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