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