1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * SPCA506 chip based cameras function
4 * M Xhaard 15/04/2004 based on different work Mark Taylor and others
5 * and my own snoopy file on a pv-321c donate by a german compagny
6 * "Firma Frank Gmbh" from Saarbruecken
8 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
11 #define MODULE_NAME "spca506"
15 MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
16 MODULE_DESCRIPTION("GSPCA/SPCA506 USB Camera Driver");
17 MODULE_LICENSE("GPL");
19 /* specific webcam descriptor */
21 struct gspca_dev gspca_dev; /* !! must be the first item */
27 static const struct v4l2_pix_format vga_mode[] = {
28 {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
30 .sizeimage = 160 * 120 * 3 / 2,
31 .colorspace = V4L2_COLORSPACE_SRGB,
33 {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
35 .sizeimage = 176 * 144 * 3 / 2,
36 .colorspace = V4L2_COLORSPACE_SRGB,
38 {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
40 .sizeimage = 320 * 240 * 3 / 2,
41 .colorspace = V4L2_COLORSPACE_SRGB,
43 {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
45 .sizeimage = 352 * 288 * 3 / 2,
46 .colorspace = V4L2_COLORSPACE_SRGB,
48 {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
50 .sizeimage = 640 * 480 * 3 / 2,
51 .colorspace = V4L2_COLORSPACE_SRGB,
55 #define SPCA50X_OFFSET_DATA 10
57 #define SAA7113_bright 0x0a /* defaults 0x80 */
58 #define SAA7113_contrast 0x0b /* defaults 0x47 */
59 #define SAA7113_saturation 0x0c /* defaults 0x40 */
60 #define SAA7113_hue 0x0d /* defaults 0x00 */
61 #define SAA7113_I2C_BASE_WRITE 0x4a
63 /* read 'len' bytes to gspca_dev->usb_buf */
64 static void reg_r(struct gspca_dev *gspca_dev,
69 usb_control_msg(gspca_dev->dev,
70 usb_rcvctrlpipe(gspca_dev->dev, 0),
72 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
74 index, gspca_dev->usb_buf, length,
78 static void reg_w(struct usb_device *dev,
84 usb_sndctrlpipe(dev, 0),
86 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
91 static void spca506_Initi2c(struct gspca_dev *gspca_dev)
93 reg_w(gspca_dev->dev, 0x07, SAA7113_I2C_BASE_WRITE, 0x0004);
96 static void spca506_WriteI2c(struct gspca_dev *gspca_dev, __u16 valeur,
101 reg_w(gspca_dev->dev, 0x07, reg, 0x0001);
102 reg_w(gspca_dev->dev, 0x07, valeur, 0x0000);
104 reg_r(gspca_dev, 0x07, 0x0003, 2);
105 if ((gspca_dev->usb_buf[0] | gspca_dev->usb_buf[1]) == 0x00)
110 static void spca506_SetNormeInput(struct gspca_dev *gspca_dev,
114 struct sd *sd = (struct sd *) gspca_dev;
115 /* fixme: check if channel == 0..3 and 6..9 (8 values) */
118 __u8 videomask = 0x00;
120 gspca_dbg(gspca_dev, D_STREAM, "** Open Set Norme **\n");
121 spca506_Initi2c(gspca_dev);
122 /* NTSC bit0 -> 1(525 l) PAL SECAM bit0 -> 0 (625 l) */
123 /* Composite channel bit1 -> 1 S-video bit 1 -> 0 */
124 /* and exclude SAA7113 reserved channel set default 0 otherwise */
125 if (norme & V4L2_STD_NTSC)
127 if (channel == 4 || channel == 5 || channel > 9)
131 videomask = (0x48 | setbit0 | setbit1);
132 reg_w(gspca_dev->dev, 0x08, videomask, 0x0000);
133 spca506_WriteI2c(gspca_dev, (0xc0 | (channel & 0x0F)), 0x02);
135 if (norme & V4L2_STD_NTSC)
136 spca506_WriteI2c(gspca_dev, 0x33, 0x0e);
137 /* Chrominance Control NTSC N */
138 else if (norme & V4L2_STD_SECAM)
139 spca506_WriteI2c(gspca_dev, 0x53, 0x0e);
140 /* Chrominance Control SECAM */
142 spca506_WriteI2c(gspca_dev, 0x03, 0x0e);
143 /* Chrominance Control PAL BGHIV */
146 sd->channel = channel;
147 gspca_dbg(gspca_dev, D_STREAM, "Set Video Byte to 0x%2x\n", videomask);
148 gspca_dbg(gspca_dev, D_STREAM, "Set Norme: %08x Channel %d",
152 static void spca506_GetNormeInput(struct gspca_dev *gspca_dev,
153 __u16 *norme, __u16 *channel)
155 struct sd *sd = (struct sd *) gspca_dev;
157 /* Read the register is not so good value change so
158 we use your own copy in spca50x struct */
160 *channel = sd->channel;
161 gspca_dbg(gspca_dev, D_STREAM, "Get Norme: %d Channel %d\n",
165 static void spca506_Setsize(struct gspca_dev *gspca_dev, __u16 code,
166 __u16 xmult, __u16 ymult)
168 struct usb_device *dev = gspca_dev->dev;
170 gspca_dbg(gspca_dev, D_STREAM, "** SetSize **\n");
171 reg_w(dev, 0x04, (0x18 | (code & 0x07)), 0x0000);
172 /* Soft snap 0x40 Hard 0x41 */
173 reg_w(dev, 0x04, 0x41, 0x0001);
174 reg_w(dev, 0x04, 0x00, 0x0002);
176 reg_w(dev, 0x04, 0x00, 0x0003);
179 reg_w(dev, 0x04, 0x00, 0x0004);
181 reg_w(dev, 0x04, 0x01, 0x0005);
183 reg_w(dev, 0x04, xmult, 0x0006);
185 reg_w(dev, 0x04, ymult, 0x0007);
187 reg_w(dev, 0x04, 0x00, 0x0008);
189 reg_w(dev, 0x04, 0x00, 0x0009);
191 reg_w(dev, 0x04, 0x21, 0x000a);
193 reg_w(dev, 0x04, 0x00, 0x000b);
196 /* this function is called at probe time */
197 static int sd_config(struct gspca_dev *gspca_dev,
198 const struct usb_device_id *id)
202 cam = &gspca_dev->cam;
203 cam->cam_mode = vga_mode;
204 cam->nmodes = ARRAY_SIZE(vga_mode);
208 /* this function is called at probe and resume time */
209 static int sd_init(struct gspca_dev *gspca_dev)
211 struct usb_device *dev = gspca_dev->dev;
213 reg_w(dev, 0x03, 0x00, 0x0004);
214 reg_w(dev, 0x03, 0xFF, 0x0003);
215 reg_w(dev, 0x03, 0x00, 0x0000);
216 reg_w(dev, 0x03, 0x1c, 0x0001);
217 reg_w(dev, 0x03, 0x18, 0x0001);
218 /* Init on PAL and composite input0 */
219 spca506_SetNormeInput(gspca_dev, 0, 0);
220 reg_w(dev, 0x03, 0x1c, 0x0001);
221 reg_w(dev, 0x03, 0x18, 0x0001);
222 reg_w(dev, 0x05, 0x00, 0x0000);
223 reg_w(dev, 0x05, 0xef, 0x0001);
224 reg_w(dev, 0x05, 0x00, 0x00c1);
225 reg_w(dev, 0x05, 0x00, 0x00c2);
226 reg_w(dev, 0x06, 0x18, 0x0002);
227 reg_w(dev, 0x06, 0xf5, 0x0011);
228 reg_w(dev, 0x06, 0x02, 0x0012);
229 reg_w(dev, 0x06, 0xfb, 0x0013);
230 reg_w(dev, 0x06, 0x00, 0x0014);
231 reg_w(dev, 0x06, 0xa4, 0x0051);
232 reg_w(dev, 0x06, 0x40, 0x0052);
233 reg_w(dev, 0x06, 0x71, 0x0053);
234 reg_w(dev, 0x06, 0x40, 0x0054);
235 /************************************************/
236 reg_w(dev, 0x03, 0x00, 0x0004);
237 reg_w(dev, 0x03, 0x00, 0x0003);
238 reg_w(dev, 0x03, 0x00, 0x0004);
239 reg_w(dev, 0x03, 0xFF, 0x0003);
240 reg_w(dev, 0x02, 0x00, 0x0000);
241 reg_w(dev, 0x03, 0x60, 0x0000);
242 reg_w(dev, 0x03, 0x18, 0x0001);
243 /* for a better reading mx :) */
244 /*sdca506_WriteI2c(value,register) */
245 spca506_Initi2c(gspca_dev);
246 spca506_WriteI2c(gspca_dev, 0x08, 0x01);
247 spca506_WriteI2c(gspca_dev, 0xc0, 0x02);
248 /* input composite video */
249 spca506_WriteI2c(gspca_dev, 0x33, 0x03);
250 spca506_WriteI2c(gspca_dev, 0x00, 0x04);
251 spca506_WriteI2c(gspca_dev, 0x00, 0x05);
252 spca506_WriteI2c(gspca_dev, 0x0d, 0x06);
253 spca506_WriteI2c(gspca_dev, 0xf0, 0x07);
254 spca506_WriteI2c(gspca_dev, 0x98, 0x08);
255 spca506_WriteI2c(gspca_dev, 0x03, 0x09);
256 spca506_WriteI2c(gspca_dev, 0x80, 0x0a);
257 spca506_WriteI2c(gspca_dev, 0x47, 0x0b);
258 spca506_WriteI2c(gspca_dev, 0x48, 0x0c);
259 spca506_WriteI2c(gspca_dev, 0x00, 0x0d);
260 spca506_WriteI2c(gspca_dev, 0x03, 0x0e); /* Chroma Pal adjust */
261 spca506_WriteI2c(gspca_dev, 0x2a, 0x0f);
262 spca506_WriteI2c(gspca_dev, 0x00, 0x10);
263 spca506_WriteI2c(gspca_dev, 0x0c, 0x11);
264 spca506_WriteI2c(gspca_dev, 0xb8, 0x12);
265 spca506_WriteI2c(gspca_dev, 0x01, 0x13);
266 spca506_WriteI2c(gspca_dev, 0x00, 0x14);
267 spca506_WriteI2c(gspca_dev, 0x00, 0x15);
268 spca506_WriteI2c(gspca_dev, 0x00, 0x16);
269 spca506_WriteI2c(gspca_dev, 0x00, 0x17);
270 spca506_WriteI2c(gspca_dev, 0x00, 0x18);
271 spca506_WriteI2c(gspca_dev, 0x00, 0x19);
272 spca506_WriteI2c(gspca_dev, 0x00, 0x1a);
273 spca506_WriteI2c(gspca_dev, 0x00, 0x1b);
274 spca506_WriteI2c(gspca_dev, 0x00, 0x1c);
275 spca506_WriteI2c(gspca_dev, 0x00, 0x1d);
276 spca506_WriteI2c(gspca_dev, 0x00, 0x1e);
277 spca506_WriteI2c(gspca_dev, 0xa1, 0x1f);
278 spca506_WriteI2c(gspca_dev, 0x02, 0x40);
279 spca506_WriteI2c(gspca_dev, 0xff, 0x41);
280 spca506_WriteI2c(gspca_dev, 0xff, 0x42);
281 spca506_WriteI2c(gspca_dev, 0xff, 0x43);
282 spca506_WriteI2c(gspca_dev, 0xff, 0x44);
283 spca506_WriteI2c(gspca_dev, 0xff, 0x45);
284 spca506_WriteI2c(gspca_dev, 0xff, 0x46);
285 spca506_WriteI2c(gspca_dev, 0xff, 0x47);
286 spca506_WriteI2c(gspca_dev, 0xff, 0x48);
287 spca506_WriteI2c(gspca_dev, 0xff, 0x49);
288 spca506_WriteI2c(gspca_dev, 0xff, 0x4a);
289 spca506_WriteI2c(gspca_dev, 0xff, 0x4b);
290 spca506_WriteI2c(gspca_dev, 0xff, 0x4c);
291 spca506_WriteI2c(gspca_dev, 0xff, 0x4d);
292 spca506_WriteI2c(gspca_dev, 0xff, 0x4e);
293 spca506_WriteI2c(gspca_dev, 0xff, 0x4f);
294 spca506_WriteI2c(gspca_dev, 0xff, 0x50);
295 spca506_WriteI2c(gspca_dev, 0xff, 0x51);
296 spca506_WriteI2c(gspca_dev, 0xff, 0x52);
297 spca506_WriteI2c(gspca_dev, 0xff, 0x53);
298 spca506_WriteI2c(gspca_dev, 0xff, 0x54);
299 spca506_WriteI2c(gspca_dev, 0xff, 0x55);
300 spca506_WriteI2c(gspca_dev, 0xff, 0x56);
301 spca506_WriteI2c(gspca_dev, 0xff, 0x57);
302 spca506_WriteI2c(gspca_dev, 0x00, 0x58);
303 spca506_WriteI2c(gspca_dev, 0x54, 0x59);
304 spca506_WriteI2c(gspca_dev, 0x07, 0x5a);
305 spca506_WriteI2c(gspca_dev, 0x83, 0x5b);
306 spca506_WriteI2c(gspca_dev, 0x00, 0x5c);
307 spca506_WriteI2c(gspca_dev, 0x00, 0x5d);
308 spca506_WriteI2c(gspca_dev, 0x00, 0x5e);
309 spca506_WriteI2c(gspca_dev, 0x00, 0x5f);
310 spca506_WriteI2c(gspca_dev, 0x00, 0x60);
311 spca506_WriteI2c(gspca_dev, 0x05, 0x61);
312 spca506_WriteI2c(gspca_dev, 0x9f, 0x62);
313 gspca_dbg(gspca_dev, D_STREAM, "** Close Init *\n");
317 static int sd_start(struct gspca_dev *gspca_dev)
319 struct usb_device *dev = gspca_dev->dev;
323 /**************************************/
324 reg_w(dev, 0x03, 0x00, 0x0004);
325 reg_w(dev, 0x03, 0x00, 0x0003);
326 reg_w(dev, 0x03, 0x00, 0x0004);
327 reg_w(dev, 0x03, 0xFF, 0x0003);
328 reg_w(dev, 0x02, 0x00, 0x0000);
329 reg_w(dev, 0x03, 0x60, 0x0000);
330 reg_w(dev, 0x03, 0x18, 0x0001);
332 /*sdca506_WriteI2c(value,register) */
333 spca506_Initi2c(gspca_dev);
334 spca506_WriteI2c(gspca_dev, 0x08, 0x01); /* Increment Delay */
335 /* spca506_WriteI2c(gspca_dev, 0xc0, 0x02); * Analog Input Control 1 */
336 spca506_WriteI2c(gspca_dev, 0x33, 0x03);
337 /* Analog Input Control 2 */
338 spca506_WriteI2c(gspca_dev, 0x00, 0x04);
339 /* Analog Input Control 3 */
340 spca506_WriteI2c(gspca_dev, 0x00, 0x05);
341 /* Analog Input Control 4 */
342 spca506_WriteI2c(gspca_dev, 0x0d, 0x06);
343 /* Horizontal Sync Start 0xe9-0x0d */
344 spca506_WriteI2c(gspca_dev, 0xf0, 0x07);
345 /* Horizontal Sync Stop 0x0d-0xf0 */
347 spca506_WriteI2c(gspca_dev, 0x98, 0x08); /* Sync Control */
349 spca506_WriteI2c(gspca_dev, 0x03, 0x09); /* Luminance Control */
350 spca506_WriteI2c(gspca_dev, 0x80, 0x0a);
351 /* Luminance Brightness */
352 spca506_WriteI2c(gspca_dev, 0x47, 0x0b); /* Luminance Contrast */
353 spca506_WriteI2c(gspca_dev, 0x48, 0x0c);
354 /* Chrominance Saturation */
355 spca506_WriteI2c(gspca_dev, 0x00, 0x0d);
356 /* Chrominance Hue Control */
357 spca506_WriteI2c(gspca_dev, 0x2a, 0x0f);
358 /* Chrominance Gain Control */
359 /**************************************/
360 spca506_WriteI2c(gspca_dev, 0x00, 0x10);
361 /* Format/Delay Control */
362 spca506_WriteI2c(gspca_dev, 0x0c, 0x11); /* Output Control 1 */
363 spca506_WriteI2c(gspca_dev, 0xb8, 0x12); /* Output Control 2 */
364 spca506_WriteI2c(gspca_dev, 0x01, 0x13); /* Output Control 3 */
365 spca506_WriteI2c(gspca_dev, 0x00, 0x14); /* reserved */
366 spca506_WriteI2c(gspca_dev, 0x00, 0x15); /* VGATE START */
367 spca506_WriteI2c(gspca_dev, 0x00, 0x16); /* VGATE STOP */
368 spca506_WriteI2c(gspca_dev, 0x00, 0x17); /* VGATE Control (MSB) */
369 spca506_WriteI2c(gspca_dev, 0x00, 0x18);
370 spca506_WriteI2c(gspca_dev, 0x00, 0x19);
371 spca506_WriteI2c(gspca_dev, 0x00, 0x1a);
372 spca506_WriteI2c(gspca_dev, 0x00, 0x1b);
373 spca506_WriteI2c(gspca_dev, 0x00, 0x1c);
374 spca506_WriteI2c(gspca_dev, 0x00, 0x1d);
375 spca506_WriteI2c(gspca_dev, 0x00, 0x1e);
376 spca506_WriteI2c(gspca_dev, 0xa1, 0x1f);
377 spca506_WriteI2c(gspca_dev, 0x02, 0x40);
378 spca506_WriteI2c(gspca_dev, 0xff, 0x41);
379 spca506_WriteI2c(gspca_dev, 0xff, 0x42);
380 spca506_WriteI2c(gspca_dev, 0xff, 0x43);
381 spca506_WriteI2c(gspca_dev, 0xff, 0x44);
382 spca506_WriteI2c(gspca_dev, 0xff, 0x45);
383 spca506_WriteI2c(gspca_dev, 0xff, 0x46);
384 spca506_WriteI2c(gspca_dev, 0xff, 0x47);
385 spca506_WriteI2c(gspca_dev, 0xff, 0x48);
386 spca506_WriteI2c(gspca_dev, 0xff, 0x49);
387 spca506_WriteI2c(gspca_dev, 0xff, 0x4a);
388 spca506_WriteI2c(gspca_dev, 0xff, 0x4b);
389 spca506_WriteI2c(gspca_dev, 0xff, 0x4c);
390 spca506_WriteI2c(gspca_dev, 0xff, 0x4d);
391 spca506_WriteI2c(gspca_dev, 0xff, 0x4e);
392 spca506_WriteI2c(gspca_dev, 0xff, 0x4f);
393 spca506_WriteI2c(gspca_dev, 0xff, 0x50);
394 spca506_WriteI2c(gspca_dev, 0xff, 0x51);
395 spca506_WriteI2c(gspca_dev, 0xff, 0x52);
396 spca506_WriteI2c(gspca_dev, 0xff, 0x53);
397 spca506_WriteI2c(gspca_dev, 0xff, 0x54);
398 spca506_WriteI2c(gspca_dev, 0xff, 0x55);
399 spca506_WriteI2c(gspca_dev, 0xff, 0x56);
400 spca506_WriteI2c(gspca_dev, 0xff, 0x57);
401 spca506_WriteI2c(gspca_dev, 0x00, 0x58);
402 spca506_WriteI2c(gspca_dev, 0x54, 0x59);
403 spca506_WriteI2c(gspca_dev, 0x07, 0x5a);
404 spca506_WriteI2c(gspca_dev, 0x83, 0x5b);
405 spca506_WriteI2c(gspca_dev, 0x00, 0x5c);
406 spca506_WriteI2c(gspca_dev, 0x00, 0x5d);
407 spca506_WriteI2c(gspca_dev, 0x00, 0x5e);
408 spca506_WriteI2c(gspca_dev, 0x00, 0x5f);
409 spca506_WriteI2c(gspca_dev, 0x00, 0x60);
410 spca506_WriteI2c(gspca_dev, 0x05, 0x61);
411 spca506_WriteI2c(gspca_dev, 0x9f, 0x62);
412 /**************************************/
413 reg_w(dev, 0x05, 0x00, 0x0003);
414 reg_w(dev, 0x05, 0x00, 0x0004);
415 reg_w(dev, 0x03, 0x10, 0x0001);
416 reg_w(dev, 0x03, 0x78, 0x0000);
417 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) {
419 spca506_Setsize(gspca_dev, 0, 0x10, 0x10);
422 spca506_Setsize(gspca_dev, 1, 0x1a, 0x1a);
425 spca506_Setsize(gspca_dev, 2, 0x1c, 0x1c);
428 spca506_Setsize(gspca_dev, 4, 0x34, 0x34);
432 spca506_Setsize(gspca_dev, 5, 0x40, 0x40);
436 /* compress setting and size */
438 reg_w(dev, 0x02, 0x01, 0x0000);
439 reg_w(dev, 0x03, 0x12, 0x0000);
440 reg_r(gspca_dev, 0x04, 0x0001, 2);
441 gspca_dbg(gspca_dev, D_STREAM, "webcam started\n");
442 spca506_GetNormeInput(gspca_dev, &norme, &channel);
443 spca506_SetNormeInput(gspca_dev, norme, channel);
447 static void sd_stopN(struct gspca_dev *gspca_dev)
449 struct usb_device *dev = gspca_dev->dev;
451 reg_w(dev, 0x02, 0x00, 0x0000);
452 reg_w(dev, 0x03, 0x00, 0x0004);
453 reg_w(dev, 0x03, 0x00, 0x0003);
456 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
457 u8 *data, /* isoc packet */
458 int len) /* iso packet length */
461 case 0: /* start of frame */
462 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
463 data += SPCA50X_OFFSET_DATA;
464 len -= SPCA50X_OFFSET_DATA;
465 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
467 case 0xff: /* drop */
468 /* gspca_dev->last_packet_type = DISCARD_PACKET; */
473 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
478 static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
480 spca506_Initi2c(gspca_dev);
481 spca506_WriteI2c(gspca_dev, val, SAA7113_bright);
482 spca506_WriteI2c(gspca_dev, 0x01, 0x09);
485 static void setcontrast(struct gspca_dev *gspca_dev, s32 val)
487 spca506_Initi2c(gspca_dev);
488 spca506_WriteI2c(gspca_dev, val, SAA7113_contrast);
489 spca506_WriteI2c(gspca_dev, 0x01, 0x09);
492 static void setcolors(struct gspca_dev *gspca_dev, s32 val)
494 spca506_Initi2c(gspca_dev);
495 spca506_WriteI2c(gspca_dev, val, SAA7113_saturation);
496 spca506_WriteI2c(gspca_dev, 0x01, 0x09);
499 static void sethue(struct gspca_dev *gspca_dev, s32 val)
501 spca506_Initi2c(gspca_dev);
502 spca506_WriteI2c(gspca_dev, val, SAA7113_hue);
503 spca506_WriteI2c(gspca_dev, 0x01, 0x09);
506 static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
508 struct gspca_dev *gspca_dev =
509 container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
511 gspca_dev->usb_err = 0;
513 if (!gspca_dev->streaming)
517 case V4L2_CID_BRIGHTNESS:
518 setbrightness(gspca_dev, ctrl->val);
520 case V4L2_CID_CONTRAST:
521 setcontrast(gspca_dev, ctrl->val);
523 case V4L2_CID_SATURATION:
524 setcolors(gspca_dev, ctrl->val);
527 sethue(gspca_dev, ctrl->val);
530 return gspca_dev->usb_err;
533 static const struct v4l2_ctrl_ops sd_ctrl_ops = {
537 static int sd_init_controls(struct gspca_dev *gspca_dev)
539 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
541 gspca_dev->vdev.ctrl_handler = hdl;
542 v4l2_ctrl_handler_init(hdl, 4);
543 v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
544 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
545 v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
546 V4L2_CID_CONTRAST, 0, 255, 1, 0x47);
547 v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
548 V4L2_CID_SATURATION, 0, 255, 1, 0x40);
549 v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
550 V4L2_CID_HUE, 0, 255, 1, 0);
553 pr_err("Could not initialize controls\n");
559 /* sub-driver description */
560 static const struct sd_desc sd_desc = {
564 .init_controls = sd_init_controls,
567 .pkt_scan = sd_pkt_scan,
570 /* -- module initialisation -- */
571 static const struct usb_device_id device_table[] = {
572 {USB_DEVICE(0x06e1, 0xa190)},
573 /* {USB_DEVICE(0x0733, 0x0430)}, FIXME: may be IntelPCCameraPro BRIDGE_SPCA505 */
574 {USB_DEVICE(0x0734, 0x043b)},
575 {USB_DEVICE(0x99fa, 0x8988)},
578 MODULE_DEVICE_TABLE(usb, device_table);
580 /* -- device connect -- */
581 static int sd_probe(struct usb_interface *intf, const struct usb_device_id *id)
583 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
587 static struct usb_driver sd_driver = {
589 .id_table = device_table,
591 .disconnect = gspca_disconnect,
593 .suspend = gspca_suspend,
594 .resume = gspca_resume,
595 .reset_resume = gspca_resume,
599 module_usb_driver(sd_driver);