blob: 566adf41f59f6f823bc30835152bbcbab97a463a [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
2 * SPCA508 chip based cameras subdriver
3 *
4 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#define MODULE_NAME "spca508"
22
23#include "gspca.h"
24
25#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0)
26static const char version[] = "2.1.0";
27
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver");
30MODULE_LICENSE("GPL");
31
32/* specific webcam descriptor */
33struct sd {
34 struct gspca_dev gspca_dev; /* !! must be the first item */
35
36 int buflen;
37 unsigned char tmpbuf[352 * 288 * 3 / 2]; /* YUVY per line */
38 unsigned char tmpbuf2[352 * 288 * 2]; /* YUYV */
39
40 unsigned char brightness;
41
42 char subtype;
43#define CreativeVista 0
44#define HamaUSBSightcam 1
45#define HamaUSBSightcam2 2
46#define IntelEasyPCCamera 3
47#define MicroInnovationIC200 4
48#define ViewQuestVQ110 5
49};
50
51/* V4L2 controls supported by the driver */
52static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
53static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
54
55static struct ctrl sd_ctrls[] = {
56#define SD_BRIGHTNESS 0
57 {
58 {
59 .id = V4L2_CID_BRIGHTNESS,
60 .type = V4L2_CTRL_TYPE_INTEGER,
61 .name = "Brightness",
62 .minimum = 0,
63 .maximum = 0xff,
64 .step = 1,
65 .default_value = 0x80,
66 },
67 .set = sd_setbrightness,
68 .get = sd_getbrightness,
69 },
70};
71
72static struct cam_mode sif_mode[] = {
73 {V4L2_PIX_FMT_YUYV, 160, 120, 3},
74 {V4L2_PIX_FMT_YUYV, 176, 144, 2},
75 {V4L2_PIX_FMT_YUYV, 320, 240, 1},
76 {V4L2_PIX_FMT_YUYV, 352, 288, 0},
77};
78
79/* Frame packet header offsets for the spca508 */
80#define SPCA508_OFFSET_TYPE 1
81#define SPCA508_OFFSET_COMPRESS 2
82#define SPCA508_OFFSET_FRAMSEQ 8
83#define SPCA508_OFFSET_WIN1LUM 11
84#define SPCA508_OFFSET_DATA 37
85
86#define SPCA508_SNAPBIT 0x20
87#define SPCA508_SNAPCTRL 0x40
88/*************** I2c ****************/
89#define SPCA508_INDEX_I2C_BASE 0x8800
90
91/*
92 * Initialization data: this is the first set-up data written to the
93 * device (before the open data).
94 */
95static __u16 spca508_init_data[][3] =
96#define IGN(x) /* nothing */
97{
98 /* line URB value, index */
99 /* 44274 1804 */ {0x0000, 0x870b},
100
101 /* 44299 1805 */ {0x0020, 0x8112},
102 /* Video drop enable, ISO streaming disable */
103 /* 44324 1806 */ {0x0003, 0x8111},
104 /* Reset compression & memory */
105 /* 44349 1807 */ {0x0000, 0x8110},
106 /* Disable all outputs */
107 /* 44372 1808 */ /* READ {0x0000, 0x8114} -> 0000: 00 */
108 /* 44398 1809 */ {0x0000, 0x8114},
109 /* SW GPIO data */
110 /* 44423 1810 */ {0x0008, 0x8110},
111 /* Enable charge pump output */
112 /* 44527 1811 */ {0x0002, 0x8116},
113 /* 200 kHz pump clock */
114 /* 44555 1812 */
115 /* UNKNOWN DIRECTION (URB_FUNCTION_SELECT_INTERFACE:) */
116 /* 44590 1813 */ {0x0003, 0x8111},
117 /* Reset compression & memory */
118 /* 44615 1814 */ {0x0000, 0x8111},
119 /* Normal mode (not reset) */
120 /* 44640 1815 */ {0x0098, 0x8110},
121 /* Enable charge pump output, sync.serial,external 2x clock */
122 /* 44665 1816 */ {0x000d, 0x8114},
123 /* SW GPIO data */
124 /* 44690 1817 */ {0x0002, 0x8116},
125 /* 200 kHz pump clock */
126 /* 44715 1818 */ {0x0020, 0x8112},
127 /* Video drop enable, ISO streaming disable */
128/* --------------------------------------- */
129 /* 44740 1819 */ {0x000f, 0x8402},
130 /* memory bank */
131 /* 44765 1820 */ {0x0000, 0x8403},
132 /* ... address */
133/* --------------------------------------- */
134/* 0x88__ is Synchronous Serial Interface. */
135/* TBD: This table could be expressed more compactly */
136/* using spca508_write_i2c_vector(). */
137/* TBD: Should see if the values in spca50x_i2c_data */
138/* would work with the VQ110 instead of the values */
139/* below. */
140 /* 44790 1821 */ {0x00c0, 0x8804},
141 /* SSI slave addr */
142 /* 44815 1822 */ {0x0008, 0x8802},
143 /* 375 Khz SSI clock */
144 /* 44838 1823 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
145 /* 44862 1824 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
146 /* 44888 1825 */ {0x0008, 0x8802},
147 /* 375 Khz SSI clock */
148 /* 44913 1826 */ {0x0012, 0x8801},
149 /* SSI reg addr */
150 /* 44938 1827 */ {0x0080, 0x8800},
151 /* SSI data to write */
152 /* 44961 1828 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
153 /* 44985 1829 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
154 /* 45009 1830 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
155 /* 45035 1831 */ {0x0008, 0x8802},
156 /* 375 Khz SSI clock */
157 /* 45060 1832 */ {0x0012, 0x8801},
158 /* SSI reg addr */
159 /* 45085 1833 */ {0x0000, 0x8800},
160 /* SSI data to write */
161 /* 45108 1834 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
162 /* 45132 1835 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
163 /* 45156 1836 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
164 /* 45182 1837 */ {0x0008, 0x8802},
165 /* 375 Khz SSI clock */
166 /* 45207 1838 */ {0x0011, 0x8801},
167 /* SSI reg addr */
168 /* 45232 1839 */ {0x0040, 0x8800},
169 /* SSI data to write */
170 /* 45255 1840 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
171 /* 45279 1841 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
172 /* 45303 1842 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
173 /* 45329 1843 */ {0x0008, 0x8802},
174 /* 45354 1844 */ {0x0013, 0x8801},
175 /* 45379 1845 */ {0x0000, 0x8800},
176 /* 45402 1846 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
177 /* 45426 1847 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
178 /* 45450 1848 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
179 /* 45476 1849 */ {0x0008, 0x8802},
180 /* 45501 1850 */ {0x0014, 0x8801},
181 /* 45526 1851 */ {0x0000, 0x8800},
182 /* 45549 1852 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
183 /* 45573 1853 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
184 /* 45597 1854 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
185 /* 45623 1855 */ {0x0008, 0x8802},
186 /* 45648 1856 */ {0x0015, 0x8801},
187 /* 45673 1857 */ {0x0001, 0x8800},
188 /* 45696 1858 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
189 /* 45720 1859 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
190 /* 45744 1860 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
191 /* 45770 1861 */ {0x0008, 0x8802},
192 /* 45795 1862 */ {0x0016, 0x8801},
193 /* 45820 1863 */ {0x0003, 0x8800},
194 /* 45843 1864 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
195 /* 45867 1865 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
196 /* 45891 1866 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
197 /* 45917 1867 */ {0x0008, 0x8802},
198 /* 45942 1868 */ {0x0017, 0x8801},
199 /* 45967 1869 */ {0x0036, 0x8800},
200 /* 45990 1870 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
201 /* 46014 1871 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
202 /* 46038 1872 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
203 /* 46064 1873 */ {0x0008, 0x8802},
204 /* 46089 1874 */ {0x0018, 0x8801},
205 /* 46114 1875 */ {0x00ec, 0x8800},
206 /* 46137 1876 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
207 /* 46161 1877 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
208 /* 46185 1878 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
209 /* 46211 1879 */ {0x0008, 0x8802},
210 /* 46236 1880 */ {0x001a, 0x8801},
211 /* 46261 1881 */ {0x0094, 0x8800},
212 /* 46284 1882 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
213 /* 46308 1883 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
214 /* 46332 1884 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
215 /* 46358 1885 */ {0x0008, 0x8802},
216 /* 46383 1886 */ {0x001b, 0x8801},
217 /* 46408 1887 */ {0x0000, 0x8800},
218 /* 46431 1888 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
219 /* 46455 1889 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
220 /* 46479 1890 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
221 /* 46505 1891 */ {0x0008, 0x8802},
222 /* 46530 1892 */ {0x0027, 0x8801},
223 /* 46555 1893 */ {0x00a2, 0x8800},
224 /* 46578 1894 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
225 /* 46602 1895 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
226 /* 46626 1896 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
227 /* 46652 1897 */ {0x0008, 0x8802},
228 /* 46677 1898 */ {0x0028, 0x8801},
229 /* 46702 1899 */ {0x0040, 0x8800},
230 /* 46725 1900 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
231 /* 46749 1901 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
232 /* 46773 1902 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
233 /* 46799 1903 */ {0x0008, 0x8802},
234 /* 46824 1904 */ {0x002a, 0x8801},
235 /* 46849 1905 */ {0x0084, 0x8800},
236 /* 46872 1906 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
237 /* 46896 1907 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
238 /* 46920 1908 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
239 /* 46946 1909 */ {0x0008, 0x8802},
240 /* 46971 1910 */ {0x002b, 0x8801},
241 /* 46996 1911 */ {0x00a8, 0x8800},
242 /* 47019 1912 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
243 /* 47043 1913 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
244 /* 47067 1914 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
245 /* 47093 1915 */ {0x0008, 0x8802},
246 /* 47118 1916 */ {0x002c, 0x8801},
247 /* 47143 1917 */ {0x00fe, 0x8800},
248 /* 47166 1918 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
249 /* 47190 1919 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
250 /* 47214 1920 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
251 /* 47240 1921 */ {0x0008, 0x8802},
252 /* 47265 1922 */ {0x002d, 0x8801},
253 /* 47290 1923 */ {0x0003, 0x8800},
254 /* 47313 1924 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
255 /* 47337 1925 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
256 /* 47361 1926 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
257 /* 47387 1927 */ {0x0008, 0x8802},
258 /* 47412 1928 */ {0x0038, 0x8801},
259 /* 47437 1929 */ {0x0083, 0x8800},
260 /* 47460 1930 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
261 /* 47484 1931 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
262 /* 47508 1932 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
263 /* 47534 1933 */ {0x0008, 0x8802},
264 /* 47559 1934 */ {0x0033, 0x8801},
265 /* 47584 1935 */ {0x0081, 0x8800},
266 /* 47607 1936 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
267 /* 47631 1937 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
268 /* 47655 1938 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
269 /* 47681 1939 */ {0x0008, 0x8802},
270 /* 47706 1940 */ {0x0034, 0x8801},
271 /* 47731 1941 */ {0x004a, 0x8800},
272 /* 47754 1942 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
273 /* 47778 1943 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
274 /* 47802 1944 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
275 /* 47828 1945 */ {0x0008, 0x8802},
276 /* 47853 1946 */ {0x0039, 0x8801},
277 /* 47878 1947 */ {0x0000, 0x8800},
278 /* 47901 1948 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
279 /* 47925 1949 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
280 /* 47949 1950 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
281 /* 47975 1951 */ {0x0008, 0x8802},
282 /* 48000 1952 */ {0x0010, 0x8801},
283 /* 48025 1953 */ {0x00a8, 0x8800},
284 /* 48048 1954 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
285 /* 48072 1955 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
286 /* 48096 1956 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
287 /* 48122 1957 */ {0x0008, 0x8802},
288 /* 48147 1958 */ {0x0006, 0x8801},
289 /* 48172 1959 */ {0x0058, 0x8800},
290 /* 48195 1960 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
291 /* 48219 1961 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
292 /* 48243 1962 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
293 /* 48269 1963 */ {0x0008, 0x8802},
294 /* 48294 1964 */ {0x0000, 0x8801},
295 /* 48319 1965 */ {0x0004, 0x8800},
296 /* 48342 1966 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
297 /* 48366 1967 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
298 /* 48390 1968 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
299 /* 48416 1969 */ {0x0008, 0x8802},
300 /* 48441 1970 */ {0x0040, 0x8801},
301 /* 48466 1971 */ {0x0080, 0x8800},
302 /* 48489 1972 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
303 /* 48513 1973 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
304 /* 48537 1974 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
305 /* 48563 1975 */ {0x0008, 0x8802},
306 /* 48588 1976 */ {0x0041, 0x8801},
307 /* 48613 1977 */ {0x000c, 0x8800},
308 /* 48636 1978 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
309 /* 48660 1979 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
310 /* 48684 1980 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
311 /* 48710 1981 */ {0x0008, 0x8802},
312 /* 48735 1982 */ {0x0042, 0x8801},
313 /* 48760 1983 */ {0x000c, 0x8800},
314 /* 48783 1984 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
315 /* 48807 1985 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
316 /* 48831 1986 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
317 /* 48857 1987 */ {0x0008, 0x8802},
318 /* 48882 1988 */ {0x0043, 0x8801},
319 /* 48907 1989 */ {0x0028, 0x8800},
320 /* 48930 1990 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
321 /* 48954 1991 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
322 /* 48978 1992 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
323 /* 49004 1993 */ {0x0008, 0x8802},
324 /* 49029 1994 */ {0x0044, 0x8801},
325 /* 49054 1995 */ {0x0080, 0x8800},
326 /* 49077 1996 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
327 /* 49101 1997 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
328 /* 49125 1998 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
329 /* 49151 1999 */ {0x0008, 0x8802},
330 /* 49176 2000 */ {0x0045, 0x8801},
331 /* 49201 2001 */ {0x0020, 0x8800},
332 /* 49224 2002 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
333 /* 49248 2003 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
334 /* 49272 2004 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
335 /* 49298 2005 */ {0x0008, 0x8802},
336 /* 49323 2006 */ {0x0046, 0x8801},
337 /* 49348 2007 */ {0x0020, 0x8800},
338 /* 49371 2008 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
339 /* 49395 2009 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
340 /* 49419 2010 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
341 /* 49445 2011 */ {0x0008, 0x8802},
342 /* 49470 2012 */ {0x0047, 0x8801},
343 /* 49495 2013 */ {0x0080, 0x8800},
344 /* 49518 2014 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
345 /* 49542 2015 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
346 /* 49566 2016 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
347 /* 49592 2017 */ {0x0008, 0x8802},
348 /* 49617 2018 */ {0x0048, 0x8801},
349 /* 49642 2019 */ {0x004c, 0x8800},
350 /* 49665 2020 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
351 /* 49689 2021 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
352 /* 49713 2022 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
353 /* 49739 2023 */ {0x0008, 0x8802},
354 /* 49764 2024 */ {0x0049, 0x8801},
355 /* 49789 2025 */ {0x0084, 0x8800},
356 /* 49812 2026 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
357 /* 49836 2027 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
358 /* 49860 2028 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
359 /* 49886 2029 */ {0x0008, 0x8802},
360 /* 49911 2030 */ {0x004a, 0x8801},
361 /* 49936 2031 */ {0x0084, 0x8800},
362 /* 49959 2032 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
363 /* 49983 2033 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
364 /* 50007 2034 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
365 /* 50033 2035 */ {0x0008, 0x8802},
366 /* 50058 2036 */ {0x004b, 0x8801},
367 /* 50083 2037 */ {0x0084, 0x8800},
368 /* 50106 2038 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
369 /* --------------------------------------- */
370 /* 50132 2039 */ {0x0012, 0x8700},
371 /* Clock speed 48Mhz/(2+2)/2= 6 Mhz */
372 /* 50157 2040 */ {0x0000, 0x8701},
373 /* CKx1 clock delay adj */
374 /* 50182 2041 */ {0x0000, 0x8701},
375 /* CKx1 clock delay adj */
376 /* 50207 2042 */ {0x0001, 0x870c},
377 /* CKOx2 output */
378 /* --------------------------------------- */
379 /* 50232 2043 */ {0x0080, 0x8600},
380 /* Line memory read counter (L) */
381 /* 50257 2044 */ {0x0001, 0x8606},
382 /* reserved */
383 /* 50282 2045 */ {0x0064, 0x8607},
384 /* Line memory read counter (H) 0x6480=25,728 */
385 /* 50307 2046 */ {0x002a, 0x8601},
386 /* CDSP sharp interpolation mode,
387 * line sel for color sep, edge enhance enab */
388 /* 50332 2047 */ {0x0000, 0x8602},
389 /* optical black level for user settng = 0 */
390 /* 50357 2048 */ {0x0080, 0x8600},
391 /* Line memory read counter (L) */
392 /* 50382 2049 */ {0x000a, 0x8603},
393 /* optical black level calc mode: auto; optical black offset = 10 */
394 /* 50407 2050 */ {0x00df, 0x865b},
395 /* Horiz offset for valid pixels (L)=0xdf */
396 /* 50432 2051 */ {0x0012, 0x865c},
397 /* Vert offset for valid lines (L)=0x12 */
398
399/* The following two lines seem to be the "wrong" resolution. */
400/* But perhaps these indicate the actual size of the sensor */
401/* rather than the size of the current video mode. */
402 /* 50457 2052 */ {0x0058, 0x865d},
403 /* Horiz valid pixels (*4) (L) = 352 */
404 /* 50482 2053 */ {0x0048, 0x865e},
405 /* Vert valid lines (*4) (L) = 288 */
406
407 /* 50507 2054 */ {0x0015, 0x8608},
408 /* A11 Coef ... */
409 /* 50532 2055 */ {0x0030, 0x8609},
410 /* 50557 2056 */ {0x00fb, 0x860a},
411 /* 50582 2057 */ {0x003e, 0x860b},
412 /* 50607 2058 */ {0x00ce, 0x860c},
413 /* 50632 2059 */ {0x00f4, 0x860d},
414 /* 50657 2060 */ {0x00eb, 0x860e},
415 /* 50682 2061 */ {0x00dc, 0x860f},
416 /* 50707 2062 */ {0x0039, 0x8610},
417 /* 50732 2063 */ {0x0001, 0x8611},
418 /* R offset for white balance ... */
419 /* 50757 2064 */ {0x0000, 0x8612},
420 /* 50782 2065 */ {0x0001, 0x8613},
421 /* 50807 2066 */ {0x0000, 0x8614},
422 /* 50832 2067 */ {0x005b, 0x8651},
423 /* R gain for white balance ... */
424 /* 50857 2068 */ {0x0040, 0x8652},
425 /* 50882 2069 */ {0x0060, 0x8653},
426 /* 50907 2070 */ {0x0040, 0x8654},
427 /* 50932 2071 */ {0x0000, 0x8655},
428 /* 50957 2072 */ {0x0001, 0x863f},
429 /* Fixed gamma correction enable, USB control,
430 * lum filter disable, lum noise clip disable */
431 /* 50982 2073 */ {0x00a1, 0x8656},
432 /* Window1 size 256x256, Windows2 size 64x64,
433 * gamma look-up disable, new edge enhancement enable */
434 /* 51007 2074 */ {0x0018, 0x8657},
435 /* Edge gain high thresh */
436 /* 51032 2075 */ {0x0020, 0x8658},
437 /* Edge gain low thresh */
438 /* 51057 2076 */ {0x000a, 0x8659},
439 /* Edge bandwidth high threshold */
440 /* 51082 2077 */ {0x0005, 0x865a},
441 /* Edge bandwidth low threshold */
442 /* -------------------------------- */
443 /* 51107 2078 */ {0x0030, 0x8112},
444 /* Video drop enable, ISO streaming enable */
445 /* 51130 2079 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
446 /* 51154 2080 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
447 /* 51180 2081 */ {0xa908, 0x8802},
448 /* 51205 2082 */ {0x0034, 0x8801},
449 /* SSI reg addr */
450 /* 51230 2083 */ {0x00ca, 0x8800},
451 /* SSI data to write */
452 /* 51253 2084 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
453 /* 51277 2085 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
454 /* 51301 2086 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
455 /* 51327 2087 */ {0x1f08, 0x8802},
456 /* 51352 2088 */ {0x0006, 0x8801},
457 /* 51377 2089 */ {0x0080, 0x8800},
458 /* 51400 2090 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
459
460/* ----- Read back coefs we wrote earlier. */
461 /* 51424 2091 */ /* READ { 0, 0x0000, 0x8608 } -> 0000: 15 */
462 /* 51448 2092 */ /* READ { 0, 0x0000, 0x8609 } -> 0000: 30 */
463 /* 51472 2093 */ /* READ { 0, 0x0000, 0x860a } -> 0000: fb */
464 /* 51496 2094 */ /* READ { 0, 0x0000, 0x860b } -> 0000: 3e */
465 /* 51520 2095 */ /* READ { 0, 0x0000, 0x860c } -> 0000: ce */
466 /* 51544 2096 */ /* READ { 0, 0x0000, 0x860d } -> 0000: f4 */
467 /* 51568 2097 */ /* READ { 0, 0x0000, 0x860e } -> 0000: eb */
468 /* 51592 2098 */ /* READ { 0, 0x0000, 0x860f } -> 0000: dc */
469 /* 51616 2099 */ /* READ { 0, 0x0000, 0x8610 } -> 0000: 39 */
470 /* 51640 2100 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
471 /* 51664 2101 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 08 */
472 /* 51690 2102 */ {0xb008, 0x8802},
473 /* 51715 2103 */ {0x0006, 0x8801},
474 /* 51740 2104 */ {0x007d, 0x8800},
475 /* 51763 2105 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
476
477
478 /* This chunk is seemingly redundant with */
479 /* earlier commands (A11 Coef...), but if I disable it, */
480 /* the image appears too dark. Maybe there was some kind of */
481 /* reset since the earlier commands, so this is necessary again. */
482 /* 51789 2106 */ {0x0015, 0x8608},
483 /* 51814 2107 */ {0x0030, 0x8609},
484 /* 51839 2108 */ {0xfffb, 0x860a},
485 /* 51864 2109 */ {0x003e, 0x860b},
486 /* 51889 2110 */ {0xffce, 0x860c},
487 /* 51914 2111 */ {0xfff4, 0x860d},
488 /* 51939 2112 */ {0xffeb, 0x860e},
489 /* 51964 2113 */ {0xffdc, 0x860f},
490 /* 51989 2114 */ {0x0039, 0x8610},
491 /* 52014 2115 */ {0x0018, 0x8657},
492
493 /* 52039 2116 */ {0x0000, 0x8508},
494 /* Disable compression. */
495 /* Previous line was:
496 * 52039 2116 * { 0, 0x0021, 0x8508 }, * Enable compression. */
497 /* 52064 2117 */ {0x0032, 0x850b},
498 /* compression stuff */
499 /* 52089 2118 */ {0x0003, 0x8509},
500 /* compression stuff */
501 /* 52114 2119 */ {0x0011, 0x850a},
502 /* compression stuff */
503 /* 52139 2120 */ {0x0021, 0x850d},
504 /* compression stuff */
505 /* 52164 2121 */ {0x0010, 0x850c},
506 /* compression stuff */
507 /* 52189 2122 */ {0x0003, 0x8500},
508 /* *** Video mode: 160x120 */
509 /* 52214 2123 */ {0x0001, 0x8501},
510 /* Hardware-dominated snap control */
511 /* 52239 2124 */ {0x0061, 0x8656},
512 /* Window1 size 128x128, Windows2 size 128x128,
513 * gamma look-up disable, new edge enhancement enable */
514 /* 52264 2125 */ {0x0018, 0x8617},
515 /* Window1 start X (*2) */
516 /* 52289 2126 */ {0x0008, 0x8618},
517 /* Window1 start Y (*2) */
518 /* 52314 2127 */ {0x0061, 0x8656},
519 /* Window1 size 128x128, Windows2 size 128x128,
520 * gamma look-up disable, new edge enhancement enable */
521 /* 52339 2128 */ {0x0058, 0x8619},
522 /* Window2 start X (*2) */
523 /* 52364 2129 */ {0x0008, 0x861a},
524 /* Window2 start Y (*2) */
525 /* 52389 2130 */ {0x00ff, 0x8615},
526 /* High lum thresh for white balance */
527 /* 52414 2131 */ {0x0000, 0x8616},
528 /* Low lum thresh for white balance */
529 /* 52439 2132 */ {0x0012, 0x8700},
530 /* Clock speed 48Mhz/(2+2)/2= 6 Mhz */
531 /* 52464 2133 */ {0x0012, 0x8700},
532 /* Clock speed 48Mhz/(2+2)/2= 6 Mhz */
533 /* 52487 2134 */ /* READ { 0, 0x0000, 0x8656 } -> 0000: 61 */
534 /* 52513 2135 */ {0x0028, 0x8802},
535 /* 375 Khz SSI clock, SSI r/w sync with VSYNC */
536 /* 52536 2136 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
537 /* 52560 2137 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 28 */
538 /* 52586 2138 */ {0x1f28, 0x8802},
539 /* 375 Khz SSI clock, SSI r/w sync with VSYNC */
540 /* 52611 2139 */ {0x0010, 0x8801},
541 /* SSI reg addr */
542 /* 52636 2140 */ {0x003e, 0x8800},
543 /* SSI data to write */
544 /* 52659 2141 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
545 /* 52685 2142 */ {0x0028, 0x8802},
546 /* 52708 2143 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
547 /* 52732 2144 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 28 */
548 /* 52758 2145 */ {0x1f28, 0x8802},
549 /* 52783 2146 */ {0x0000, 0x8801},
550 /* 52808 2147 */ {0x001f, 0x8800},
551 /* 52831 2148 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
552 /* 52857 2149 */ {0x0001, 0x8602},
553 /* optical black level for user settning = 1 */
554
555 /* Original: */
556 /* 52882 2150 */ {0x0023, 0x8700},
557 /* Clock speed 48Mhz/(3+2)/4= 2.4 Mhz */
558 /* 52907 2151 */ {0x000f, 0x8602},
559 /* optical black level for user settning = 15 */
560
561 /* 52932 2152 */ {0x0028, 0x8802},
562 /* 52955 2153 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
563 /* 52979 2154 */ /* READ { 0, 0x0001, 0x8802 } -> 0000: 28 */
564 /* 53005 2155 */ {0x1f28, 0x8802},
565 /* 53030 2156 */ {0x0010, 0x8801},
566 /* 53055 2157 */ {0x007b, 0x8800},
567 /* 53078 2158 */ /* READ { 0, 0x0001, 0x8803 } -> 0000: 00 */
568 /* 53104 2159 */ {0x002f, 0x8651},
569 /* R gain for white balance ... */
570 /* 53129 2160 */ {0x0080, 0x8653},
571 /* 53152 2161 */ /* READ { 0, 0x0000, 0x8655 } -> 0000: 00 */
572 /* 53178 2162 */ {0x0000, 0x8655},
573
574 /* 53203 2163 */ {0x0030, 0x8112},
575 /* Video drop enable, ISO streaming enable */
576 /* 53228 2164 */ {0x0020, 0x8112},
577 /* Video drop enable, ISO streaming disable */
578 /* 53252 2165 */
579 /* UNKNOWN DIRECTION (URB_FUNCTION_SELECT_INTERFACE: (ALT=0) ) */
580 {0, 0}
581};
582
583
584/*
585 * Initialization data for Intel EasyPC Camera CS110
586 */
587static __u16 spca508cs110_init_data[][3] = {
588 {0x0000, 0x870b}, /* Reset CTL3 */
589 {0x0003, 0x8111}, /* Soft Reset compression, memory, TG & CDSP */
590 {0x0000, 0x8111}, /* Normal operation on reset */
591 {0x0090, 0x8110},
592 /* External Clock 2x & Synchronous Serial Interface Output */
593 {0x0020, 0x8112}, /* Video Drop packet enable */
594 {0x0000, 0x8114}, /* Software GPIO output data */
595 {0x0001, 0x8114},
596 {0x0001, 0x8114},
597 {0x0001, 0x8114},
598 {0x0003, 0x8114},
599
600 /* Initial sequence Synchronous Serial Interface */
601 {0x000f, 0x8402}, /* Memory bank Address */
602 {0x0000, 0x8403}, /* Memory bank Address */
603 {0x00ba, 0x8804}, /* SSI Slave address */
604 {0x0010, 0x8802}, /* 93.75kHz SSI Clock Two DataByte */
605 {0x0010, 0x8802}, /* 93.75kHz SSI Clock two DataByte */
606
607 {0x0001, 0x8801},
608 {0x000a, 0x8805},/* a - NWG: Dunno what this is about */
609 {0x0000, 0x8800},
610 {0x0010, 0x8802},
611
612 {0x0002, 0x8801},
613 {0x0000, 0x8805},
614 {0x0000, 0x8800},
615 {0x0010, 0x8802},
616
617 {0x0003, 0x8801},
618 {0x0027, 0x8805},
619 {0x0001, 0x8800},
620 {0x0010, 0x8802},
621
622 {0x0004, 0x8801},
623 {0x0065, 0x8805},
624 {0x0001, 0x8800},
625 {0x0010, 0x8802},
626
627 {0x0005, 0x8801},
628 {0x0003, 0x8805},
629 {0x0000, 0x8800},
630 {0x0010, 0x8802},
631
632 {0x0006, 0x8801},
633 {0x001c, 0x8805},
634 {0x0000, 0x8800},
635 {0x0010, 0x8802},
636
637 {0x0007, 0x8801},
638 {0x002a, 0x8805},
639 {0x0000, 0x8800},
640 {0x0010, 0x8802},
641
642 {0x0002, 0x8704}, /* External input CKIx1 */
643 {0x0001, 0x8606}, /* 1 Line memory Read Counter (H) Result: (d)410 */
644 {0x009a, 0x8600}, /* Line memory Read Counter (L) */
645 {0x0001, 0x865b}, /* 1 Horizontal Offset for Valid Pixel(L) */
646 {0x0003, 0x865c}, /* 3 Vertical Offset for Valid Lines(L) */
647 {0x0058, 0x865d}, /* 58 Horizontal Valid Pixel Window(L) */
648
649 {0x0006, 0x8660}, /* Nibble data + input order */
650
651 {0x000a, 0x8602}, /* Optical black level set to 0x0a */
652/* 1945 */ {0x0000, 0x8603}, /* Optical black level Offset */
653
654/* 1962 * {0, 0x0000, 0x8611}, * 0 R Offset for white Balance */
655/* 1963 * {0, 0x0000, 0x8612}, * 1 Gr Offset for white Balance */
656/* 1964 * {0, 0x0000, 0x8613}, * 1f B Offset for white Balance */
657/* 1965 * {0, 0x0000, 0x8614}, * f0 Gb Offset for white Balance */
658
659 {0x0040, 0x8651}, /* 2b BLUE gain for white balance good at all 60 */
660 {0x0030, 0x8652}, /* 41 Gr Gain for white Balance (L) */
661 {0x0035, 0x8653}, /* 26 RED gain for white balance */
662 {0x0035, 0x8654}, /* 40Gb Gain for white Balance (L) */
663 {0x0041, 0x863f},
664 /* Fixed Gamma correction enabled (makes colours look better) */
665
666/* 2422 */ {0x0000, 0x8655},
667 /* High bits for white balance*****brightness control*** */
668 {}
669};
670
671static __u16 spca508_sightcam_init_data[][3] = {
672/* This line seems to setup the frame/canvas */
673 /*368 */ {0x000f, 0x8402},
674
675/* Theese 6 lines are needed to startup the webcam */
676 /*398 */ {0x0090, 0x8110},
677 /*399 */ {0x0001, 0x8114},
678 /*400 */ {0x0001, 0x8114},
679 /*401 */ {0x0001, 0x8114},
680 /*402 */ {0x0003, 0x8114},
681 /*403 */ {0x0080, 0x8804},
682
683/* This part seems to make the pictures darker? (autobrightness?) */
684 /*436 */ {0x0001, 0x8801},
685 /*437 */ {0x0004, 0x8800},
686 /*439 */ {0x0003, 0x8801},
687 /*440 */ {0x00e0, 0x8800},
688 /*442 */ {0x0004, 0x8801},
689 /*443 */ {0x00b4, 0x8800},
690 /*445 */ {0x0005, 0x8801},
691 /*446 */ {0x0000, 0x8800},
692
693 /*448 */ {0x0006, 0x8801},
694 /*449 */ {0x00e0, 0x8800},
695 /*451 */ {0x0007, 0x8801},
696 /*452 */ {0x000c, 0x8800},
697
698/* This section is just needed, it probably
699 * does something like the previous section,
700 * but the cam won't start if it's not included.
701 */
702 /*484 */ {0x0014, 0x8801},
703 /*485 */ {0x0008, 0x8800},
704 /*487 */ {0x0015, 0x8801},
705 /*488 */ {0x0067, 0x8800},
706 /*490 */ {0x0016, 0x8801},
707 /*491 */ {0x0000, 0x8800},
708 /*493 */ {0x0017, 0x8801},
709 /*494 */ {0x0020, 0x8800},
710 /*496 */ {0x0018, 0x8801},
711 /*497 */ {0x0044, 0x8800},
712
713/* Makes the picture darker - and the
714 * cam won't start if not included
715 */
716 /*505 */ {0x001e, 0x8801},
717 /*506 */ {0x00ea, 0x8800},
718 /*508 */ {0x001f, 0x8801},
719 /*509 */ {0x0001, 0x8800},
720 /*511 */ {0x0003, 0x8801},
721 /*512 */ {0x00e0, 0x8800},
722
723/* seems to place the colors ontop of each other #1 */
724 /*517 */ {0x0006, 0x8704},
725 /*518 */ {0x0001, 0x870c},
726 /*519 */ {0x0016, 0x8600},
727 /*520 */ {0x0002, 0x8606},
728
729/* if not included the pictures becomes _very_ dark */
730 /*521 */ {0x0064, 0x8607},
731 /*522 */ {0x003a, 0x8601},
732 /*523 */ {0x0000, 0x8602},
733
734/* seems to place the colors ontop of each other #2 */
735 /*524 */ {0x0016, 0x8600},
736 /*525 */ {0x0018, 0x8617},
737 /*526 */ {0x0008, 0x8618},
738 /*527 */ {0x00a1, 0x8656},
739
740/* webcam won't start if not included */
741 /*528 */ {0x0007, 0x865b},
742 /*529 */ {0x0001, 0x865c},
743 /*530 */ {0x0058, 0x865d},
744 /*531 */ {0x0048, 0x865e},
745
746/* adjusts the colors */
747 /*541 */ {0x0049, 0x8651},
748 /*542 */ {0x0040, 0x8652},
749 /*543 */ {0x004c, 0x8653},
750 /*544 */ {0x0040, 0x8654},
751
752 {0, 0}
753};
754
755static __u16 spca508_sightcam2_init_data[][3] = {
756/* 35 */ {0x0020, 0x8112},
757
758/* 36 */ {0x000f, 0x8402},
759/* 37 */ {0x0000, 0x8403},
760
761/* 38 */ {0x0008, 0x8201},
762/* 39 */ {0x0008, 0x8200},
763/* 40 */ {0x0001, 0x8200},
764/* 43 */ {0x0009, 0x8201},
765/* 44 */ {0x0008, 0x8200},
766/* 45 */ {0x0001, 0x8200},
767/* 48 */ {0x000a, 0x8201},
768/* 49 */ {0x0008, 0x8200},
769/* 50 */ {0x0001, 0x8200},
770/* 53 */ {0x000b, 0x8201},
771/* 54 */ {0x0008, 0x8200},
772/* 55 */ {0x0001, 0x8200},
773/* 58 */ {0x000c, 0x8201},
774/* 59 */ {0x0008, 0x8200},
775/* 60 */ {0x0001, 0x8200},
776/* 63 */ {0x000d, 0x8201},
777/* 64 */ {0x0008, 0x8200},
778/* 65 */ {0x0001, 0x8200},
779/* 68 */ {0x000e, 0x8201},
780/* 69 */ {0x0008, 0x8200},
781/* 70 */ {0x0001, 0x8200},
782/* 73 */ {0x0007, 0x8201},
783/* 74 */ {0x0008, 0x8200},
784/* 75 */ {0x0001, 0x8200},
785/* 78 */ {0x000f, 0x8201},
786/* 79 */ {0x0008, 0x8200},
787/* 80 */ {0x0001, 0x8200},
788
789/* 84 */ {0x0018, 0x8660},
790/* 85 */ {0x0010, 0x8201},
791
792/* 86 */ {0x0008, 0x8200},
793/* 87 */ {0x0001, 0x8200},
794/* 90 */ {0x0011, 0x8201},
795/* 91 */ {0x0008, 0x8200},
796/* 92 */ {0x0001, 0x8200},
797
798/* 95 */ {0x0000, 0x86b0},
799/* 96 */ {0x0034, 0x86b1},
800/* 97 */ {0x0000, 0x86b2},
801/* 98 */ {0x0049, 0x86b3},
802/* 99 */ {0x0000, 0x86b4},
803/* 100 */ {0x0000, 0x86b4},
804
805/* 101 */ {0x0012, 0x8201},
806/* 102 */ {0x0008, 0x8200},
807/* 103 */ {0x0001, 0x8200},
808/* 106 */ {0x0013, 0x8201},
809/* 107 */ {0x0008, 0x8200},
810/* 108 */ {0x0001, 0x8200},
811
812/* 111 */ {0x0001, 0x86b0},
813/* 112 */ {0x00aa, 0x86b1},
814/* 113 */ {0x0000, 0x86b2},
815/* 114 */ {0x00e4, 0x86b3},
816/* 115 */ {0x0000, 0x86b4},
817/* 116 */ {0x0000, 0x86b4},
818
819/* 118 */ {0x0018, 0x8660},
820
821/* 119 */ {0x0090, 0x8110},
822/* 120 */ {0x0001, 0x8114},
823/* 121 */ {0x0001, 0x8114},
824/* 122 */ {0x0001, 0x8114},
825/* 123 */ {0x0003, 0x8114},
826
827/* 124 */ {0x0080, 0x8804},
828/* 157 */ {0x0003, 0x8801},
829/* 158 */ {0x0012, 0x8800},
830/* 160 */ {0x0004, 0x8801},
831/* 161 */ {0x0005, 0x8800},
832/* 163 */ {0x0005, 0x8801},
833/* 164 */ {0x0000, 0x8800},
834/* 166 */ {0x0006, 0x8801},
835/* 167 */ {0x0000, 0x8800},
836/* 169 */ {0x0007, 0x8801},
837/* 170 */ {0x0000, 0x8800},
838/* 172 */ {0x0008, 0x8801},
839/* 173 */ {0x0005, 0x8800},
840/* 175 */ {0x000a, 0x8700},
841/* 176 */ {0x000e, 0x8801},
842/* 177 */ {0x0004, 0x8800},
843/* 179 */ {0x0005, 0x8801},
844/* 180 */ {0x0047, 0x8800},
845/* 182 */ {0x0006, 0x8801},
846/* 183 */ {0x0000, 0x8800},
847/* 185 */ {0x0007, 0x8801},
848/* 186 */ {0x00c0, 0x8800},
849/* 188 */ {0x0008, 0x8801},
850/* 189 */ {0x0003, 0x8800},
851/* 191 */ {0x0013, 0x8801},
852/* 192 */ {0x0001, 0x8800},
853/* 194 */ {0x0009, 0x8801},
854/* 195 */ {0x0000, 0x8800},
855/* 197 */ {0x000a, 0x8801},
856/* 198 */ {0x0000, 0x8800},
857/* 200 */ {0x000b, 0x8801},
858/* 201 */ {0x0000, 0x8800},
859/* 203 */ {0x000c, 0x8801},
860/* 204 */ {0x0000, 0x8800},
861/* 206 */ {0x000e, 0x8801},
862/* 207 */ {0x0004, 0x8800},
863/* 209 */ {0x000f, 0x8801},
864/* 210 */ {0x0000, 0x8800},
865/* 212 */ {0x0010, 0x8801},
866/* 213 */ {0x0006, 0x8800},
867/* 215 */ {0x0011, 0x8801},
868/* 216 */ {0x0006, 0x8800},
869/* 218 */ {0x0012, 0x8801},
870/* 219 */ {0x0000, 0x8800},
871/* 221 */ {0x0013, 0x8801},
872/* 222 */ {0x0001, 0x8800},
873
874/* 224 */ {0x000a, 0x8700},
875/* 225 */ {0x0000, 0x8702},
876/* 226 */ {0x0000, 0x8703},
877/* 227 */ {0x00c2, 0x8704},
878/* 228 */ {0x0001, 0x870c},
879
880/* 229 */ {0x0044, 0x8600},
881/* 230 */ {0x0002, 0x8606},
882/* 231 */ {0x0064, 0x8607},
883/* 232 */ {0x003a, 0x8601},
884/* 233 */ {0x0008, 0x8602},
885/* 234 */ {0x0044, 0x8600},
886/* 235 */ {0x0018, 0x8617},
887/* 236 */ {0x0008, 0x8618},
888/* 237 */ {0x00a1, 0x8656},
889/* 238 */ {0x0004, 0x865b},
890/* 239 */ {0x0002, 0x865c},
891/* 240 */ {0x0058, 0x865d},
892/* 241 */ {0x0048, 0x865e},
893/* 242 */ {0x0012, 0x8608},
894/* 243 */ {0x002c, 0x8609},
895/* 244 */ {0x0002, 0x860a},
896/* 245 */ {0x002c, 0x860b},
897/* 246 */ {0x00db, 0x860c},
898/* 247 */ {0x00f9, 0x860d},
899/* 248 */ {0x00f1, 0x860e},
900/* 249 */ {0x00e3, 0x860f},
901/* 250 */ {0x002c, 0x8610},
902/* 251 */ {0x006c, 0x8651},
903/* 252 */ {0x0041, 0x8652},
904/* 253 */ {0x0059, 0x8653},
905/* 254 */ {0x0040, 0x8654},
906/* 255 */ {0x00fa, 0x8611},
907/* 256 */ {0x00ff, 0x8612},
908/* 257 */ {0x00f8, 0x8613},
909/* 258 */ {0x0000, 0x8614},
910/* 259 */ {0x0001, 0x863f},
911/* 260 */ {0x0000, 0x8640},
912/* 261 */ {0x0026, 0x8641},
913/* 262 */ {0x0045, 0x8642},
914/* 263 */ {0x0060, 0x8643},
915/* 264 */ {0x0075, 0x8644},
916/* 265 */ {0x0088, 0x8645},
917/* 266 */ {0x009b, 0x8646},
918/* 267 */ {0x00b0, 0x8647},
919/* 268 */ {0x00c5, 0x8648},
920/* 269 */ {0x00d2, 0x8649},
921/* 270 */ {0x00dc, 0x864a},
922/* 271 */ {0x00e5, 0x864b},
923/* 272 */ {0x00eb, 0x864c},
924/* 273 */ {0x00f0, 0x864d},
925/* 274 */ {0x00f6, 0x864e},
926/* 275 */ {0x00fa, 0x864f},
927/* 276 */ {0x00ff, 0x8650},
928/* 277 */ {0x0060, 0x8657},
929/* 278 */ {0x0010, 0x8658},
930/* 279 */ {0x0018, 0x8659},
931/* 280 */ {0x0005, 0x865a},
932/* 281 */ {0x0018, 0x8660},
933/* 282 */ {0x0003, 0x8509},
934/* 283 */ {0x0011, 0x850a},
935/* 284 */ {0x0032, 0x850b},
936/* 285 */ {0x0010, 0x850c},
937/* 286 */ {0x0021, 0x850d},
938/* 287 */ {0x0001, 0x8500},
939/* 288 */ {0x0000, 0x8508},
940/* 289 */ {0x0012, 0x8608},
941/* 290 */ {0x002c, 0x8609},
942/* 291 */ {0x0002, 0x860a},
943/* 292 */ {0x0039, 0x860b},
944/* 293 */ {0x00d0, 0x860c},
945/* 294 */ {0x00f7, 0x860d},
946/* 295 */ {0x00ed, 0x860e},
947/* 296 */ {0x00db, 0x860f},
948/* 297 */ {0x0039, 0x8610},
949/* 298 */ {0x0012, 0x8657},
950/* 299 */ {0x000c, 0x8619},
951/* 300 */ {0x0004, 0x861a},
952/* 301 */ {0x00a1, 0x8656},
953/* 302 */ {0x00c8, 0x8615},
954/* 303 */ {0x0032, 0x8616},
955
956/* 306 */ {0x0030, 0x8112},
957/* 313 */ {0x0020, 0x8112},
958/* 314 */ {0x0020, 0x8112},
959/* 315 */ {0x000f, 0x8402},
960/* 316 */ {0x0000, 0x8403},
961
962/* 317 */ {0x0090, 0x8110},
963/* 318 */ {0x0001, 0x8114},
964/* 319 */ {0x0001, 0x8114},
965/* 320 */ {0x0001, 0x8114},
966/* 321 */ {0x0003, 0x8114},
967/* 322 */ {0x0080, 0x8804},
968
969/* 355 */ {0x0003, 0x8801},
970/* 356 */ {0x0012, 0x8800},
971/* 358 */ {0x0004, 0x8801},
972/* 359 */ {0x0005, 0x8800},
973/* 361 */ {0x0005, 0x8801},
974/* 362 */ {0x0047, 0x8800},
975/* 364 */ {0x0006, 0x8801},
976/* 365 */ {0x0000, 0x8800},
977/* 367 */ {0x0007, 0x8801},
978/* 368 */ {0x00c0, 0x8800},
979/* 370 */ {0x0008, 0x8801},
980/* 371 */ {0x0003, 0x8800},
981/* 373 */ {0x000a, 0x8700},
982/* 374 */ {0x000e, 0x8801},
983/* 375 */ {0x0004, 0x8800},
984/* 377 */ {0x0005, 0x8801},
985/* 378 */ {0x0047, 0x8800},
986/* 380 */ {0x0006, 0x8801},
987/* 381 */ {0x0000, 0x8800},
988/* 383 */ {0x0007, 0x8801},
989/* 384 */ {0x00c0, 0x8800},
990/* 386 */ {0x0008, 0x8801},
991/* 387 */ {0x0003, 0x8800},
992/* 389 */ {0x0013, 0x8801},
993/* 390 */ {0x0001, 0x8800},
994/* 392 */ {0x0009, 0x8801},
995/* 393 */ {0x0000, 0x8800},
996/* 395 */ {0x000a, 0x8801},
997/* 396 */ {0x0000, 0x8800},
998/* 398 */ {0x000b, 0x8801},
999/* 399 */ {0x0000, 0x8800},
1000/* 401 */ {0x000c, 0x8801},
1001/* 402 */ {0x0000, 0x8800},
1002/* 404 */ {0x000e, 0x8801},
1003/* 405 */ {0x0004, 0x8800},
1004/* 407 */ {0x000f, 0x8801},
1005/* 408 */ {0x0000, 0x8800},
1006/* 410 */ {0x0010, 0x8801},
1007/* 411 */ {0x0006, 0x8800},
1008/* 413 */ {0x0011, 0x8801},
1009/* 414 */ {0x0006, 0x8800},
1010/* 416 */ {0x0012, 0x8801},
1011/* 417 */ {0x0000, 0x8800},
1012/* 419 */ {0x0013, 0x8801},
1013/* 420 */ {0x0001, 0x8800},
1014/* 422 */ {0x000a, 0x8700},
1015/* 423 */ {0x0000, 0x8702},
1016/* 424 */ {0x0000, 0x8703},
1017/* 425 */ {0x00c2, 0x8704},
1018/* 426 */ {0x0001, 0x870c},
1019/* 427 */ {0x0044, 0x8600},
1020/* 428 */ {0x0002, 0x8606},
1021/* 429 */ {0x0064, 0x8607},
1022/* 430 */ {0x003a, 0x8601},
1023/* 431 */ {0x0008, 0x8602},
1024/* 432 */ {0x0044, 0x8600},
1025/* 433 */ {0x0018, 0x8617},
1026/* 434 */ {0x0008, 0x8618},
1027/* 435 */ {0x00a1, 0x8656},
1028/* 436 */ {0x0004, 0x865b},
1029/* 437 */ {0x0002, 0x865c},
1030/* 438 */ {0x0058, 0x865d},
1031/* 439 */ {0x0048, 0x865e},
1032/* 440 */ {0x0012, 0x8608},
1033/* 441 */ {0x002c, 0x8609},
1034/* 442 */ {0x0002, 0x860a},
1035/* 443 */ {0x002c, 0x860b},
1036/* 444 */ {0x00db, 0x860c},
1037/* 445 */ {0x00f9, 0x860d},
1038/* 446 */ {0x00f1, 0x860e},
1039/* 447 */ {0x00e3, 0x860f},
1040/* 448 */ {0x002c, 0x8610},
1041/* 449 */ {0x006c, 0x8651},
1042/* 450 */ {0x0041, 0x8652},
1043/* 451 */ {0x0059, 0x8653},
1044/* 452 */ {0x0040, 0x8654},
1045/* 453 */ {0x00fa, 0x8611},
1046/* 454 */ {0x00ff, 0x8612},
1047/* 455 */ {0x00f8, 0x8613},
1048/* 456 */ {0x0000, 0x8614},
1049/* 457 */ {0x0001, 0x863f},
1050/* 458 */ {0x0000, 0x8640},
1051/* 459 */ {0x0026, 0x8641},
1052/* 460 */ {0x0045, 0x8642},
1053/* 461 */ {0x0060, 0x8643},
1054/* 462 */ {0x0075, 0x8644},
1055/* 463 */ {0x0088, 0x8645},
1056/* 464 */ {0x009b, 0x8646},
1057/* 465 */ {0x00b0, 0x8647},
1058/* 466 */ {0x00c5, 0x8648},
1059/* 467 */ {0x00d2, 0x8649},
1060/* 468 */ {0x00dc, 0x864a},
1061/* 469 */ {0x00e5, 0x864b},
1062/* 470 */ {0x00eb, 0x864c},
1063/* 471 */ {0x00f0, 0x864d},
1064/* 472 */ {0x00f6, 0x864e},
1065/* 473 */ {0x00fa, 0x864f},
1066/* 474 */ {0x00ff, 0x8650},
1067/* 475 */ {0x0060, 0x8657},
1068/* 476 */ {0x0010, 0x8658},
1069/* 477 */ {0x0018, 0x8659},
1070/* 478 */ {0x0005, 0x865a},
1071/* 479 */ {0x0018, 0x8660},
1072/* 480 */ {0x0003, 0x8509},
1073/* 481 */ {0x0011, 0x850a},
1074/* 482 */ {0x0032, 0x850b},
1075/* 483 */ {0x0010, 0x850c},
1076/* 484 */ {0x0021, 0x850d},
1077/* 485 */ {0x0001, 0x8500},
1078/* 486 */ {0x0000, 0x8508},
1079
1080/* 487 */ {0x0012, 0x8608},
1081/* 488 */ {0x002c, 0x8609},
1082/* 489 */ {0x0002, 0x860a},
1083/* 490 */ {0x0039, 0x860b},
1084/* 491 */ {0x00d0, 0x860c},
1085/* 492 */ {0x00f7, 0x860d},
1086/* 493 */ {0x00ed, 0x860e},
1087/* 494 */ {0x00db, 0x860f},
1088/* 495 */ {0x0039, 0x8610},
1089/* 496 */ {0x0012, 0x8657},
1090/* 497 */ {0x0064, 0x8619},
1091
1092/* This line starts it all, it is not needed here */
1093/* since it has been build into the driver */
1094/* jfm: don't start now */
1095/* 590 * {0x0030, 0x8112}, */
1096 {}
1097};
1098
1099/*
1100 * Initialization data for Creative Webcam Vista
1101 */
1102static __u16 spca508_vista_init_data[][3] = {
1103 {0x0008, 0x8200}, /* Clear register */
1104 {0x0000, 0x870b}, /* Reset CTL3 */
1105 {0x0020, 0x8112}, /* Video Drop packet enable */
1106 {0x0003, 0x8111}, /* Soft Reset compression, memory, TG & CDSP */
1107 {0x0000, 0x8110}, /* Disable everything */
1108 {0x0000, 0x8114}, /* Software GPIO output data */
1109 {0x0000, 0x8114},
1110
1111 {0x0003, 0x8111},
1112 {0x0000, 0x8111},
1113 {0x0090, 0x8110}, /* Enable: SSI output, External 2X clock output */
1114 {0x0020, 0x8112},
1115 {0x0000, 0x8114},
1116 {0x0001, 0x8114},
1117 {0x0001, 0x8114},
1118 {0x0001, 0x8114},
1119 {0x0003, 0x8114},
1120
1121 {0x000f, 0x8402}, /* Memory bank Address */
1122 {0x0000, 0x8403}, /* Memory bank Address */
1123 {0x00ba, 0x8804}, /* SSI Slave address */
1124 {0x0010, 0x8802}, /* 93.75kHz SSI Clock Two DataByte */
1125
1126 /* READ { 0, 0x0001, 0x8803 } ->
1127 0000: 00 */
1128 /* READ { 0, 0x0001, 0x8802 } ->
1129 0000: 10 */
1130 {0x0010, 0x8802}, /* Will write 2 bytes (DATA1+DATA2) */
1131 {0x0020, 0x8801}, /* Register address for SSI read/write */
1132 {0x0044, 0x8805}, /* DATA2 */
1133 {0x0004, 0x8800}, /* DATA1 -> write triggered */
1134 /* READ { 0, 0x0001, 0x8803 } ->
1135 0000: 00 */
1136
1137 /* READ { 0, 0x0001, 0x8803 } ->
1138 0000: 00 */
1139 /* READ { 0, 0x0001, 0x8802 } ->
1140 0000: 10 */
1141 {0x0010, 0x8802},
1142 {0x0009, 0x8801},
1143 {0x0042, 0x8805},
1144 {0x0001, 0x8800},
1145 /* READ { 0, 0x0001, 0x8803 } ->
1146 0000: 00 */
1147
1148 /* READ { 0, 0x0001, 0x8803 } ->
1149 0000: 00 */
1150 /* READ { 0, 0x0001, 0x8802 } ->
1151 0000: 10 */
1152 {0x0010, 0x8802},
1153 {0x003c, 0x8801},
1154 {0x0001, 0x8805},
1155 {0x0000, 0x8800},
1156 /* READ { 0, 0x0001, 0x8803 } ->
1157 0000: 00 */
1158
1159 /* READ { 0, 0x0001, 0x8803 } ->
1160 0000: 00 */
1161 /* READ { 0, 0x0001, 0x8802 } ->
1162 0000: 10 */
1163 {0x0010, 0x8802},
1164 {0x0001, 0x8801},
1165 {0x000a, 0x8805},
1166 {0x0000, 0x8800},
1167 /* READ { 0, 0x0001, 0x8803 } ->
1168 0000: 00 */
1169
1170 /* READ { 0, 0x0001, 0x8803 } ->
1171 0000: 00 */
1172 /* READ { 0, 0x0001, 0x8802 } ->
1173 0000: 10 */
1174 {0x0010, 0x8802},
1175 {0x0002, 0x8801},
1176 {0x0000, 0x8805},
1177 {0x0000, 0x8800},
1178 /* READ { 0, 0x0001, 0x8803 } ->
1179 0000: 00 */
1180
1181 /* READ { 0, 0x0001, 0x8803 } ->
1182 0000: 00 */
1183 /* READ { 0, 0x0001, 0x8802 } ->
1184 0000: 10 */
1185 {0x0010, 0x8802},
1186 {0x0003, 0x8801},
1187 {0x0027, 0x8805},
1188 {0x0001, 0x8800},
1189 /* READ { 0, 0x0001, 0x8803 } ->
1190 0000: 00 */
1191
1192 /* READ { 0, 0x0001, 0x8803 } ->
1193 0000: 00 */
1194 /* READ { 0, 0x0001, 0x8802 } ->
1195 0000: 10 */
1196 {0x0010, 0x8802},
1197 {0x0004, 0x8801},
1198 {0x0065, 0x8805},
1199 {0x0001, 0x8800},
1200 /* READ { 0, 0x0001, 0x8803 } ->
1201 0000: 00 */
1202
1203 /* READ { 0, 0x0001, 0x8803 } ->
1204 0000: 00 */
1205 /* READ { 0, 0x0001, 0x8802 } ->
1206 0000: 10 */
1207 {0x0010, 0x8802},
1208 {0x0005, 0x8801},
1209 {0x0003, 0x8805},
1210 {0x0000, 0x8800},
1211 /* READ { 0, 0x0001, 0x8803 } ->
1212 0000: 00 */
1213
1214 /* READ { 0, 0x0001, 0x8803 } ->
1215 0000: 00 */
1216 /* READ { 0, 0x0001, 0x8802 } ->
1217 0000: 10 */
1218 {0x0010, 0x8802},
1219 {0x0006, 0x8801},
1220 {0x001c, 0x8805},
1221 {0x0000, 0x8800},
1222 /* READ { 0, 0x0001, 0x8803 } ->
1223 0000: 00 */
1224
1225 /* READ { 0, 0x0001, 0x8803 } ->
1226 0000: 00 */
1227 /* READ { 0, 0x0001, 0x8802 } ->
1228 0000: 10 */
1229 {0x0010, 0x8802},
1230 {0x0007, 0x8801},
1231 {0x002a, 0x8805},
1232 {0x0000, 0x8800},
1233 /* READ { 0, 0x0001, 0x8803 } ->
1234 0000: 00 */
1235
1236 /* READ { 0, 0x0001, 0x8803 } ->
1237 0000: 00 */
1238 /* READ { 0, 0x0001, 0x8802 } ->
1239 0000: 10 */
1240 {0x0010, 0x8802},
1241 {0x000e, 0x8801},
1242 {0x0000, 0x8805},
1243 {0x0000, 0x8800},
1244 /* READ { 0, 0x0001, 0x8803 } ->
1245 0000: 00 */
1246
1247 /* READ { 0, 0x0001, 0x8803 } ->
1248 0000: 00 */
1249 /* READ { 0, 0x0001, 0x8802 } ->
1250 0000: 10 */
1251 {0x0010, 0x8802},
1252 {0x0028, 0x8801},
1253 {0x002e, 0x8805},
1254 {0x0000, 0x8800},
1255 /* READ { 0, 0x0001, 0x8803 } ->
1256 0000: 00 */
1257
1258 /* READ { 0, 0x0001, 0x8803 } ->
1259 0000: 00 */
1260 /* READ { 0, 0x0001, 0x8802 } ->
1261 0000: 10 */
1262 {0x0010, 0x8802},
1263 {0x0039, 0x8801},
1264 {0x0013, 0x8805},
1265 {0x0000, 0x8800},
1266 /* READ { 0, 0x0001, 0x8803 } ->
1267 0000: 00 */
1268
1269 /* READ { 0, 0x0001, 0x8803 } ->
1270 0000: 00 */
1271 /* READ { 0, 0x0001, 0x8802 } ->
1272 0000: 10 */
1273 {0x0010, 0x8802},
1274 {0x003b, 0x8801},
1275 {0x000c, 0x8805},
1276 {0x0000, 0x8800},
1277 /* READ { 0, 0x0001, 0x8803 } ->
1278 0000: 00 */
1279
1280 /* READ { 0, 0x0001, 0x8803 } ->
1281 0000: 00 */
1282 /* READ { 0, 0x0001, 0x8802 } ->
1283 0000: 10 */
1284 {0x0010, 0x8802},
1285 {0x0035, 0x8801},
1286 {0x0028, 0x8805},
1287 {0x0000, 0x8800},
1288 /* READ { 0, 0x0001, 0x8803 } ->
1289 0000: 00 */
1290
1291 /* READ { 0, 0x0001, 0x8803 } ->
1292 0000: 00 */
1293 /* READ { 0, 0x0001, 0x8802 } ->
1294 0000: 10 */
1295 {0x0010, 0x8802},
1296 {0x0009, 0x8801},
1297 {0x0042, 0x8805},
1298 {0x0001, 0x8800},
1299 /* READ { 0, 0x0001, 0x8803 } ->
1300 0000: 00 */
1301
1302 {0x0050, 0x8703},
1303 {0x0002, 0x8704}, /* External input CKIx1 */
1304 {0x0001, 0x870C}, /* Select CKOx2 output */
1305 {0x009A, 0x8600}, /* Line memory Read Counter (L) */
1306 {0x0001, 0x8606}, /* 1 Line memory Read Counter (H) Result: (d)410 */
1307 {0x0023, 0x8601},
1308 {0x0010, 0x8602},
1309 {0x000A, 0x8603},
1310 {0x009A, 0x8600},
1311 {0x0001, 0x865B}, /* 1 Horizontal Offset for Valid Pixel(L) */
1312 {0x0003, 0x865C}, /* Vertical offset for valid lines (L) */
1313 {0x0058, 0x865D}, /* Horizontal valid pixels window (L) */
1314 {0x0048, 0x865E}, /* Vertical valid lines window (L) */
1315 {0x0000, 0x865F},
1316
1317 {0x0006, 0x8660},
1318 /* Enable nibble data input, select nibble input order */
1319
1320 {0x0013, 0x8608}, /* A11 Coeficients for color correction */
1321 {0x0028, 0x8609},
1322 /* Note: these values are confirmed at the end of array */
1323 {0x0005, 0x860A}, /* ... */
1324 {0x0025, 0x860B},
1325 {0x00E1, 0x860C},
1326 {0x00FA, 0x860D},
1327 {0x00F4, 0x860E},
1328 {0x00E8, 0x860F},
1329 {0x0025, 0x8610}, /* A33 Coef. */
1330 {0x00FC, 0x8611}, /* White balance offset: R */
1331 {0x0001, 0x8612}, /* White balance offset: Gr */
1332 {0x00FE, 0x8613}, /* White balance offset: B */
1333 {0x0000, 0x8614}, /* White balance offset: Gb */
1334
1335 {0x0064, 0x8651}, /* R gain for white balance (L) */
1336 {0x0040, 0x8652}, /* Gr gain for white balance (L) */
1337 {0x0066, 0x8653}, /* B gain for white balance (L) */
1338 {0x0040, 0x8654}, /* Gb gain for white balance (L) */
1339 {0x0001, 0x863F}, /* Enable fixed gamma correction */
1340
1341 {0x00A1, 0x8656}, /* Size - Window1: 256x256, Window2: 128x128 */
1342 /* UV division: UV no change, Enable New edge enhancement */
1343 {0x0018, 0x8657}, /* Edge gain high threshold */
1344 {0x0020, 0x8658}, /* Edge gain low threshold */
1345 {0x000A, 0x8659}, /* Edge bandwidth high threshold */
1346 {0x0005, 0x865A}, /* Edge bandwidth low threshold */
1347 {0x0064, 0x8607}, /* UV filter enable */
1348
1349 {0x0016, 0x8660},
1350 {0x0000, 0x86B0}, /* Bad pixels compensation address */
1351 {0x00DC, 0x86B1}, /* X coord for bad pixels compensation (L) */
1352 {0x0000, 0x86B2},
1353 {0x0009, 0x86B3}, /* Y coord for bad pixels compensation (L) */
1354 {0x0000, 0x86B4},
1355
1356 {0x0001, 0x86B0},
1357 {0x00F5, 0x86B1},
1358 {0x0000, 0x86B2},
1359 {0x00C6, 0x86B3},
1360 {0x0000, 0x86B4},
1361
1362 {0x0002, 0x86B0},
1363 {0x001C, 0x86B1},
1364 {0x0001, 0x86B2},
1365 {0x00D7, 0x86B3},
1366 {0x0000, 0x86B4},
1367
1368 {0x0003, 0x86B0},
1369 {0x001C, 0x86B1},
1370 {0x0001, 0x86B2},
1371 {0x00D8, 0x86B3},
1372 {0x0000, 0x86B4},
1373
1374 {0x0004, 0x86B0},
1375 {0x001D, 0x86B1},
1376 {0x0001, 0x86B2},
1377 {0x00D8, 0x86B3},
1378 {0x0000, 0x86B4},
1379 {0x001E, 0x8660},
1380
1381 /* READ { 0, 0x0000, 0x8608 } ->
1382 0000: 13 */
1383 /* READ { 0, 0x0000, 0x8609 } ->
1384 0000: 28 */
1385 /* READ { 0, 0x0000, 0x8610 } ->
1386 0000: 05 */
1387 /* READ { 0, 0x0000, 0x8611 } ->
1388 0000: 25 */
1389 /* READ { 0, 0x0000, 0x8612 } ->
1390 0000: e1 */
1391 /* READ { 0, 0x0000, 0x8613 } ->
1392 0000: fa */
1393 /* READ { 0, 0x0000, 0x8614 } ->
1394 0000: f4 */
1395 /* READ { 0, 0x0000, 0x8615 } ->
1396 0000: e8 */
1397 /* READ { 0, 0x0000, 0x8616 } ->
1398 0000: 25 */
1399 {}
1400};
1401
1402static int reg_write(struct usb_device *dev,
1403 __u16 index, __u16 value)
1404{
1405 int ret;
1406
1407 ret = usb_control_msg(dev,
1408 usb_sndctrlpipe(dev, 0),
1409 0, /* request */
1410 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1411 value, index, NULL, 0, 500);
1412 PDEBUG(D_USBO, "reg write i:0x%04x = 0x%02x",
1413 index, value);
1414 if (ret < 0)
1415 PDEBUG(D_ERR|D_USBO, "reg write: error %d", ret);
1416 return ret;
1417}
1418
1419/* read 1 byte */
1420/* returns: negative is error, pos or zero is data */
1421static int reg_read(struct usb_device *dev,
1422 __u16 index) /* wIndex */
1423{
1424 int ret;
1425 __u8 data;
1426
1427 ret = usb_control_msg(dev,
1428 usb_rcvctrlpipe(dev, 0),
1429 0, /* register */
1430 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1431 (__u16) 0, /* value */
1432 index,
1433 &data, 1,
1434 500); /* timeout */
1435 PDEBUG(D_USBI, "reg read i:%04x --> %02x", index, data);
1436 if (ret < 0) {
1437 PDEBUG(D_ERR|D_USBI, "reg_read err %d", ret);
1438 return ret;
1439 }
1440 return data;
1441}
1442
1443static int write_vector(struct gspca_dev *gspca_dev,
1444 __u16 data[][3])
1445{
1446 struct usb_device *dev = gspca_dev->dev;
1447 int ret, i = 0;
1448
1449 while (data[i][1] != 0) {
1450 ret = reg_write(dev, data[i][1], data[i][0]);
1451 if (ret < 0)
1452 return ret;
1453 i++;
1454 }
1455 return 0;
1456}
1457
1458/* this function is called at probe time */
1459static int sd_config(struct gspca_dev *gspca_dev,
1460 const struct usb_device_id *id)
1461{
1462 struct sd *sd = (struct sd *) gspca_dev;
1463 struct usb_device *dev = gspca_dev->dev;
1464 struct cam *cam;
1465 __u16 vendor;
1466 __u16 product;
1467 int data1, data2;
1468
1469 vendor = id->idVendor;
1470 product = id->idProduct;
1471 switch (vendor) {
1472 case 0x041e: /* Creative cameras */
1473/* switch (product) { */
1474/* case 0x4018: */
1475 sd->subtype = CreativeVista;
1476/* break; */
1477/* } */
1478 break;
1479 case 0x0461: /* MicroInnovation */
1480/* switch (product) { */
1481/* case 0x0815: */
1482 sd->subtype = MicroInnovationIC200;
1483/* break; */
1484/* } */
1485 break;
1486 case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
1487/* switch (product) { */
1488/* case 0x110: */
1489 sd->subtype = ViewQuestVQ110;
1490/* break; */
1491/* } */
1492 break;
1493 case 0x0af9: /* Hama cameras */
1494 switch (product) {
1495 case 0x0010:
1496 sd->subtype = HamaUSBSightcam;
1497 break;
1498 case 0x0011:
1499 sd->subtype = HamaUSBSightcam2;
1500 break;
1501 }
1502 break;
1503 case 0x8086: /* Intel */
1504/* switch (product) { */
1505/* case 0x0110: */
1506 sd->subtype = IntelEasyPCCamera;
1507/* break; */
1508/* } */
1509 break;
1510 }
1511
1512 /* Read from global register the USB product and vendor IDs, just to */
1513 /* prove that we can communicate with the device. This works, which */
1514 /* confirms at we are communicating properly and that the device */
1515 /* is a 508. */
1516 data1 = reg_read(dev, 0x8104);
1517 data2 = reg_read(dev, 0x8105);
1518 PDEBUG(D_PROBE,
1519 "Read from GLOBAL: USB Vendor ID 0x%02x%02x", data2, data1);
1520
1521 data1 = reg_read(dev, 0x8106);
1522 data2 = reg_read(dev, 0x8107);
1523 PDEBUG(D_PROBE,
1524 "Read from GLOBAL: USB Product ID 0x%02x%02x", data2, data1);
1525
1526 data1 = reg_read(dev, 0x8621);
1527 PDEBUG(D_PROBE,
1528 "Read from GLOBAL: Window 1 average luminance %d", data1);
1529
1530 cam = &gspca_dev->cam;
1531 cam->dev_name = (char *) id->driver_info;
1532 cam->epaddr = 0x01;
1533 cam->cam_mode = sif_mode;
1534 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0];
1535 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
1536
1537 switch (sd->subtype) {
1538 case ViewQuestVQ110:
1539 if (write_vector(gspca_dev, spca508_init_data))
1540 return -1;
1541 break;
1542 default:
1543/* case MicroInnovationIC200: */
1544/* case IntelEasyPCCamera: */
1545 if (write_vector(gspca_dev, spca508cs110_init_data))
1546 return -1;
1547 break;
1548 case HamaUSBSightcam:
1549 if (write_vector(gspca_dev, spca508_sightcam_init_data))
1550 return -1;
1551 break;
1552 case HamaUSBSightcam2:
1553 if (write_vector(gspca_dev, spca508_sightcam2_init_data))
1554 return -1;
1555 break;
1556 case CreativeVista:
1557 if (write_vector(gspca_dev, spca508_vista_init_data))
1558 return -1;
1559 break;
1560 }
1561 return 0; /* success */
1562}
1563
1564/* this function is called at open time */
1565static int sd_open(struct gspca_dev *gspca_dev)
1566{
1567/* write_vector(gspca_dev, spca508_open_data); */
1568 return 0;
1569}
1570
1571static void sd_start(struct gspca_dev *gspca_dev)
1572{
1573 int mode;
1574
1575 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode;
1576 reg_write(gspca_dev->dev, 0x8500, mode);
1577 switch (mode) {
1578 case 0:
1579 case 1:
1580 reg_write(gspca_dev->dev, 0x8700, 0x28); /* clock */
1581 break;
1582 default:
1583/* case 2: */
1584/* case 3: */
1585 reg_write(gspca_dev->dev, 0x8700, 0x23); /* clock */
1586 break;
1587 }
1588 reg_write(gspca_dev->dev, 0x8112, 0x10 | 0x20);
1589}
1590
1591static void sd_stopN(struct gspca_dev *gspca_dev)
1592{
1593 /* Video ISO disable, Video Drop Packet enable: */
1594 reg_write(gspca_dev->dev, 0x8112, 0x20);
1595}
1596
1597static void sd_stop0(struct gspca_dev *gspca_dev)
1598{
1599}
1600
1601/* this function is called at close time */
1602static void sd_close(struct gspca_dev *gspca_dev)
1603{
1604}
1605
1606/* convert YUVY per line to YUYV (YUV 4:2:2) */
1607static void yuvy_decode(unsigned char *out,
1608 unsigned char *in,
1609 int width,
1610 int height)
1611{
1612 unsigned char *Ui, *Vi, *yi, *yi1;
1613 unsigned char *out1;
1614 int i, j;
1615
1616 yi = in;
1617 for (i = height / 2; --i >= 0; ) {
1618 out1 = out + width * 2; /* next line */
1619 Ui = yi + width;
1620 Vi = Ui + width / 2;
1621 yi1 = Vi + width / 2;
1622 for (j = width / 2; --j >= 0; ) {
1623 *out++ = 128 + *yi++;
1624 *out++ = 128 + *Ui;
1625 *out++ = 128 + *yi++;
1626 *out++ = 128 + *Vi;
1627
1628 *out1++ = 128 + *yi1++;
1629 *out1++ = 128 + *Ui++;
1630 *out1++ = 128 + *yi1++;
1631 *out1++ = 128 + *Vi++;
1632 }
1633 yi += width * 2;
1634 out = out1;
1635 }
1636}
1637
1638static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1639 struct gspca_frame *frame, /* target */
1640 unsigned char *data, /* isoc packet */
1641 int len) /* iso packet length */
1642{
1643 struct sd *sd = (struct sd *) gspca_dev;
1644
1645 switch (data[0]) {
1646 case 0: /* start of frame */
1647 if (gspca_dev->last_packet_type == FIRST_PACKET) {
1648 yuvy_decode(sd->tmpbuf2, sd->tmpbuf,
1649 gspca_dev->width,
1650 gspca_dev->height);
1651 frame = gspca_frame_add(gspca_dev,
1652 LAST_PACKET,
1653 frame,
1654 sd->tmpbuf2,
1655 gspca_dev->width
1656 * gspca_dev->height
1657 * 2);
1658 }
1659 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1660 data, 0);
1661 data += SPCA508_OFFSET_DATA;
1662 len -= SPCA508_OFFSET_DATA;
1663 if (len > 0)
1664 memcpy(sd->tmpbuf, data, len);
1665 else
1666 len = 0;
1667 sd->buflen = len;
1668 return;
1669 case 0xff: /* drop */
1670/* gspca_dev->last_packet_type = DISCARD_PACKET; */
1671 return;
1672 }
1673 data += 1;
1674 len -= 1;
1675 memcpy(&sd->tmpbuf[sd->buflen], data, len);
1676 sd->buflen += len;
1677}
1678
1679static void setbrightness(struct gspca_dev *gspca_dev)
1680{
1681 struct sd *sd = (struct sd *) gspca_dev;
1682 __u8 brightness = sd->brightness;
1683
1684/* MX seem contrast */
1685 reg_write(gspca_dev->dev, 0x8651, brightness);
1686 reg_write(gspca_dev->dev, 0x8652, brightness);
1687 reg_write(gspca_dev->dev, 0x8653, brightness);
1688 reg_write(gspca_dev->dev, 0x8654, brightness);
1689}
1690
1691static void getbrightness(struct gspca_dev *gspca_dev)
1692{
1693 struct sd *sd = (struct sd *) gspca_dev;
1694
1695 sd->brightness = reg_read(gspca_dev->dev, 0x8651);
1696}
1697
1698static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1699{
1700 struct sd *sd = (struct sd *) gspca_dev;
1701
1702 sd->brightness = val;
1703 if (gspca_dev->streaming)
1704 setbrightness(gspca_dev);
1705 return 0;
1706}
1707
1708static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
1709{
1710 struct sd *sd = (struct sd *) gspca_dev;
1711
1712 getbrightness(gspca_dev);
1713 *val = sd->brightness;
1714 return 0;
1715}
1716
1717/* sub-driver description */
1718static struct sd_desc sd_desc = {
1719 .name = MODULE_NAME,
1720 .ctrls = sd_ctrls,
1721 .nctrls = ARRAY_SIZE(sd_ctrls),
1722 .config = sd_config,
1723 .open = sd_open,
1724 .start = sd_start,
1725 .stopN = sd_stopN,
1726 .stop0 = sd_stop0,
1727 .close = sd_close,
1728 .pkt_scan = sd_pkt_scan,
1729};
1730
1731/* -- module initialisation -- */
1732#define DVNM(name) .driver_info = (kernel_ulong_t) name
1733static __devinitdata struct usb_device_id device_table[] = {
1734 {USB_DEVICE(0x041e, 0x4018), DVNM("Creative Webcam Vista (PD1100)")},
1735 {USB_DEVICE(0x0461, 0x0815), DVNM("Micro Innovation IC200")},
1736 {USB_DEVICE(0x0733, 0x0110), DVNM("ViewQuest VQ110")},
1737 {USB_DEVICE(0x0af9, 0x0010), DVNM("Hama USB Sightcam 100")},
1738 {USB_DEVICE(0x0af9, 0x0011), DVNM("Hama USB Sightcam 100")},
1739 {USB_DEVICE(0x8086, 0x0110), DVNM("Intel Easy PC Camera")},
1740 {}
1741};
1742MODULE_DEVICE_TABLE(usb, device_table);
1743
1744/* -- device connect -- */
1745static int sd_probe(struct usb_interface *intf,
1746 const struct usb_device_id *id)
1747{
1748 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
1749 THIS_MODULE);
1750}
1751
1752static struct usb_driver sd_driver = {
1753 .name = MODULE_NAME,
1754 .id_table = device_table,
1755 .probe = sd_probe,
1756 .disconnect = gspca_disconnect,
1757};
1758
1759/* -- module insert / remove -- */
1760static int __init sd_mod_init(void)
1761{
1762 if (usb_register(&sd_driver) < 0)
1763 return -1;
1764 PDEBUG(D_PROBE, "v%s registered", version);
1765 return 0;
1766}
1767static void __exit sd_mod_exit(void)
1768{
1769 usb_deregister(&sd_driver);
1770 PDEBUG(D_PROBE, "deregistered");
1771}
1772
1773module_init(sd_mod_init);
1774module_exit(sd_mod_exit);