blob: 169238d40c9714ce33d130a0edbe300741b45c40 [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
Jean-Francois Moinec2446b32008-07-05 11:49:20 -030025#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5)
26static const char version[] = "2.1.5";
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030027
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
Jean-Francois Moinec2446b32008-07-05 11:49:20 -030072static 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},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030093};
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 */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300111static const __u16 spca508_init_data[][3] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300112#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 {0, 0}
597};
598
599
600/*
601 * Initialization data for Intel EasyPC Camera CS110
602 */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300603static const __u16 spca508cs110_init_data[][3] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300604 {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
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300687static const __u16 spca508_sightcam_init_data[][3] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300688/* 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 {0, 0}
769};
770
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300771static const __u16 spca508_sightcam2_init_data[][3] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300772/* 35 */ {0x0020, 0x8112},
773
774/* 36 */ {0x000f, 0x8402},
775/* 37 */ {0x0000, 0x8403},
776
777/* 38 */ {0x0008, 0x8201},
778/* 39 */ {0x0008, 0x8200},
779/* 40 */ {0x0001, 0x8200},
780/* 43 */ {0x0009, 0x8201},
781/* 44 */ {0x0008, 0x8200},
782/* 45 */ {0x0001, 0x8200},
783/* 48 */ {0x000a, 0x8201},
784/* 49 */ {0x0008, 0x8200},
785/* 50 */ {0x0001, 0x8200},
786/* 53 */ {0x000b, 0x8201},
787/* 54 */ {0x0008, 0x8200},
788/* 55 */ {0x0001, 0x8200},
789/* 58 */ {0x000c, 0x8201},
790/* 59 */ {0x0008, 0x8200},
791/* 60 */ {0x0001, 0x8200},
792/* 63 */ {0x000d, 0x8201},
793/* 64 */ {0x0008, 0x8200},
794/* 65 */ {0x0001, 0x8200},
795/* 68 */ {0x000e, 0x8201},
796/* 69 */ {0x0008, 0x8200},
797/* 70 */ {0x0001, 0x8200},
798/* 73 */ {0x0007, 0x8201},
799/* 74 */ {0x0008, 0x8200},
800/* 75 */ {0x0001, 0x8200},
801/* 78 */ {0x000f, 0x8201},
802/* 79 */ {0x0008, 0x8200},
803/* 80 */ {0x0001, 0x8200},
804
805/* 84 */ {0x0018, 0x8660},
806/* 85 */ {0x0010, 0x8201},
807
808/* 86 */ {0x0008, 0x8200},
809/* 87 */ {0x0001, 0x8200},
810/* 90 */ {0x0011, 0x8201},
811/* 91 */ {0x0008, 0x8200},
812/* 92 */ {0x0001, 0x8200},
813
814/* 95 */ {0x0000, 0x86b0},
815/* 96 */ {0x0034, 0x86b1},
816/* 97 */ {0x0000, 0x86b2},
817/* 98 */ {0x0049, 0x86b3},
818/* 99 */ {0x0000, 0x86b4},
819/* 100 */ {0x0000, 0x86b4},
820
821/* 101 */ {0x0012, 0x8201},
822/* 102 */ {0x0008, 0x8200},
823/* 103 */ {0x0001, 0x8200},
824/* 106 */ {0x0013, 0x8201},
825/* 107 */ {0x0008, 0x8200},
826/* 108 */ {0x0001, 0x8200},
827
828/* 111 */ {0x0001, 0x86b0},
829/* 112 */ {0x00aa, 0x86b1},
830/* 113 */ {0x0000, 0x86b2},
831/* 114 */ {0x00e4, 0x86b3},
832/* 115 */ {0x0000, 0x86b4},
833/* 116 */ {0x0000, 0x86b4},
834
835/* 118 */ {0x0018, 0x8660},
836
837/* 119 */ {0x0090, 0x8110},
838/* 120 */ {0x0001, 0x8114},
839/* 121 */ {0x0001, 0x8114},
840/* 122 */ {0x0001, 0x8114},
841/* 123 */ {0x0003, 0x8114},
842
843/* 124 */ {0x0080, 0x8804},
844/* 157 */ {0x0003, 0x8801},
845/* 158 */ {0x0012, 0x8800},
846/* 160 */ {0x0004, 0x8801},
847/* 161 */ {0x0005, 0x8800},
848/* 163 */ {0x0005, 0x8801},
849/* 164 */ {0x0000, 0x8800},
850/* 166 */ {0x0006, 0x8801},
851/* 167 */ {0x0000, 0x8800},
852/* 169 */ {0x0007, 0x8801},
853/* 170 */ {0x0000, 0x8800},
854/* 172 */ {0x0008, 0x8801},
855/* 173 */ {0x0005, 0x8800},
856/* 175 */ {0x000a, 0x8700},
857/* 176 */ {0x000e, 0x8801},
858/* 177 */ {0x0004, 0x8800},
859/* 179 */ {0x0005, 0x8801},
860/* 180 */ {0x0047, 0x8800},
861/* 182 */ {0x0006, 0x8801},
862/* 183 */ {0x0000, 0x8800},
863/* 185 */ {0x0007, 0x8801},
864/* 186 */ {0x00c0, 0x8800},
865/* 188 */ {0x0008, 0x8801},
866/* 189 */ {0x0003, 0x8800},
867/* 191 */ {0x0013, 0x8801},
868/* 192 */ {0x0001, 0x8800},
869/* 194 */ {0x0009, 0x8801},
870/* 195 */ {0x0000, 0x8800},
871/* 197 */ {0x000a, 0x8801},
872/* 198 */ {0x0000, 0x8800},
873/* 200 */ {0x000b, 0x8801},
874/* 201 */ {0x0000, 0x8800},
875/* 203 */ {0x000c, 0x8801},
876/* 204 */ {0x0000, 0x8800},
877/* 206 */ {0x000e, 0x8801},
878/* 207 */ {0x0004, 0x8800},
879/* 209 */ {0x000f, 0x8801},
880/* 210 */ {0x0000, 0x8800},
881/* 212 */ {0x0010, 0x8801},
882/* 213 */ {0x0006, 0x8800},
883/* 215 */ {0x0011, 0x8801},
884/* 216 */ {0x0006, 0x8800},
885/* 218 */ {0x0012, 0x8801},
886/* 219 */ {0x0000, 0x8800},
887/* 221 */ {0x0013, 0x8801},
888/* 222 */ {0x0001, 0x8800},
889
890/* 224 */ {0x000a, 0x8700},
891/* 225 */ {0x0000, 0x8702},
892/* 226 */ {0x0000, 0x8703},
893/* 227 */ {0x00c2, 0x8704},
894/* 228 */ {0x0001, 0x870c},
895
896/* 229 */ {0x0044, 0x8600},
897/* 230 */ {0x0002, 0x8606},
898/* 231 */ {0x0064, 0x8607},
899/* 232 */ {0x003a, 0x8601},
900/* 233 */ {0x0008, 0x8602},
901/* 234 */ {0x0044, 0x8600},
902/* 235 */ {0x0018, 0x8617},
903/* 236 */ {0x0008, 0x8618},
904/* 237 */ {0x00a1, 0x8656},
905/* 238 */ {0x0004, 0x865b},
906/* 239 */ {0x0002, 0x865c},
907/* 240 */ {0x0058, 0x865d},
908/* 241 */ {0x0048, 0x865e},
909/* 242 */ {0x0012, 0x8608},
910/* 243 */ {0x002c, 0x8609},
911/* 244 */ {0x0002, 0x860a},
912/* 245 */ {0x002c, 0x860b},
913/* 246 */ {0x00db, 0x860c},
914/* 247 */ {0x00f9, 0x860d},
915/* 248 */ {0x00f1, 0x860e},
916/* 249 */ {0x00e3, 0x860f},
917/* 250 */ {0x002c, 0x8610},
918/* 251 */ {0x006c, 0x8651},
919/* 252 */ {0x0041, 0x8652},
920/* 253 */ {0x0059, 0x8653},
921/* 254 */ {0x0040, 0x8654},
922/* 255 */ {0x00fa, 0x8611},
923/* 256 */ {0x00ff, 0x8612},
924/* 257 */ {0x00f8, 0x8613},
925/* 258 */ {0x0000, 0x8614},
926/* 259 */ {0x0001, 0x863f},
927/* 260 */ {0x0000, 0x8640},
928/* 261 */ {0x0026, 0x8641},
929/* 262 */ {0x0045, 0x8642},
930/* 263 */ {0x0060, 0x8643},
931/* 264 */ {0x0075, 0x8644},
932/* 265 */ {0x0088, 0x8645},
933/* 266 */ {0x009b, 0x8646},
934/* 267 */ {0x00b0, 0x8647},
935/* 268 */ {0x00c5, 0x8648},
936/* 269 */ {0x00d2, 0x8649},
937/* 270 */ {0x00dc, 0x864a},
938/* 271 */ {0x00e5, 0x864b},
939/* 272 */ {0x00eb, 0x864c},
940/* 273 */ {0x00f0, 0x864d},
941/* 274 */ {0x00f6, 0x864e},
942/* 275 */ {0x00fa, 0x864f},
943/* 276 */ {0x00ff, 0x8650},
944/* 277 */ {0x0060, 0x8657},
945/* 278 */ {0x0010, 0x8658},
946/* 279 */ {0x0018, 0x8659},
947/* 280 */ {0x0005, 0x865a},
948/* 281 */ {0x0018, 0x8660},
949/* 282 */ {0x0003, 0x8509},
950/* 283 */ {0x0011, 0x850a},
951/* 284 */ {0x0032, 0x850b},
952/* 285 */ {0x0010, 0x850c},
953/* 286 */ {0x0021, 0x850d},
954/* 287 */ {0x0001, 0x8500},
955/* 288 */ {0x0000, 0x8508},
956/* 289 */ {0x0012, 0x8608},
957/* 290 */ {0x002c, 0x8609},
958/* 291 */ {0x0002, 0x860a},
959/* 292 */ {0x0039, 0x860b},
960/* 293 */ {0x00d0, 0x860c},
961/* 294 */ {0x00f7, 0x860d},
962/* 295 */ {0x00ed, 0x860e},
963/* 296 */ {0x00db, 0x860f},
964/* 297 */ {0x0039, 0x8610},
965/* 298 */ {0x0012, 0x8657},
966/* 299 */ {0x000c, 0x8619},
967/* 300 */ {0x0004, 0x861a},
968/* 301 */ {0x00a1, 0x8656},
969/* 302 */ {0x00c8, 0x8615},
970/* 303 */ {0x0032, 0x8616},
971
972/* 306 */ {0x0030, 0x8112},
973/* 313 */ {0x0020, 0x8112},
974/* 314 */ {0x0020, 0x8112},
975/* 315 */ {0x000f, 0x8402},
976/* 316 */ {0x0000, 0x8403},
977
978/* 317 */ {0x0090, 0x8110},
979/* 318 */ {0x0001, 0x8114},
980/* 319 */ {0x0001, 0x8114},
981/* 320 */ {0x0001, 0x8114},
982/* 321 */ {0x0003, 0x8114},
983/* 322 */ {0x0080, 0x8804},
984
985/* 355 */ {0x0003, 0x8801},
986/* 356 */ {0x0012, 0x8800},
987/* 358 */ {0x0004, 0x8801},
988/* 359 */ {0x0005, 0x8800},
989/* 361 */ {0x0005, 0x8801},
990/* 362 */ {0x0047, 0x8800},
991/* 364 */ {0x0006, 0x8801},
992/* 365 */ {0x0000, 0x8800},
993/* 367 */ {0x0007, 0x8801},
994/* 368 */ {0x00c0, 0x8800},
995/* 370 */ {0x0008, 0x8801},
996/* 371 */ {0x0003, 0x8800},
997/* 373 */ {0x000a, 0x8700},
998/* 374 */ {0x000e, 0x8801},
999/* 375 */ {0x0004, 0x8800},
1000/* 377 */ {0x0005, 0x8801},
1001/* 378 */ {0x0047, 0x8800},
1002/* 380 */ {0x0006, 0x8801},
1003/* 381 */ {0x0000, 0x8800},
1004/* 383 */ {0x0007, 0x8801},
1005/* 384 */ {0x00c0, 0x8800},
1006/* 386 */ {0x0008, 0x8801},
1007/* 387 */ {0x0003, 0x8800},
1008/* 389 */ {0x0013, 0x8801},
1009/* 390 */ {0x0001, 0x8800},
1010/* 392 */ {0x0009, 0x8801},
1011/* 393 */ {0x0000, 0x8800},
1012/* 395 */ {0x000a, 0x8801},
1013/* 396 */ {0x0000, 0x8800},
1014/* 398 */ {0x000b, 0x8801},
1015/* 399 */ {0x0000, 0x8800},
1016/* 401 */ {0x000c, 0x8801},
1017/* 402 */ {0x0000, 0x8800},
1018/* 404 */ {0x000e, 0x8801},
1019/* 405 */ {0x0004, 0x8800},
1020/* 407 */ {0x000f, 0x8801},
1021/* 408 */ {0x0000, 0x8800},
1022/* 410 */ {0x0010, 0x8801},
1023/* 411 */ {0x0006, 0x8800},
1024/* 413 */ {0x0011, 0x8801},
1025/* 414 */ {0x0006, 0x8800},
1026/* 416 */ {0x0012, 0x8801},
1027/* 417 */ {0x0000, 0x8800},
1028/* 419 */ {0x0013, 0x8801},
1029/* 420 */ {0x0001, 0x8800},
1030/* 422 */ {0x000a, 0x8700},
1031/* 423 */ {0x0000, 0x8702},
1032/* 424 */ {0x0000, 0x8703},
1033/* 425 */ {0x00c2, 0x8704},
1034/* 426 */ {0x0001, 0x870c},
1035/* 427 */ {0x0044, 0x8600},
1036/* 428 */ {0x0002, 0x8606},
1037/* 429 */ {0x0064, 0x8607},
1038/* 430 */ {0x003a, 0x8601},
1039/* 431 */ {0x0008, 0x8602},
1040/* 432 */ {0x0044, 0x8600},
1041/* 433 */ {0x0018, 0x8617},
1042/* 434 */ {0x0008, 0x8618},
1043/* 435 */ {0x00a1, 0x8656},
1044/* 436 */ {0x0004, 0x865b},
1045/* 437 */ {0x0002, 0x865c},
1046/* 438 */ {0x0058, 0x865d},
1047/* 439 */ {0x0048, 0x865e},
1048/* 440 */ {0x0012, 0x8608},
1049/* 441 */ {0x002c, 0x8609},
1050/* 442 */ {0x0002, 0x860a},
1051/* 443 */ {0x002c, 0x860b},
1052/* 444 */ {0x00db, 0x860c},
1053/* 445 */ {0x00f9, 0x860d},
1054/* 446 */ {0x00f1, 0x860e},
1055/* 447 */ {0x00e3, 0x860f},
1056/* 448 */ {0x002c, 0x8610},
1057/* 449 */ {0x006c, 0x8651},
1058/* 450 */ {0x0041, 0x8652},
1059/* 451 */ {0x0059, 0x8653},
1060/* 452 */ {0x0040, 0x8654},
1061/* 453 */ {0x00fa, 0x8611},
1062/* 454 */ {0x00ff, 0x8612},
1063/* 455 */ {0x00f8, 0x8613},
1064/* 456 */ {0x0000, 0x8614},
1065/* 457 */ {0x0001, 0x863f},
1066/* 458 */ {0x0000, 0x8640},
1067/* 459 */ {0x0026, 0x8641},
1068/* 460 */ {0x0045, 0x8642},
1069/* 461 */ {0x0060, 0x8643},
1070/* 462 */ {0x0075, 0x8644},
1071/* 463 */ {0x0088, 0x8645},
1072/* 464 */ {0x009b, 0x8646},
1073/* 465 */ {0x00b0, 0x8647},
1074/* 466 */ {0x00c5, 0x8648},
1075/* 467 */ {0x00d2, 0x8649},
1076/* 468 */ {0x00dc, 0x864a},
1077/* 469 */ {0x00e5, 0x864b},
1078/* 470 */ {0x00eb, 0x864c},
1079/* 471 */ {0x00f0, 0x864d},
1080/* 472 */ {0x00f6, 0x864e},
1081/* 473 */ {0x00fa, 0x864f},
1082/* 474 */ {0x00ff, 0x8650},
1083/* 475 */ {0x0060, 0x8657},
1084/* 476 */ {0x0010, 0x8658},
1085/* 477 */ {0x0018, 0x8659},
1086/* 478 */ {0x0005, 0x865a},
1087/* 479 */ {0x0018, 0x8660},
1088/* 480 */ {0x0003, 0x8509},
1089/* 481 */ {0x0011, 0x850a},
1090/* 482 */ {0x0032, 0x850b},
1091/* 483 */ {0x0010, 0x850c},
1092/* 484 */ {0x0021, 0x850d},
1093/* 485 */ {0x0001, 0x8500},
1094/* 486 */ {0x0000, 0x8508},
1095
1096/* 487 */ {0x0012, 0x8608},
1097/* 488 */ {0x002c, 0x8609},
1098/* 489 */ {0x0002, 0x860a},
1099/* 490 */ {0x0039, 0x860b},
1100/* 491 */ {0x00d0, 0x860c},
1101/* 492 */ {0x00f7, 0x860d},
1102/* 493 */ {0x00ed, 0x860e},
1103/* 494 */ {0x00db, 0x860f},
1104/* 495 */ {0x0039, 0x8610},
1105/* 496 */ {0x0012, 0x8657},
1106/* 497 */ {0x0064, 0x8619},
1107
1108/* This line starts it all, it is not needed here */
1109/* since it has been build into the driver */
1110/* jfm: don't start now */
1111/* 590 * {0x0030, 0x8112}, */
1112 {}
1113};
1114
1115/*
1116 * Initialization data for Creative Webcam Vista
1117 */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001118static const __u16 spca508_vista_init_data[][3] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001119 {0x0008, 0x8200}, /* Clear register */
1120 {0x0000, 0x870b}, /* Reset CTL3 */
1121 {0x0020, 0x8112}, /* Video Drop packet enable */
1122 {0x0003, 0x8111}, /* Soft Reset compression, memory, TG & CDSP */
1123 {0x0000, 0x8110}, /* Disable everything */
1124 {0x0000, 0x8114}, /* Software GPIO output data */
1125 {0x0000, 0x8114},
1126
1127 {0x0003, 0x8111},
1128 {0x0000, 0x8111},
1129 {0x0090, 0x8110}, /* Enable: SSI output, External 2X clock output */
1130 {0x0020, 0x8112},
1131 {0x0000, 0x8114},
1132 {0x0001, 0x8114},
1133 {0x0001, 0x8114},
1134 {0x0001, 0x8114},
1135 {0x0003, 0x8114},
1136
1137 {0x000f, 0x8402}, /* Memory bank Address */
1138 {0x0000, 0x8403}, /* Memory bank Address */
1139 {0x00ba, 0x8804}, /* SSI Slave address */
1140 {0x0010, 0x8802}, /* 93.75kHz SSI Clock Two DataByte */
1141
1142 /* READ { 0, 0x0001, 0x8803 } ->
1143 0000: 00 */
1144 /* READ { 0, 0x0001, 0x8802 } ->
1145 0000: 10 */
1146 {0x0010, 0x8802}, /* Will write 2 bytes (DATA1+DATA2) */
1147 {0x0020, 0x8801}, /* Register address for SSI read/write */
1148 {0x0044, 0x8805}, /* DATA2 */
1149 {0x0004, 0x8800}, /* DATA1 -> write triggered */
1150 /* READ { 0, 0x0001, 0x8803 } ->
1151 0000: 00 */
1152
1153 /* READ { 0, 0x0001, 0x8803 } ->
1154 0000: 00 */
1155 /* READ { 0, 0x0001, 0x8802 } ->
1156 0000: 10 */
1157 {0x0010, 0x8802},
1158 {0x0009, 0x8801},
1159 {0x0042, 0x8805},
1160 {0x0001, 0x8800},
1161 /* READ { 0, 0x0001, 0x8803 } ->
1162 0000: 00 */
1163
1164 /* READ { 0, 0x0001, 0x8803 } ->
1165 0000: 00 */
1166 /* READ { 0, 0x0001, 0x8802 } ->
1167 0000: 10 */
1168 {0x0010, 0x8802},
1169 {0x003c, 0x8801},
1170 {0x0001, 0x8805},
1171 {0x0000, 0x8800},
1172 /* READ { 0, 0x0001, 0x8803 } ->
1173 0000: 00 */
1174
1175 /* READ { 0, 0x0001, 0x8803 } ->
1176 0000: 00 */
1177 /* READ { 0, 0x0001, 0x8802 } ->
1178 0000: 10 */
1179 {0x0010, 0x8802},
1180 {0x0001, 0x8801},
1181 {0x000a, 0x8805},
1182 {0x0000, 0x8800},
1183 /* READ { 0, 0x0001, 0x8803 } ->
1184 0000: 00 */
1185
1186 /* READ { 0, 0x0001, 0x8803 } ->
1187 0000: 00 */
1188 /* READ { 0, 0x0001, 0x8802 } ->
1189 0000: 10 */
1190 {0x0010, 0x8802},
1191 {0x0002, 0x8801},
1192 {0x0000, 0x8805},
1193 {0x0000, 0x8800},
1194 /* READ { 0, 0x0001, 0x8803 } ->
1195 0000: 00 */
1196
1197 /* READ { 0, 0x0001, 0x8803 } ->
1198 0000: 00 */
1199 /* READ { 0, 0x0001, 0x8802 } ->
1200 0000: 10 */
1201 {0x0010, 0x8802},
1202 {0x0003, 0x8801},
1203 {0x0027, 0x8805},
1204 {0x0001, 0x8800},
1205 /* READ { 0, 0x0001, 0x8803 } ->
1206 0000: 00 */
1207
1208 /* READ { 0, 0x0001, 0x8803 } ->
1209 0000: 00 */
1210 /* READ { 0, 0x0001, 0x8802 } ->
1211 0000: 10 */
1212 {0x0010, 0x8802},
1213 {0x0004, 0x8801},
1214 {0x0065, 0x8805},
1215 {0x0001, 0x8800},
1216 /* READ { 0, 0x0001, 0x8803 } ->
1217 0000: 00 */
1218
1219 /* READ { 0, 0x0001, 0x8803 } ->
1220 0000: 00 */
1221 /* READ { 0, 0x0001, 0x8802 } ->
1222 0000: 10 */
1223 {0x0010, 0x8802},
1224 {0x0005, 0x8801},
1225 {0x0003, 0x8805},
1226 {0x0000, 0x8800},
1227 /* READ { 0, 0x0001, 0x8803 } ->
1228 0000: 00 */
1229
1230 /* READ { 0, 0x0001, 0x8803 } ->
1231 0000: 00 */
1232 /* READ { 0, 0x0001, 0x8802 } ->
1233 0000: 10 */
1234 {0x0010, 0x8802},
1235 {0x0006, 0x8801},
1236 {0x001c, 0x8805},
1237 {0x0000, 0x8800},
1238 /* READ { 0, 0x0001, 0x8803 } ->
1239 0000: 00 */
1240
1241 /* READ { 0, 0x0001, 0x8803 } ->
1242 0000: 00 */
1243 /* READ { 0, 0x0001, 0x8802 } ->
1244 0000: 10 */
1245 {0x0010, 0x8802},
1246 {0x0007, 0x8801},
1247 {0x002a, 0x8805},
1248 {0x0000, 0x8800},
1249 /* READ { 0, 0x0001, 0x8803 } ->
1250 0000: 00 */
1251
1252 /* READ { 0, 0x0001, 0x8803 } ->
1253 0000: 00 */
1254 /* READ { 0, 0x0001, 0x8802 } ->
1255 0000: 10 */
1256 {0x0010, 0x8802},
1257 {0x000e, 0x8801},
1258 {0x0000, 0x8805},
1259 {0x0000, 0x8800},
1260 /* READ { 0, 0x0001, 0x8803 } ->
1261 0000: 00 */
1262
1263 /* READ { 0, 0x0001, 0x8803 } ->
1264 0000: 00 */
1265 /* READ { 0, 0x0001, 0x8802 } ->
1266 0000: 10 */
1267 {0x0010, 0x8802},
1268 {0x0028, 0x8801},
1269 {0x002e, 0x8805},
1270 {0x0000, 0x8800},
1271 /* READ { 0, 0x0001, 0x8803 } ->
1272 0000: 00 */
1273
1274 /* READ { 0, 0x0001, 0x8803 } ->
1275 0000: 00 */
1276 /* READ { 0, 0x0001, 0x8802 } ->
1277 0000: 10 */
1278 {0x0010, 0x8802},
1279 {0x0039, 0x8801},
1280 {0x0013, 0x8805},
1281 {0x0000, 0x8800},
1282 /* READ { 0, 0x0001, 0x8803 } ->
1283 0000: 00 */
1284
1285 /* READ { 0, 0x0001, 0x8803 } ->
1286 0000: 00 */
1287 /* READ { 0, 0x0001, 0x8802 } ->
1288 0000: 10 */
1289 {0x0010, 0x8802},
1290 {0x003b, 0x8801},
1291 {0x000c, 0x8805},
1292 {0x0000, 0x8800},
1293 /* READ { 0, 0x0001, 0x8803 } ->
1294 0000: 00 */
1295
1296 /* READ { 0, 0x0001, 0x8803 } ->
1297 0000: 00 */
1298 /* READ { 0, 0x0001, 0x8802 } ->
1299 0000: 10 */
1300 {0x0010, 0x8802},
1301 {0x0035, 0x8801},
1302 {0x0028, 0x8805},
1303 {0x0000, 0x8800},
1304 /* READ { 0, 0x0001, 0x8803 } ->
1305 0000: 00 */
1306
1307 /* READ { 0, 0x0001, 0x8803 } ->
1308 0000: 00 */
1309 /* READ { 0, 0x0001, 0x8802 } ->
1310 0000: 10 */
1311 {0x0010, 0x8802},
1312 {0x0009, 0x8801},
1313 {0x0042, 0x8805},
1314 {0x0001, 0x8800},
1315 /* READ { 0, 0x0001, 0x8803 } ->
1316 0000: 00 */
1317
1318 {0x0050, 0x8703},
1319 {0x0002, 0x8704}, /* External input CKIx1 */
1320 {0x0001, 0x870C}, /* Select CKOx2 output */
1321 {0x009A, 0x8600}, /* Line memory Read Counter (L) */
1322 {0x0001, 0x8606}, /* 1 Line memory Read Counter (H) Result: (d)410 */
1323 {0x0023, 0x8601},
1324 {0x0010, 0x8602},
1325 {0x000A, 0x8603},
1326 {0x009A, 0x8600},
1327 {0x0001, 0x865B}, /* 1 Horizontal Offset for Valid Pixel(L) */
1328 {0x0003, 0x865C}, /* Vertical offset for valid lines (L) */
1329 {0x0058, 0x865D}, /* Horizontal valid pixels window (L) */
1330 {0x0048, 0x865E}, /* Vertical valid lines window (L) */
1331 {0x0000, 0x865F},
1332
1333 {0x0006, 0x8660},
1334 /* Enable nibble data input, select nibble input order */
1335
1336 {0x0013, 0x8608}, /* A11 Coeficients for color correction */
1337 {0x0028, 0x8609},
1338 /* Note: these values are confirmed at the end of array */
1339 {0x0005, 0x860A}, /* ... */
1340 {0x0025, 0x860B},
1341 {0x00E1, 0x860C},
1342 {0x00FA, 0x860D},
1343 {0x00F4, 0x860E},
1344 {0x00E8, 0x860F},
1345 {0x0025, 0x8610}, /* A33 Coef. */
1346 {0x00FC, 0x8611}, /* White balance offset: R */
1347 {0x0001, 0x8612}, /* White balance offset: Gr */
1348 {0x00FE, 0x8613}, /* White balance offset: B */
1349 {0x0000, 0x8614}, /* White balance offset: Gb */
1350
1351 {0x0064, 0x8651}, /* R gain for white balance (L) */
1352 {0x0040, 0x8652}, /* Gr gain for white balance (L) */
1353 {0x0066, 0x8653}, /* B gain for white balance (L) */
1354 {0x0040, 0x8654}, /* Gb gain for white balance (L) */
1355 {0x0001, 0x863F}, /* Enable fixed gamma correction */
1356
1357 {0x00A1, 0x8656}, /* Size - Window1: 256x256, Window2: 128x128 */
1358 /* UV division: UV no change, Enable New edge enhancement */
1359 {0x0018, 0x8657}, /* Edge gain high threshold */
1360 {0x0020, 0x8658}, /* Edge gain low threshold */
1361 {0x000A, 0x8659}, /* Edge bandwidth high threshold */
1362 {0x0005, 0x865A}, /* Edge bandwidth low threshold */
1363 {0x0064, 0x8607}, /* UV filter enable */
1364
1365 {0x0016, 0x8660},
1366 {0x0000, 0x86B0}, /* Bad pixels compensation address */
1367 {0x00DC, 0x86B1}, /* X coord for bad pixels compensation (L) */
1368 {0x0000, 0x86B2},
1369 {0x0009, 0x86B3}, /* Y coord for bad pixels compensation (L) */
1370 {0x0000, 0x86B4},
1371
1372 {0x0001, 0x86B0},
1373 {0x00F5, 0x86B1},
1374 {0x0000, 0x86B2},
1375 {0x00C6, 0x86B3},
1376 {0x0000, 0x86B4},
1377
1378 {0x0002, 0x86B0},
1379 {0x001C, 0x86B1},
1380 {0x0001, 0x86B2},
1381 {0x00D7, 0x86B3},
1382 {0x0000, 0x86B4},
1383
1384 {0x0003, 0x86B0},
1385 {0x001C, 0x86B1},
1386 {0x0001, 0x86B2},
1387 {0x00D8, 0x86B3},
1388 {0x0000, 0x86B4},
1389
1390 {0x0004, 0x86B0},
1391 {0x001D, 0x86B1},
1392 {0x0001, 0x86B2},
1393 {0x00D8, 0x86B3},
1394 {0x0000, 0x86B4},
1395 {0x001E, 0x8660},
1396
1397 /* READ { 0, 0x0000, 0x8608 } ->
1398 0000: 13 */
1399 /* READ { 0, 0x0000, 0x8609 } ->
1400 0000: 28 */
1401 /* READ { 0, 0x0000, 0x8610 } ->
1402 0000: 05 */
1403 /* READ { 0, 0x0000, 0x8611 } ->
1404 0000: 25 */
1405 /* READ { 0, 0x0000, 0x8612 } ->
1406 0000: e1 */
1407 /* READ { 0, 0x0000, 0x8613 } ->
1408 0000: fa */
1409 /* READ { 0, 0x0000, 0x8614 } ->
1410 0000: f4 */
1411 /* READ { 0, 0x0000, 0x8615 } ->
1412 0000: e8 */
1413 /* READ { 0, 0x0000, 0x8616 } ->
1414 0000: 25 */
1415 {}
1416};
1417
1418static int reg_write(struct usb_device *dev,
1419 __u16 index, __u16 value)
1420{
1421 int ret;
1422
1423 ret = usb_control_msg(dev,
1424 usb_sndctrlpipe(dev, 0),
1425 0, /* request */
1426 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1427 value, index, NULL, 0, 500);
1428 PDEBUG(D_USBO, "reg write i:0x%04x = 0x%02x",
1429 index, value);
1430 if (ret < 0)
1431 PDEBUG(D_ERR|D_USBO, "reg write: error %d", ret);
1432 return ret;
1433}
1434
1435/* read 1 byte */
1436/* returns: negative is error, pos or zero is data */
1437static int reg_read(struct usb_device *dev,
1438 __u16 index) /* wIndex */
1439{
1440 int ret;
1441 __u8 data;
1442
1443 ret = usb_control_msg(dev,
1444 usb_rcvctrlpipe(dev, 0),
1445 0, /* register */
1446 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1447 (__u16) 0, /* value */
1448 index,
1449 &data, 1,
1450 500); /* timeout */
1451 PDEBUG(D_USBI, "reg read i:%04x --> %02x", index, data);
1452 if (ret < 0) {
1453 PDEBUG(D_ERR|D_USBI, "reg_read err %d", ret);
1454 return ret;
1455 }
1456 return data;
1457}
1458
1459static int write_vector(struct gspca_dev *gspca_dev,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001460 const __u16 data[][3])
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001461{
1462 struct usb_device *dev = gspca_dev->dev;
1463 int ret, i = 0;
1464
1465 while (data[i][1] != 0) {
1466 ret = reg_write(dev, data[i][1], data[i][0]);
1467 if (ret < 0)
1468 return ret;
1469 i++;
1470 }
1471 return 0;
1472}
1473
1474/* this function is called at probe time */
1475static int sd_config(struct gspca_dev *gspca_dev,
1476 const struct usb_device_id *id)
1477{
1478 struct sd *sd = (struct sd *) gspca_dev;
1479 struct usb_device *dev = gspca_dev->dev;
1480 struct cam *cam;
1481 __u16 vendor;
1482 __u16 product;
1483 int data1, data2;
1484
1485 vendor = id->idVendor;
1486 product = id->idProduct;
1487 switch (vendor) {
1488 case 0x041e: /* Creative cameras */
1489/* switch (product) { */
1490/* case 0x4018: */
1491 sd->subtype = CreativeVista;
1492/* break; */
1493/* } */
1494 break;
1495 case 0x0461: /* MicroInnovation */
1496/* switch (product) { */
1497/* case 0x0815: */
1498 sd->subtype = MicroInnovationIC200;
1499/* break; */
1500/* } */
1501 break;
1502 case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
1503/* switch (product) { */
1504/* case 0x110: */
1505 sd->subtype = ViewQuestVQ110;
1506/* break; */
1507/* } */
1508 break;
Douglas Schilling Landgraf69b28b12008-07-04 04:40:28 -03001509 case 0x0130: /* Clone webcam */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001510 case 0x0af9: /* Hama cameras */
1511 switch (product) {
Douglas Schilling Landgraf69b28b12008-07-04 04:40:28 -03001512 case 0x0130:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001513 case 0x0010:
1514 sd->subtype = HamaUSBSightcam;
1515 break;
1516 case 0x0011:
1517 sd->subtype = HamaUSBSightcam2;
1518 break;
1519 }
1520 break;
1521 case 0x8086: /* Intel */
1522/* switch (product) { */
1523/* case 0x0110: */
1524 sd->subtype = IntelEasyPCCamera;
1525/* break; */
1526/* } */
1527 break;
1528 }
1529
1530 /* Read from global register the USB product and vendor IDs, just to */
1531 /* prove that we can communicate with the device. This works, which */
1532 /* confirms at we are communicating properly and that the device */
1533 /* is a 508. */
1534 data1 = reg_read(dev, 0x8104);
1535 data2 = reg_read(dev, 0x8105);
1536 PDEBUG(D_PROBE,
1537 "Read from GLOBAL: USB Vendor ID 0x%02x%02x", data2, data1);
1538
1539 data1 = reg_read(dev, 0x8106);
1540 data2 = reg_read(dev, 0x8107);
1541 PDEBUG(D_PROBE,
1542 "Read from GLOBAL: USB Product ID 0x%02x%02x", data2, data1);
1543
1544 data1 = reg_read(dev, 0x8621);
1545 PDEBUG(D_PROBE,
1546 "Read from GLOBAL: Window 1 average luminance %d", data1);
1547
1548 cam = &gspca_dev->cam;
1549 cam->dev_name = (char *) id->driver_info;
1550 cam->epaddr = 0x01;
1551 cam->cam_mode = sif_mode;
1552 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0];
1553 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
1554
1555 switch (sd->subtype) {
1556 case ViewQuestVQ110:
1557 if (write_vector(gspca_dev, spca508_init_data))
1558 return -1;
1559 break;
1560 default:
1561/* case MicroInnovationIC200: */
1562/* case IntelEasyPCCamera: */
1563 if (write_vector(gspca_dev, spca508cs110_init_data))
1564 return -1;
1565 break;
1566 case HamaUSBSightcam:
1567 if (write_vector(gspca_dev, spca508_sightcam_init_data))
1568 return -1;
1569 break;
1570 case HamaUSBSightcam2:
1571 if (write_vector(gspca_dev, spca508_sightcam2_init_data))
1572 return -1;
1573 break;
1574 case CreativeVista:
1575 if (write_vector(gspca_dev, spca508_vista_init_data))
1576 return -1;
1577 break;
1578 }
1579 return 0; /* success */
1580}
1581
1582/* this function is called at open time */
1583static int sd_open(struct gspca_dev *gspca_dev)
1584{
1585/* write_vector(gspca_dev, spca508_open_data); */
1586 return 0;
1587}
1588
1589static void sd_start(struct gspca_dev *gspca_dev)
1590{
1591 int mode;
1592
Jean-Francois Moinec2446b32008-07-05 11:49:20 -03001593 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001594 reg_write(gspca_dev->dev, 0x8500, mode);
1595 switch (mode) {
1596 case 0:
1597 case 1:
1598 reg_write(gspca_dev->dev, 0x8700, 0x28); /* clock */
1599 break;
1600 default:
1601/* case 2: */
1602/* case 3: */
1603 reg_write(gspca_dev->dev, 0x8700, 0x23); /* clock */
1604 break;
1605 }
1606 reg_write(gspca_dev->dev, 0x8112, 0x10 | 0x20);
1607}
1608
1609static void sd_stopN(struct gspca_dev *gspca_dev)
1610{
1611 /* Video ISO disable, Video Drop Packet enable: */
1612 reg_write(gspca_dev->dev, 0x8112, 0x20);
1613}
1614
1615static void sd_stop0(struct gspca_dev *gspca_dev)
1616{
1617}
1618
1619/* this function is called at close time */
1620static void sd_close(struct gspca_dev *gspca_dev)
1621{
1622}
1623
1624/* convert YUVY per line to YUYV (YUV 4:2:2) */
1625static void yuvy_decode(unsigned char *out,
1626 unsigned char *in,
1627 int width,
1628 int height)
1629{
1630 unsigned char *Ui, *Vi, *yi, *yi1;
1631 unsigned char *out1;
1632 int i, j;
1633
1634 yi = in;
1635 for (i = height / 2; --i >= 0; ) {
1636 out1 = out + width * 2; /* next line */
1637 Ui = yi + width;
1638 Vi = Ui + width / 2;
1639 yi1 = Vi + width / 2;
1640 for (j = width / 2; --j >= 0; ) {
1641 *out++ = 128 + *yi++;
1642 *out++ = 128 + *Ui;
1643 *out++ = 128 + *yi++;
1644 *out++ = 128 + *Vi;
1645
1646 *out1++ = 128 + *yi1++;
1647 *out1++ = 128 + *Ui++;
1648 *out1++ = 128 + *yi1++;
1649 *out1++ = 128 + *Vi++;
1650 }
1651 yi += width * 2;
1652 out = out1;
1653 }
1654}
1655
1656static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1657 struct gspca_frame *frame, /* target */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001658 __u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001659 int len) /* iso packet length */
1660{
1661 struct sd *sd = (struct sd *) gspca_dev;
1662
1663 switch (data[0]) {
1664 case 0: /* start of frame */
1665 if (gspca_dev->last_packet_type == FIRST_PACKET) {
1666 yuvy_decode(sd->tmpbuf2, sd->tmpbuf,
1667 gspca_dev->width,
1668 gspca_dev->height);
1669 frame = gspca_frame_add(gspca_dev,
1670 LAST_PACKET,
1671 frame,
1672 sd->tmpbuf2,
1673 gspca_dev->width
1674 * gspca_dev->height
1675 * 2);
1676 }
1677 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1678 data, 0);
1679 data += SPCA508_OFFSET_DATA;
1680 len -= SPCA508_OFFSET_DATA;
1681 if (len > 0)
1682 memcpy(sd->tmpbuf, data, len);
1683 else
1684 len = 0;
1685 sd->buflen = len;
1686 return;
1687 case 0xff: /* drop */
1688/* gspca_dev->last_packet_type = DISCARD_PACKET; */
1689 return;
1690 }
1691 data += 1;
1692 len -= 1;
1693 memcpy(&sd->tmpbuf[sd->buflen], data, len);
1694 sd->buflen += len;
1695}
1696
1697static void setbrightness(struct gspca_dev *gspca_dev)
1698{
1699 struct sd *sd = (struct sd *) gspca_dev;
1700 __u8 brightness = sd->brightness;
1701
1702/* MX seem contrast */
1703 reg_write(gspca_dev->dev, 0x8651, brightness);
1704 reg_write(gspca_dev->dev, 0x8652, brightness);
1705 reg_write(gspca_dev->dev, 0x8653, brightness);
1706 reg_write(gspca_dev->dev, 0x8654, brightness);
1707}
1708
1709static void getbrightness(struct gspca_dev *gspca_dev)
1710{
1711 struct sd *sd = (struct sd *) gspca_dev;
1712
1713 sd->brightness = reg_read(gspca_dev->dev, 0x8651);
1714}
1715
1716static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1717{
1718 struct sd *sd = (struct sd *) gspca_dev;
1719
1720 sd->brightness = val;
1721 if (gspca_dev->streaming)
1722 setbrightness(gspca_dev);
1723 return 0;
1724}
1725
1726static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
1727{
1728 struct sd *sd = (struct sd *) gspca_dev;
1729
1730 getbrightness(gspca_dev);
1731 *val = sd->brightness;
1732 return 0;
1733}
1734
1735/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001736static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001737 .name = MODULE_NAME,
1738 .ctrls = sd_ctrls,
1739 .nctrls = ARRAY_SIZE(sd_ctrls),
1740 .config = sd_config,
1741 .open = sd_open,
1742 .start = sd_start,
1743 .stopN = sd_stopN,
1744 .stop0 = sd_stop0,
1745 .close = sd_close,
1746 .pkt_scan = sd_pkt_scan,
1747};
1748
1749/* -- module initialisation -- */
1750#define DVNM(name) .driver_info = (kernel_ulong_t) name
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001751static const __devinitdata struct usb_device_id device_table[] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001752 {USB_DEVICE(0x041e, 0x4018), DVNM("Creative Webcam Vista (PD1100)")},
1753 {USB_DEVICE(0x0461, 0x0815), DVNM("Micro Innovation IC200")},
1754 {USB_DEVICE(0x0733, 0x0110), DVNM("ViewQuest VQ110")},
1755 {USB_DEVICE(0x0af9, 0x0010), DVNM("Hama USB Sightcam 100")},
1756 {USB_DEVICE(0x0af9, 0x0011), DVNM("Hama USB Sightcam 100")},
1757 {USB_DEVICE(0x8086, 0x0110), DVNM("Intel Easy PC Camera")},
Douglas Schilling Landgraf69b28b12008-07-04 04:40:28 -03001758 {USB_DEVICE(0x0130, 0x0130),
1759 DVNM("Clone Digital Webcam 11043 (spca508a)")},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001760 {}
1761};
1762MODULE_DEVICE_TABLE(usb, device_table);
1763
1764/* -- device connect -- */
1765static int sd_probe(struct usb_interface *intf,
1766 const struct usb_device_id *id)
1767{
1768 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
1769 THIS_MODULE);
1770}
1771
1772static struct usb_driver sd_driver = {
1773 .name = MODULE_NAME,
1774 .id_table = device_table,
1775 .probe = sd_probe,
1776 .disconnect = gspca_disconnect,
1777};
1778
1779/* -- module insert / remove -- */
1780static int __init sd_mod_init(void)
1781{
1782 if (usb_register(&sd_driver) < 0)
1783 return -1;
1784 PDEBUG(D_PROBE, "v%s registered", version);
1785 return 0;
1786}
1787static void __exit sd_mod_exit(void)
1788{
1789 usb_deregister(&sd_driver);
1790 PDEBUG(D_PROBE, "deregistered");
1791}
1792
1793module_init(sd_mod_init);
1794module_exit(sd_mod_exit);