]>
Commit | Line | Data |
---|---|---|
6a7eba24 JFM |
1 | /* |
2 | * SPCA505 chip based cameras initialization data | |
3 | * | |
4 | * V4L2 by Jean-Francis 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 | ||
133a9fe9 JP |
22 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
23 | ||
6a7eba24 JFM |
24 | #define MODULE_NAME "spca505" |
25 | ||
26 | #include "gspca.h" | |
27 | ||
6a7eba24 JFM |
28 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
29 | MODULE_DESCRIPTION("GSPCA/SPCA505 USB Camera Driver"); | |
30 | MODULE_LICENSE("GPL"); | |
31 | ||
32 | /* specific webcam descriptor */ | |
33 | struct sd { | |
34 | struct gspca_dev gspca_dev; /* !! must be the first item */ | |
35 | ||
16631aed | 36 | u8 subtype; |
6a7eba24 JFM |
37 | #define IntelPCCameraPro 0 |
38 | #define Nxultra 1 | |
39 | }; | |
40 | ||
cc611b8a | 41 | static const struct v4l2_pix_format vga_mode[] = { |
1250ac6d | 42 | {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
00b27ce6 | 43 | .bytesperline = 160, |
1250ac6d | 44 | .sizeimage = 160 * 120 * 3 / 2, |
c2446b3e | 45 | .colorspace = V4L2_COLORSPACE_SRGB, |
a5df5c14 | 46 | .priv = 4}, |
1250ac6d | 47 | {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
00b27ce6 | 48 | .bytesperline = 176, |
1250ac6d | 49 | .sizeimage = 176 * 144 * 3 / 2, |
c2446b3e | 50 | .colorspace = V4L2_COLORSPACE_SRGB, |
a5df5c14 | 51 | .priv = 3}, |
1250ac6d | 52 | {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
00b27ce6 | 53 | .bytesperline = 320, |
1250ac6d | 54 | .sizeimage = 320 * 240 * 3 / 2, |
c2446b3e JFM |
55 | .colorspace = V4L2_COLORSPACE_SRGB, |
56 | .priv = 2}, | |
1250ac6d | 57 | {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
00b27ce6 | 58 | .bytesperline = 352, |
1250ac6d | 59 | .sizeimage = 352 * 288 * 3 / 2, |
c2446b3e JFM |
60 | .colorspace = V4L2_COLORSPACE_SRGB, |
61 | .priv = 1}, | |
1250ac6d | 62 | {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
00b27ce6 | 63 | .bytesperline = 640, |
1250ac6d | 64 | .sizeimage = 640 * 480 * 3 / 2, |
c2446b3e JFM |
65 | .colorspace = V4L2_COLORSPACE_SRGB, |
66 | .priv = 0}, | |
6a7eba24 JFM |
67 | }; |
68 | ||
69 | #define SPCA50X_OFFSET_DATA 10 | |
70 | ||
71 | #define SPCA50X_REG_USB 0x02 /* spca505 501 */ | |
72 | ||
73 | #define SPCA50X_USB_CTRL 0x00 /* spca505 */ | |
74 | #define SPCA50X_CUSB_ENABLE 0x01 /* spca505 */ | |
a5df5c14 | 75 | |
6a7eba24 JFM |
76 | #define SPCA50X_REG_GLOBAL 0x03 /* spca505 */ |
77 | #define SPCA50X_GMISC0_IDSEL 0x01 /* Global control device ID select spca505 */ | |
78 | #define SPCA50X_GLOBAL_MISC0 0x00 /* Global control miscellaneous 0 spca505 */ | |
79 | ||
80 | #define SPCA50X_GLOBAL_MISC1 0x01 /* 505 */ | |
81 | #define SPCA50X_GLOBAL_MISC3 0x03 /* 505 */ | |
82 | #define SPCA50X_GMISC3_SAA7113RST 0x20 /* Not sure about this one spca505 */ | |
83 | ||
a5df5c14 JFM |
84 | /* Image format and compression control */ |
85 | #define SPCA50X_REG_COMPRESS 0x04 | |
86 | ||
6a7eba24 JFM |
87 | /* |
88 | * Data to initialize a SPCA505. Common to the CCD and external modes | |
89 | */ | |
16631aed JFM |
90 | static const u8 spca505_init_data[][3] = { |
91 | /* bmRequest,value,index */ | |
6a7eba24 JFM |
92 | {SPCA50X_REG_GLOBAL, SPCA50X_GMISC3_SAA7113RST, SPCA50X_GLOBAL_MISC3}, |
93 | /* Sensor reset */ | |
16631aed JFM |
94 | {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC3}, |
95 | {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC1}, | |
6a7eba24 | 96 | /* Block USB reset */ |
16631aed | 97 | {SPCA50X_REG_GLOBAL, SPCA50X_GMISC0_IDSEL, SPCA50X_GLOBAL_MISC0}, |
6a7eba24 | 98 | |
16631aed | 99 | {0x05, 0x01, 0x10}, |
6a7eba24 | 100 | /* Maybe power down some stuff */ |
16631aed | 101 | {0x05, 0x0f, 0x11}, |
6a7eba24 JFM |
102 | |
103 | /* Setup internal CCD ? */ | |
16631aed JFM |
104 | {0x06, 0x10, 0x08}, |
105 | {0x06, 0x00, 0x09}, | |
106 | {0x06, 0x00, 0x0a}, | |
107 | {0x06, 0x00, 0x0b}, | |
108 | {0x06, 0x10, 0x0c}, | |
109 | {0x06, 0x00, 0x0d}, | |
110 | {0x06, 0x00, 0x0e}, | |
111 | {0x06, 0x00, 0x0f}, | |
112 | {0x06, 0x10, 0x10}, | |
113 | {0x06, 0x02, 0x11}, | |
114 | {0x06, 0x00, 0x12}, | |
115 | {0x06, 0x04, 0x13}, | |
116 | {0x06, 0x02, 0x14}, | |
117 | {0x06, 0x8a, 0x51}, | |
118 | {0x06, 0x40, 0x52}, | |
119 | {0x06, 0xb6, 0x53}, | |
120 | {0x06, 0x3d, 0x54}, | |
6a7eba24 JFM |
121 | {} |
122 | }; | |
123 | ||
124 | /* | |
125 | * Data to initialize the camera using the internal CCD | |
126 | */ | |
16631aed JFM |
127 | static const u8 spca505_open_data_ccd[][3] = { |
128 | /* bmRequest,value,index */ | |
6a7eba24 | 129 | /* Internal CCD data set */ |
16631aed | 130 | {0x03, 0x04, 0x01}, |
6a7eba24 | 131 | /* This could be a reset */ |
16631aed | 132 | {0x03, 0x00, 0x01}, |
6a7eba24 JFM |
133 | |
134 | /* Setup compression and image registers. 0x6 and 0x7 seem to be | |
135 | related to H&V hold, and are resolution mode specific */ | |
16631aed | 136 | {0x04, 0x10, 0x01}, |
6a7eba24 | 137 | /* DIFF(0x50), was (0x10) */ |
16631aed JFM |
138 | {0x04, 0x00, 0x04}, |
139 | {0x04, 0x00, 0x05}, | |
140 | {0x04, 0x20, 0x06}, | |
141 | {0x04, 0x20, 0x07}, | |
6a7eba24 | 142 | |
16631aed | 143 | {0x08, 0x0a, 0x00}, |
6a7eba24 JFM |
144 | /* DIFF (0x4a), was (0xa) */ |
145 | ||
16631aed JFM |
146 | {0x05, 0x00, 0x10}, |
147 | {0x05, 0x00, 0x11}, | |
148 | {0x05, 0x00, 0x00}, | |
6a7eba24 | 149 | /* DIFF not written */ |
16631aed | 150 | {0x05, 0x00, 0x01}, |
6a7eba24 | 151 | /* DIFF not written */ |
16631aed | 152 | {0x05, 0x00, 0x02}, |
6a7eba24 | 153 | /* DIFF not written */ |
16631aed | 154 | {0x05, 0x00, 0x03}, |
6a7eba24 | 155 | /* DIFF not written */ |
16631aed | 156 | {0x05, 0x00, 0x04}, |
6a7eba24 | 157 | /* DIFF not written */ |
16631aed | 158 | {0x05, 0x80, 0x05}, |
6a7eba24 | 159 | /* DIFF not written */ |
16631aed | 160 | {0x05, 0xe0, 0x06}, |
6a7eba24 | 161 | /* DIFF not written */ |
16631aed | 162 | {0x05, 0x20, 0x07}, |
6a7eba24 | 163 | /* DIFF not written */ |
16631aed | 164 | {0x05, 0xa0, 0x08}, |
6a7eba24 | 165 | /* DIFF not written */ |
16631aed | 166 | {0x05, 0x0, 0x12}, |
6a7eba24 | 167 | /* DIFF not written */ |
16631aed | 168 | {0x05, 0x02, 0x0f}, |
6a7eba24 | 169 | /* DIFF not written */ |
16631aed | 170 | {0x05, 0x10, 0x46}, |
6a7eba24 | 171 | /* DIFF not written */ |
16631aed | 172 | {0x05, 0x8, 0x4a}, |
6a7eba24 JFM |
173 | /* DIFF not written */ |
174 | ||
16631aed | 175 | {0x03, 0x08, 0x03}, |
6a7eba24 | 176 | /* DIFF (0x3,0x28,0x3) */ |
16631aed JFM |
177 | {0x03, 0x08, 0x01}, |
178 | {0x03, 0x0c, 0x03}, | |
6a7eba24 | 179 | /* DIFF not written */ |
16631aed | 180 | {0x03, 0x21, 0x00}, |
6a7eba24 JFM |
181 | /* DIFF (0x39) */ |
182 | ||
183 | /* Extra block copied from init to hopefully ensure CCD is in a sane state */ | |
16631aed JFM |
184 | {0x06, 0x10, 0x08}, |
185 | {0x06, 0x00, 0x09}, | |
186 | {0x06, 0x00, 0x0a}, | |
187 | {0x06, 0x00, 0x0b}, | |
188 | {0x06, 0x10, 0x0c}, | |
189 | {0x06, 0x00, 0x0d}, | |
190 | {0x06, 0x00, 0x0e}, | |
191 | {0x06, 0x00, 0x0f}, | |
192 | {0x06, 0x10, 0x10}, | |
193 | {0x06, 0x02, 0x11}, | |
194 | {0x06, 0x00, 0x12}, | |
195 | {0x06, 0x04, 0x13}, | |
196 | {0x06, 0x02, 0x14}, | |
197 | {0x06, 0x8a, 0x51}, | |
198 | {0x06, 0x40, 0x52}, | |
199 | {0x06, 0xb6, 0x53}, | |
200 | {0x06, 0x3d, 0x54}, | |
6a7eba24 JFM |
201 | /* End of extra block */ |
202 | ||
16631aed | 203 | {0x06, 0x3f, 0x1}, |
6a7eba24 | 204 | /* Block skipped */ |
16631aed JFM |
205 | {0x06, 0x10, 0x02}, |
206 | {0x06, 0x64, 0x07}, | |
207 | {0x06, 0x10, 0x08}, | |
208 | {0x06, 0x00, 0x09}, | |
209 | {0x06, 0x00, 0x0a}, | |
210 | {0x06, 0x00, 0x0b}, | |
211 | {0x06, 0x10, 0x0c}, | |
212 | {0x06, 0x00, 0x0d}, | |
213 | {0x06, 0x00, 0x0e}, | |
214 | {0x06, 0x00, 0x0f}, | |
215 | {0x06, 0x10, 0x10}, | |
216 | {0x06, 0x02, 0x11}, | |
217 | {0x06, 0x00, 0x12}, | |
218 | {0x06, 0x04, 0x13}, | |
219 | {0x06, 0x02, 0x14}, | |
220 | {0x06, 0x8a, 0x51}, | |
221 | {0x06, 0x40, 0x52}, | |
222 | {0x06, 0xb6, 0x53}, | |
223 | {0x06, 0x3d, 0x54}, | |
224 | {0x06, 0x60, 0x57}, | |
225 | {0x06, 0x20, 0x58}, | |
226 | {0x06, 0x15, 0x59}, | |
227 | {0x06, 0x05, 0x5a}, | |
228 | ||
229 | {0x05, 0x01, 0xc0}, | |
230 | {0x05, 0x10, 0xcb}, | |
231 | {0x05, 0x80, 0xc1}, | |
6a7eba24 | 232 | /* */ |
16631aed | 233 | {0x05, 0x0, 0xc2}, |
6a7eba24 | 234 | /* 4 was 0 */ |
16631aed JFM |
235 | {0x05, 0x00, 0xca}, |
236 | {0x05, 0x80, 0xc1}, | |
6a7eba24 | 237 | /* */ |
16631aed JFM |
238 | {0x05, 0x04, 0xc2}, |
239 | {0x05, 0x00, 0xca}, | |
240 | {0x05, 0x0, 0xc1}, | |
6a7eba24 | 241 | /* */ |
16631aed JFM |
242 | {0x05, 0x00, 0xc2}, |
243 | {0x05, 0x00, 0xca}, | |
244 | {0x05, 0x40, 0xc1}, | |
6a7eba24 | 245 | /* */ |
16631aed JFM |
246 | {0x05, 0x17, 0xc2}, |
247 | {0x05, 0x00, 0xca}, | |
248 | {0x05, 0x80, 0xc1}, | |
6a7eba24 | 249 | /* */ |
16631aed JFM |
250 | {0x05, 0x06, 0xc2}, |
251 | {0x05, 0x00, 0xca}, | |
252 | {0x05, 0x80, 0xc1}, | |
6a7eba24 | 253 | /* */ |
16631aed JFM |
254 | {0x05, 0x04, 0xc2}, |
255 | {0x05, 0x00, 0xca}, | |
6a7eba24 | 256 | |
16631aed JFM |
257 | {0x03, 0x4c, 0x3}, |
258 | {0x03, 0x18, 0x1}, | |
6a7eba24 | 259 | |
16631aed JFM |
260 | {0x06, 0x70, 0x51}, |
261 | {0x06, 0xbe, 0x53}, | |
262 | {0x06, 0x71, 0x57}, | |
263 | {0x06, 0x20, 0x58}, | |
264 | {0x06, 0x05, 0x59}, | |
265 | {0x06, 0x15, 0x5a}, | |
6a7eba24 | 266 | |
16631aed | 267 | {0x04, 0x00, 0x08}, |
6a7eba24 | 268 | /* Compress = OFF (0x1 to turn on) */ |
16631aed JFM |
269 | {0x04, 0x12, 0x09}, |
270 | {0x04, 0x21, 0x0a}, | |
271 | {0x04, 0x10, 0x0b}, | |
272 | {0x04, 0x21, 0x0c}, | |
273 | {0x04, 0x05, 0x00}, | |
6a7eba24 | 274 | /* was 5 (Image Type ? ) */ |
16631aed JFM |
275 | {0x04, 0x00, 0x01}, |
276 | ||
277 | {0x06, 0x3f, 0x01}, | |
278 | ||
279 | {0x04, 0x00, 0x04}, | |
280 | {0x04, 0x00, 0x05}, | |
281 | {0x04, 0x40, 0x06}, | |
282 | {0x04, 0x40, 0x07}, | |
283 | ||
284 | {0x06, 0x1c, 0x17}, | |
285 | {0x06, 0xe2, 0x19}, | |
286 | {0x06, 0x1c, 0x1b}, | |
287 | {0x06, 0xe2, 0x1d}, | |
288 | {0x06, 0xaa, 0x1f}, | |
289 | {0x06, 0x70, 0x20}, | |
290 | ||
291 | {0x05, 0x01, 0x10}, | |
292 | {0x05, 0x00, 0x11}, | |
293 | {0x05, 0x01, 0x00}, | |
294 | {0x05, 0x05, 0x01}, | |
295 | {0x05, 0x00, 0xc1}, | |
6a7eba24 | 296 | /* */ |
16631aed JFM |
297 | {0x05, 0x00, 0xc2}, |
298 | {0x05, 0x00, 0xca}, | |
6a7eba24 | 299 | |
16631aed JFM |
300 | {0x06, 0x70, 0x51}, |
301 | {0x06, 0xbe, 0x53}, | |
6a7eba24 JFM |
302 | {} |
303 | }; | |
304 | ||
305 | /* | |
16631aed | 306 | * Made by Tomasz Zablocki (skalamandra@poczta.onet.pl) |
6a7eba24 | 307 | * SPCA505b chip based cameras initialization data |
6a7eba24 JFM |
308 | */ |
309 | /* jfm */ | |
310 | #define initial_brightness 0x7f /* 0x0(white)-0xff(black) */ | |
311 | /* #define initial_brightness 0x0 //0x0(white)-0xff(black) */ | |
312 | /* | |
313 | * Data to initialize a SPCA505. Common to the CCD and external modes | |
314 | */ | |
16631aed | 315 | static const u8 spca505b_init_data[][3] = { |
6a7eba24 JFM |
316 | /* start */ |
317 | {0x02, 0x00, 0x00}, /* init */ | |
318 | {0x02, 0x00, 0x01}, | |
319 | {0x02, 0x00, 0x02}, | |
320 | {0x02, 0x00, 0x03}, | |
321 | {0x02, 0x00, 0x04}, | |
322 | {0x02, 0x00, 0x05}, | |
323 | {0x02, 0x00, 0x06}, | |
324 | {0x02, 0x00, 0x07}, | |
325 | {0x02, 0x00, 0x08}, | |
326 | {0x02, 0x00, 0x09}, | |
327 | {0x03, 0x00, 0x00}, | |
328 | {0x03, 0x00, 0x01}, | |
329 | {0x03, 0x00, 0x02}, | |
330 | {0x03, 0x00, 0x03}, | |
331 | {0x03, 0x00, 0x04}, | |
332 | {0x03, 0x00, 0x05}, | |
333 | {0x03, 0x00, 0x06}, | |
334 | {0x04, 0x00, 0x00}, | |
335 | {0x04, 0x00, 0x02}, | |
336 | {0x04, 0x00, 0x04}, | |
337 | {0x04, 0x00, 0x05}, | |
338 | {0x04, 0x00, 0x06}, | |
339 | {0x04, 0x00, 0x07}, | |
340 | {0x04, 0x00, 0x08}, | |
341 | {0x04, 0x00, 0x09}, | |
342 | {0x04, 0x00, 0x0a}, | |
343 | {0x04, 0x00, 0x0b}, | |
344 | {0x04, 0x00, 0x0c}, | |
345 | {0x07, 0x00, 0x00}, | |
346 | {0x07, 0x00, 0x03}, | |
347 | {0x08, 0x00, 0x00}, | |
348 | {0x08, 0x00, 0x01}, | |
349 | {0x08, 0x00, 0x02}, | |
6a7eba24 JFM |
350 | {0x06, 0x18, 0x08}, |
351 | {0x06, 0xfc, 0x09}, | |
352 | {0x06, 0xfc, 0x0a}, | |
353 | {0x06, 0xfc, 0x0b}, | |
354 | {0x06, 0x18, 0x0c}, | |
355 | {0x06, 0xfc, 0x0d}, | |
356 | {0x06, 0xfc, 0x0e}, | |
357 | {0x06, 0xfc, 0x0f}, | |
358 | {0x06, 0x18, 0x10}, | |
359 | {0x06, 0xfe, 0x12}, | |
360 | {0x06, 0x00, 0x11}, | |
361 | {0x06, 0x00, 0x14}, | |
362 | {0x06, 0x00, 0x13}, | |
363 | {0x06, 0x28, 0x51}, | |
364 | {0x06, 0xff, 0x53}, | |
365 | {0x02, 0x00, 0x08}, | |
366 | ||
367 | {0x03, 0x00, 0x03}, | |
368 | {0x03, 0x10, 0x03}, | |
369 | {} | |
370 | }; | |
371 | ||
372 | /* | |
373 | * Data to initialize the camera using the internal CCD | |
374 | */ | |
16631aed | 375 | static const u8 spca505b_open_data_ccd[][3] = { |
6a7eba24 JFM |
376 | |
377 | /* {0x02,0x00,0x00}, */ | |
378 | {0x03, 0x04, 0x01}, /* rst */ | |
379 | {0x03, 0x00, 0x01}, | |
380 | {0x03, 0x00, 0x00}, | |
381 | {0x03, 0x21, 0x00}, | |
382 | {0x03, 0x00, 0x04}, | |
383 | {0x03, 0x00, 0x03}, | |
384 | {0x03, 0x18, 0x03}, | |
385 | {0x03, 0x08, 0x01}, | |
386 | {0x03, 0x1c, 0x03}, | |
387 | {0x03, 0x5c, 0x03}, | |
388 | {0x03, 0x5c, 0x03}, | |
389 | {0x03, 0x18, 0x01}, | |
390 | ||
391 | /* same as 505 */ | |
392 | {0x04, 0x10, 0x01}, | |
393 | {0x04, 0x00, 0x04}, | |
394 | {0x04, 0x00, 0x05}, | |
395 | {0x04, 0x20, 0x06}, | |
396 | {0x04, 0x20, 0x07}, | |
397 | ||
398 | {0x08, 0x0a, 0x00}, | |
399 | ||
400 | {0x05, 0x00, 0x10}, | |
401 | {0x05, 0x00, 0x11}, | |
402 | {0x05, 0x00, 0x12}, | |
403 | {0x05, 0x6f, 0x00}, | |
92e8c91b JFM |
404 | {0x05, initial_brightness >> 6, 0x00}, |
405 | {0x05, (initial_brightness << 2) & 0xff, 0x01}, | |
6a7eba24 JFM |
406 | {0x05, 0x00, 0x02}, |
407 | {0x05, 0x01, 0x03}, | |
408 | {0x05, 0x00, 0x04}, | |
409 | {0x05, 0x03, 0x05}, | |
410 | {0x05, 0xe0, 0x06}, | |
411 | {0x05, 0x20, 0x07}, | |
412 | {0x05, 0xa0, 0x08}, | |
413 | {0x05, 0x00, 0x12}, | |
414 | {0x05, 0x02, 0x0f}, | |
16631aed | 415 | {0x05, 0x80, 0x14}, /* max exposure off (0=on) */ |
6a7eba24 JFM |
416 | {0x05, 0x01, 0xb0}, |
417 | {0x05, 0x01, 0xbf}, | |
418 | {0x03, 0x02, 0x06}, | |
419 | {0x05, 0x10, 0x46}, | |
420 | {0x05, 0x08, 0x4a}, | |
421 | ||
422 | {0x06, 0x00, 0x01}, | |
423 | {0x06, 0x10, 0x02}, | |
424 | {0x06, 0x64, 0x07}, | |
425 | {0x06, 0x18, 0x08}, | |
426 | {0x06, 0xfc, 0x09}, | |
427 | {0x06, 0xfc, 0x0a}, | |
428 | {0x06, 0xfc, 0x0b}, | |
429 | {0x04, 0x00, 0x01}, | |
430 | {0x06, 0x18, 0x0c}, | |
431 | {0x06, 0xfc, 0x0d}, | |
432 | {0x06, 0xfc, 0x0e}, | |
433 | {0x06, 0xfc, 0x0f}, | |
434 | {0x06, 0x11, 0x10}, /* contrast */ | |
435 | {0x06, 0x00, 0x11}, | |
436 | {0x06, 0xfe, 0x12}, | |
437 | {0x06, 0x00, 0x13}, | |
438 | {0x06, 0x00, 0x14}, | |
439 | {0x06, 0x9d, 0x51}, | |
440 | {0x06, 0x40, 0x52}, | |
441 | {0x06, 0x7c, 0x53}, | |
442 | {0x06, 0x40, 0x54}, | |
443 | {0x06, 0x02, 0x57}, | |
444 | {0x06, 0x03, 0x58}, | |
445 | {0x06, 0x15, 0x59}, | |
446 | {0x06, 0x05, 0x5a}, | |
447 | {0x06, 0x03, 0x56}, | |
448 | {0x06, 0x02, 0x3f}, | |
449 | {0x06, 0x00, 0x40}, | |
450 | {0x06, 0x39, 0x41}, | |
451 | {0x06, 0x69, 0x42}, | |
452 | {0x06, 0x87, 0x43}, | |
453 | {0x06, 0x9e, 0x44}, | |
454 | {0x06, 0xb1, 0x45}, | |
455 | {0x06, 0xbf, 0x46}, | |
456 | {0x06, 0xcc, 0x47}, | |
457 | {0x06, 0xd5, 0x48}, | |
458 | {0x06, 0xdd, 0x49}, | |
459 | {0x06, 0xe3, 0x4a}, | |
460 | {0x06, 0xe8, 0x4b}, | |
461 | {0x06, 0xed, 0x4c}, | |
462 | {0x06, 0xf2, 0x4d}, | |
463 | {0x06, 0xf7, 0x4e}, | |
464 | {0x06, 0xfc, 0x4f}, | |
465 | {0x06, 0xff, 0x50}, | |
466 | ||
467 | {0x05, 0x01, 0xc0}, | |
468 | {0x05, 0x10, 0xcb}, | |
469 | {0x05, 0x40, 0xc1}, | |
470 | {0x05, 0x04, 0xc2}, | |
471 | {0x05, 0x00, 0xca}, | |
472 | {0x05, 0x40, 0xc1}, | |
473 | {0x05, 0x09, 0xc2}, | |
474 | {0x05, 0x00, 0xca}, | |
475 | {0x05, 0xc0, 0xc1}, | |
476 | {0x05, 0x09, 0xc2}, | |
477 | {0x05, 0x00, 0xca}, | |
478 | {0x05, 0x40, 0xc1}, | |
479 | {0x05, 0x59, 0xc2}, | |
480 | {0x05, 0x00, 0xca}, | |
481 | {0x04, 0x00, 0x01}, | |
482 | {0x05, 0x80, 0xc1}, | |
483 | {0x05, 0xec, 0xc2}, | |
484 | {0x05, 0x0, 0xca}, | |
485 | ||
486 | {0x06, 0x02, 0x57}, | |
487 | {0x06, 0x01, 0x58}, | |
488 | {0x06, 0x15, 0x59}, | |
489 | {0x06, 0x0a, 0x5a}, | |
490 | {0x06, 0x01, 0x57}, | |
491 | {0x06, 0x8a, 0x03}, | |
492 | {0x06, 0x0a, 0x6c}, | |
493 | {0x06, 0x30, 0x01}, | |
494 | {0x06, 0x20, 0x02}, | |
495 | {0x06, 0x00, 0x03}, | |
496 | ||
497 | {0x05, 0x8c, 0x25}, | |
498 | ||
499 | {0x06, 0x4d, 0x51}, /* maybe saturation (4d) */ | |
500 | {0x06, 0x84, 0x53}, /* making green (84) */ | |
501 | {0x06, 0x00, 0x57}, /* sharpness (1) */ | |
502 | {0x06, 0x18, 0x08}, | |
503 | {0x06, 0xfc, 0x09}, | |
504 | {0x06, 0xfc, 0x0a}, | |
505 | {0x06, 0xfc, 0x0b}, | |
506 | {0x06, 0x18, 0x0c}, /* maybe hue (18) */ | |
507 | {0x06, 0xfc, 0x0d}, | |
508 | {0x06, 0xfc, 0x0e}, | |
509 | {0x06, 0xfc, 0x0f}, | |
510 | {0x06, 0x18, 0x10}, /* maybe contrast (18) */ | |
511 | ||
512 | {0x05, 0x01, 0x02}, | |
513 | ||
514 | {0x04, 0x00, 0x08}, /* compression */ | |
515 | {0x04, 0x12, 0x09}, | |
516 | {0x04, 0x21, 0x0a}, | |
517 | {0x04, 0x10, 0x0b}, | |
518 | {0x04, 0x21, 0x0c}, | |
519 | {0x04, 0x1d, 0x00}, /* imagetype (1d) */ | |
520 | {0x04, 0x41, 0x01}, /* hardware snapcontrol */ | |
521 | ||
522 | {0x04, 0x00, 0x04}, | |
523 | {0x04, 0x00, 0x05}, | |
524 | {0x04, 0x10, 0x06}, | |
525 | {0x04, 0x10, 0x07}, | |
526 | {0x04, 0x40, 0x06}, | |
527 | {0x04, 0x40, 0x07}, | |
528 | {0x04, 0x00, 0x04}, | |
529 | {0x04, 0x00, 0x05}, | |
530 | ||
531 | {0x06, 0x1c, 0x17}, | |
532 | {0x06, 0xe2, 0x19}, | |
533 | {0x06, 0x1c, 0x1b}, | |
534 | {0x06, 0xe2, 0x1d}, | |
535 | {0x06, 0x5f, 0x1f}, | |
536 | {0x06, 0x32, 0x20}, | |
537 | ||
92e8c91b JFM |
538 | {0x05, initial_brightness >> 6, 0x00}, |
539 | {0x05, (initial_brightness << 2) & 0xff, 0x01}, | |
6a7eba24 JFM |
540 | {0x05, 0x06, 0xc1}, |
541 | {0x05, 0x58, 0xc2}, | |
16631aed JFM |
542 | {0x05, 0x00, 0xca}, |
543 | {0x05, 0x00, 0x11}, | |
6a7eba24 JFM |
544 | {} |
545 | }; | |
546 | ||
547 | static int reg_write(struct usb_device *dev, | |
16631aed | 548 | u16 req, u16 index, u16 value) |
6a7eba24 JFM |
549 | { |
550 | int ret; | |
551 | ||
552 | ret = usb_control_msg(dev, | |
553 | usb_sndctrlpipe(dev, 0), | |
16631aed | 554 | req, |
6a7eba24 JFM |
555 | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
556 | value, index, NULL, 0, 500); | |
16631aed JFM |
557 | PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d", |
558 | req, index, value, ret); | |
6a7eba24 | 559 | if (ret < 0) |
133a9fe9 | 560 | pr_err("reg write: error %d\n", ret); |
6a7eba24 JFM |
561 | return ret; |
562 | } | |
563 | ||
564 | /* returns: negative is error, pos or zero is data */ | |
739570bb | 565 | static int reg_read(struct gspca_dev *gspca_dev, |
16631aed JFM |
566 | u16 req, /* bRequest */ |
567 | u16 index) /* wIndex */ | |
6a7eba24 JFM |
568 | { |
569 | int ret; | |
6a7eba24 | 570 | |
739570bb JFM |
571 | ret = usb_control_msg(gspca_dev->dev, |
572 | usb_rcvctrlpipe(gspca_dev->dev, 0), | |
16631aed | 573 | req, |
6a7eba24 | 574 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
16631aed JFM |
575 | 0, /* value */ |
576 | index, | |
577 | gspca_dev->usb_buf, 2, | |
6a7eba24 | 578 | 500); /* timeout */ |
16631aed JFM |
579 | if (ret < 0) |
580 | return ret; | |
739570bb | 581 | return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; |
6a7eba24 JFM |
582 | } |
583 | ||
584 | static int write_vector(struct gspca_dev *gspca_dev, | |
16631aed | 585 | const u8 data[][3]) |
6a7eba24 JFM |
586 | { |
587 | struct usb_device *dev = gspca_dev->dev; | |
588 | int ret, i = 0; | |
589 | ||
16631aed | 590 | while (data[i][0] != 0) { |
6a7eba24 | 591 | ret = reg_write(dev, data[i][0], data[i][2], data[i][1]); |
16631aed | 592 | if (ret < 0) |
6a7eba24 | 593 | return ret; |
6a7eba24 JFM |
594 | i++; |
595 | } | |
596 | return 0; | |
597 | } | |
598 | ||
599 | /* this function is called at probe time */ | |
600 | static int sd_config(struct gspca_dev *gspca_dev, | |
601 | const struct usb_device_id *id) | |
602 | { | |
603 | struct sd *sd = (struct sd *) gspca_dev; | |
604 | struct cam *cam; | |
6a7eba24 JFM |
605 | |
606 | cam = &gspca_dev->cam; | |
6a7eba24 | 607 | cam->cam_mode = vga_mode; |
9d64fdb1 | 608 | sd->subtype = id->driver_info; |
6a7eba24 | 609 | if (sd->subtype != IntelPCCameraPro) |
16631aed | 610 | cam->nmodes = ARRAY_SIZE(vga_mode); |
6a7eba24 | 611 | else /* no 640x480 for IntelPCCameraPro */ |
16631aed | 612 | cam->nmodes = ARRAY_SIZE(vga_mode) - 1; |
6a7eba24 | 613 | |
6a7eba24 JFM |
614 | return 0; |
615 | } | |
616 | ||
012d6b02 JFM |
617 | /* this function is called at probe and resume time */ |
618 | static int sd_init(struct gspca_dev *gspca_dev) | |
6a7eba24 | 619 | { |
253f13d5 JFM |
620 | struct sd *sd = (struct sd *) gspca_dev; |
621 | ||
622 | if (write_vector(gspca_dev, | |
623 | sd->subtype == Nxultra | |
624 | ? spca505b_init_data | |
625 | : spca505_init_data)) | |
626 | return -EIO; | |
6a7eba24 JFM |
627 | return 0; |
628 | } | |
629 | ||
2aed6c1b | 630 | static void setbrightness(struct gspca_dev *gspca_dev, s32 brightness) |
a5df5c14 | 631 | { |
a5df5c14 JFM |
632 | reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6); |
633 | reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2); | |
634 | } | |
635 | ||
72ab97ce | 636 | static int sd_start(struct gspca_dev *gspca_dev) |
6a7eba24 | 637 | { |
1de1ddf3 | 638 | struct sd *sd = (struct sd *) gspca_dev; |
6a7eba24 | 639 | struct usb_device *dev = gspca_dev->dev; |
a5df5c14 JFM |
640 | int ret, mode; |
641 | static u8 mode_tb[][3] = { | |
642 | /* r00 r06 r07 */ | |
643 | {0x00, 0x10, 0x10}, /* 640x480 */ | |
644 | {0x01, 0x1a, 0x1a}, /* 352x288 */ | |
645 | {0x02, 0x1c, 0x1d}, /* 320x240 */ | |
646 | {0x04, 0x34, 0x34}, /* 176x144 */ | |
647 | {0x05, 0x40, 0x40} /* 160x120 */ | |
648 | }; | |
6a7eba24 | 649 | |
1de1ddf3 JFM |
650 | if (sd->subtype == Nxultra) |
651 | write_vector(gspca_dev, spca505b_open_data_ccd); | |
652 | else | |
653 | write_vector(gspca_dev, spca505_open_data_ccd); | |
654 | ret = reg_read(gspca_dev, 0x06, 0x16); | |
655 | ||
656 | if (ret < 0) { | |
657 | PDEBUG(D_ERR|D_CONF, | |
658 | "register read failed err: %d", | |
659 | ret); | |
660 | return ret; | |
661 | } | |
662 | if (ret != 0x0101) { | |
133a9fe9 JP |
663 | pr_err("After vector read returns 0x%04x should be 0x0101\n", |
664 | ret); | |
1de1ddf3 JFM |
665 | } |
666 | ||
667 | ret = reg_write(gspca_dev->dev, 0x06, 0x16, 0x0a); | |
668 | if (ret < 0) | |
669 | return ret; | |
670 | reg_write(gspca_dev->dev, 0x05, 0xc2, 0x12); | |
671 | ||
6a7eba24 JFM |
672 | /* necessary because without it we can see stream |
673 | * only once after loading module */ | |
674 | /* stopping usb registers Tomasz change */ | |
a5df5c14 JFM |
675 | reg_write(dev, 0x02, 0x00, 0x00); |
676 | ||
677 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | |
678 | reg_write(dev, SPCA50X_REG_COMPRESS, 0x00, mode_tb[mode][0]); | |
679 | reg_write(dev, SPCA50X_REG_COMPRESS, 0x06, mode_tb[mode][1]); | |
680 | reg_write(dev, SPCA50X_REG_COMPRESS, 0x07, mode_tb[mode][2]); | |
681 | ||
82b343b2 | 682 | return reg_write(dev, SPCA50X_REG_USB, |
6a7eba24 JFM |
683 | SPCA50X_USB_CTRL, |
684 | SPCA50X_CUSB_ENABLE); | |
6a7eba24 JFM |
685 | } |
686 | ||
687 | static void sd_stopN(struct gspca_dev *gspca_dev) | |
688 | { | |
689 | /* Disable ISO packet machine */ | |
690 | reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); | |
691 | } | |
692 | ||
98522a7b | 693 | /* called on streamoff with alt 0 and on disconnect */ |
6a7eba24 | 694 | static void sd_stop0(struct gspca_dev *gspca_dev) |
6a7eba24 | 695 | { |
98522a7b JFM |
696 | if (!gspca_dev->present) |
697 | return; | |
698 | ||
6a7eba24 JFM |
699 | /* This maybe reset or power control */ |
700 | reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); | |
16631aed JFM |
701 | reg_write(gspca_dev->dev, 0x03, 0x01, 0x00); |
702 | reg_write(gspca_dev->dev, 0x03, 0x00, 0x01); | |
703 | reg_write(gspca_dev->dev, 0x05, 0x10, 0x01); | |
704 | reg_write(gspca_dev->dev, 0x05, 0x11, 0x0f); | |
6a7eba24 JFM |
705 | } |
706 | ||
6a7eba24 | 707 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
16631aed | 708 | u8 *data, /* isoc packet */ |
6a7eba24 JFM |
709 | int len) /* iso packet length */ |
710 | { | |
6a7eba24 JFM |
711 | switch (data[0]) { |
712 | case 0: /* start of frame */ | |
76dd272b | 713 | gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); |
6a7eba24 JFM |
714 | data += SPCA50X_OFFSET_DATA; |
715 | len -= SPCA50X_OFFSET_DATA; | |
76dd272b | 716 | gspca_frame_add(gspca_dev, FIRST_PACKET, data, len); |
1250ac6d | 717 | break; |
6a7eba24 | 718 | case 0xff: /* drop */ |
1250ac6d JFM |
719 | break; |
720 | default: | |
721 | data += 1; | |
722 | len -= 1; | |
76dd272b | 723 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
1250ac6d | 724 | break; |
6a7eba24 | 725 | } |
6a7eba24 JFM |
726 | } |
727 | ||
2aed6c1b | 728 | static int sd_s_ctrl(struct v4l2_ctrl *ctrl) |
6a7eba24 | 729 | { |
2aed6c1b HV |
730 | struct gspca_dev *gspca_dev = |
731 | container_of(ctrl->handler, struct gspca_dev, ctrl_handler); | |
6a7eba24 | 732 | |
2aed6c1b HV |
733 | gspca_dev->usb_err = 0; |
734 | ||
735 | if (!gspca_dev->streaming) | |
736 | return 0; | |
737 | ||
738 | switch (ctrl->id) { | |
739 | case V4L2_CID_BRIGHTNESS: | |
740 | setbrightness(gspca_dev, ctrl->val); | |
741 | break; | |
742 | } | |
743 | return gspca_dev->usb_err; | |
6a7eba24 JFM |
744 | } |
745 | ||
2aed6c1b HV |
746 | static const struct v4l2_ctrl_ops sd_ctrl_ops = { |
747 | .s_ctrl = sd_s_ctrl, | |
748 | }; | |
749 | ||
750 | static int sd_init_controls(struct gspca_dev *gspca_dev) | |
6a7eba24 | 751 | { |
2aed6c1b | 752 | struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; |
6a7eba24 | 753 | |
2aed6c1b HV |
754 | gspca_dev->vdev.ctrl_handler = hdl; |
755 | v4l2_ctrl_handler_init(hdl, 5); | |
756 | v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, | |
757 | V4L2_CID_BRIGHTNESS, 0, 255, 1, 127); | |
758 | ||
759 | if (hdl->error) { | |
760 | pr_err("Could not initialize controls\n"); | |
761 | return hdl->error; | |
762 | } | |
6a7eba24 JFM |
763 | return 0; |
764 | } | |
765 | ||
766 | /* sub-driver description */ | |
a5ae2062 | 767 | static const struct sd_desc sd_desc = { |
6a7eba24 | 768 | .name = MODULE_NAME, |
6a7eba24 | 769 | .config = sd_config, |
2aed6c1b | 770 | .init_controls = sd_init_controls, |
012d6b02 | 771 | .init = sd_init, |
6a7eba24 JFM |
772 | .start = sd_start, |
773 | .stopN = sd_stopN, | |
774 | .stop0 = sd_stop0, | |
6a7eba24 JFM |
775 | .pkt_scan = sd_pkt_scan, |
776 | }; | |
777 | ||
778 | /* -- module initialisation -- */ | |
95c967c1 | 779 | static const struct usb_device_id device_table[] = { |
87581aa5 JFM |
780 | {USB_DEVICE(0x041e, 0x401d), .driver_info = Nxultra}, |
781 | {USB_DEVICE(0x0733, 0x0430), .driver_info = IntelPCCameraPro}, | |
9d64fdb1 | 782 | /*fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */ |
6a7eba24 JFM |
783 | {} |
784 | }; | |
785 | MODULE_DEVICE_TABLE(usb, device_table); | |
786 | ||
787 | /* -- device connect -- */ | |
788 | static int sd_probe(struct usb_interface *intf, | |
789 | const struct usb_device_id *id) | |
790 | { | |
956e42d2 | 791 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
6a7eba24 JFM |
792 | THIS_MODULE); |
793 | } | |
794 | ||
795 | static struct usb_driver sd_driver = { | |
796 | .name = MODULE_NAME, | |
797 | .id_table = device_table, | |
798 | .probe = sd_probe, | |
799 | .disconnect = gspca_disconnect, | |
6a709749 JFM |
800 | #ifdef CONFIG_PM |
801 | .suspend = gspca_suspend, | |
802 | .resume = gspca_resume, | |
8bb58964 | 803 | .reset_resume = gspca_resume, |
6a709749 | 804 | #endif |
6a7eba24 JFM |
805 | }; |
806 | ||
ecb3b2b3 | 807 | module_usb_driver(sd_driver); |