4 * Copyright (C) 2009 Theodore Kilgore <kilgota@auburn.edu>
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
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.
17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19 #define MODULE_NAME "sn9c2028"
23 MODULE_AUTHOR("Theodore Kilgore");
24 MODULE_DESCRIPTION("Sonix SN9C2028 USB Camera Driver");
25 MODULE_LICENSE("GPL");
27 /* specific webcam descriptor */
29 struct gspca_dev gspca_dev; /* !! must be the first item */
33 #define MIN_AVG_LUM 8500
34 #define MAX_AVG_LUM 10000
38 struct { /* autogain and gain control cluster */
39 struct v4l2_ctrl *autogain;
40 struct v4l2_ctrl *gain;
45 unsigned char instruction[6];
46 unsigned char to_read; /* length to read. 0 means no reply requested */
49 /* How to change the resolution of any of the VGA cams is unknown */
50 static const struct v4l2_pix_format vga_mode[] = {
51 {640, 480, V4L2_PIX_FMT_SN9C2028, V4L2_FIELD_NONE,
53 .sizeimage = 640 * 480 * 3 / 4,
54 .colorspace = V4L2_COLORSPACE_SRGB,
58 /* No way to change the resolution of the CIF cams is known */
59 static const struct v4l2_pix_format cif_mode[] = {
60 {352, 288, V4L2_PIX_FMT_SN9C2028, V4L2_FIELD_NONE,
62 .sizeimage = 352 * 288 * 3 / 4,
63 .colorspace = V4L2_COLORSPACE_SRGB,
67 /* the bytes to write are in gspca_dev->usb_buf */
68 static int sn9c2028_command(struct gspca_dev *gspca_dev, u8 *command)
72 gspca_dbg(gspca_dev, D_USBO, "sending command %02x%02x%02x%02x%02x%02x\n",
73 command[0], command[1], command[2],
74 command[3], command[4], command[5]);
76 memcpy(gspca_dev->usb_buf, command, 6);
77 rc = usb_control_msg(gspca_dev->dev,
78 usb_sndctrlpipe(gspca_dev->dev, 0),
79 USB_REQ_GET_CONFIGURATION,
80 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
81 2, 0, gspca_dev->usb_buf, 6, 500);
83 pr_err("command write [%02x] error %d\n",
84 gspca_dev->usb_buf[0], rc);
91 static int sn9c2028_read1(struct gspca_dev *gspca_dev)
95 rc = usb_control_msg(gspca_dev->dev,
96 usb_rcvctrlpipe(gspca_dev->dev, 0),
98 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
99 1, 0, gspca_dev->usb_buf, 1, 500);
101 pr_err("read1 error %d\n", rc);
102 return (rc < 0) ? rc : -EIO;
104 gspca_dbg(gspca_dev, D_USBI, "read1 response %02x\n",
105 gspca_dev->usb_buf[0]);
106 return gspca_dev->usb_buf[0];
109 static int sn9c2028_read4(struct gspca_dev *gspca_dev, u8 *reading)
112 rc = usb_control_msg(gspca_dev->dev,
113 usb_rcvctrlpipe(gspca_dev->dev, 0),
115 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
116 4, 0, gspca_dev->usb_buf, 4, 500);
118 pr_err("read4 error %d\n", rc);
119 return (rc < 0) ? rc : -EIO;
121 memcpy(reading, gspca_dev->usb_buf, 4);
122 gspca_dbg(gspca_dev, D_USBI, "read4 response %02x%02x%02x%02x\n",
123 reading[0], reading[1], reading[2], reading[3]);
127 static int sn9c2028_long_command(struct gspca_dev *gspca_dev, u8 *command)
132 status = sn9c2028_command(gspca_dev, command);
137 for (i = 0; i < 256 && status < 2; i++)
138 status = sn9c2028_read1(gspca_dev);
140 pr_err("long command status read error %d\n", status);
144 memset(reading, 0, 4);
145 status = sn9c2028_read4(gspca_dev, reading);
149 /* in general, the first byte of the response is the first byte of
150 * the command, or'ed with 8 */
151 status = sn9c2028_read1(gspca_dev);
158 static int sn9c2028_short_command(struct gspca_dev *gspca_dev, u8 *command)
162 err_code = sn9c2028_command(gspca_dev, command);
166 err_code = sn9c2028_read1(gspca_dev);
173 /* this function is called at probe time */
174 static int sd_config(struct gspca_dev *gspca_dev,
175 const struct usb_device_id *id)
177 struct sd *sd = (struct sd *) gspca_dev;
178 struct cam *cam = &gspca_dev->cam;
180 gspca_dbg(gspca_dev, D_PROBE, "SN9C2028 camera detected (vid/pid 0x%04X:0x%04X)\n",
181 id->idVendor, id->idProduct);
183 sd->model = id->idProduct;
187 gspca_dbg(gspca_dev, D_PROBE, "Genius Smart 300 camera\n");
190 gspca_dbg(gspca_dev, D_PROBE, "Genius Videocam Live v2\n");
193 gspca_dbg(gspca_dev, D_PROBE, "DC31VC\n");
196 gspca_dbg(gspca_dev, D_PROBE, "Spy camera\n");
199 gspca_dbg(gspca_dev, D_PROBE, "CIF camera\n");
202 gspca_dbg(gspca_dev, D_PROBE, "Mini-Shotz ms-350 camera\n");
205 gspca_dbg(gspca_dev, D_PROBE, "Vivitar 3350b type camera\n");
206 cam->input_flags = V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
214 cam->cam_mode = cif_mode;
215 cam->nmodes = ARRAY_SIZE(cif_mode);
218 cam->cam_mode = vga_mode;
219 cam->nmodes = ARRAY_SIZE(vga_mode);
224 /* this function is called at probe and resume time */
225 static int sd_init(struct gspca_dev *gspca_dev)
229 sn9c2028_read1(gspca_dev);
230 sn9c2028_read1(gspca_dev);
231 status = sn9c2028_read1(gspca_dev);
233 return (status < 0) ? status : 0;
236 static int run_start_commands(struct gspca_dev *gspca_dev,
237 struct init_command *cam_commands, int n)
239 int i, err_code = -1;
241 for (i = 0; i < n; i++) {
242 switch (cam_commands[i].to_read) {
244 err_code = sn9c2028_long_command(gspca_dev,
245 cam_commands[i].instruction);
248 err_code = sn9c2028_short_command(gspca_dev,
249 cam_commands[i].instruction);
252 err_code = sn9c2028_command(gspca_dev,
253 cam_commands[i].instruction);
262 static void set_gain(struct gspca_dev *gspca_dev, s32 g)
264 struct sd *sd = (struct sd *) gspca_dev;
266 struct init_command genius_vcam_live_gain_cmds[] = {
267 {{0x1d, 0x25, 0x10 /* This byte is gain */,
268 0x20, 0xab, 0x00}, 0},
270 if (!gspca_dev->streaming)
275 genius_vcam_live_gain_cmds[0].instruction[2] = g;
276 run_start_commands(gspca_dev, genius_vcam_live_gain_cmds,
277 ARRAY_SIZE(genius_vcam_live_gain_cmds));
284 static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
286 struct gspca_dev *gspca_dev =
287 container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
288 struct sd *sd = (struct sd *)gspca_dev;
290 gspca_dev->usb_err = 0;
292 if (!gspca_dev->streaming)
296 /* standalone gain control */
298 set_gain(gspca_dev, ctrl->val);
301 case V4L2_CID_AUTOGAIN:
302 set_gain(gspca_dev, sd->gain->val);
305 return gspca_dev->usb_err;
308 static const struct v4l2_ctrl_ops sd_ctrl_ops = {
313 static int sd_init_controls(struct gspca_dev *gspca_dev)
315 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
316 struct sd *sd = (struct sd *)gspca_dev;
318 gspca_dev->vdev.ctrl_handler = hdl;
319 v4l2_ctrl_handler_init(hdl, 2);
323 sd->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
324 V4L2_CID_GAIN, 0, 20, 1, 0);
325 sd->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
326 V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
334 static int start_spy_cam(struct gspca_dev *gspca_dev)
336 struct init_command spy_start_commands[] = {
337 {{0x0c, 0x01, 0x00, 0x00, 0x00, 0x00}, 4},
338 {{0x13, 0x20, 0x01, 0x00, 0x00, 0x00}, 4},
339 {{0x13, 0x21, 0x01, 0x00, 0x00, 0x00}, 4},
340 {{0x13, 0x22, 0x01, 0x04, 0x00, 0x00}, 4},
341 {{0x13, 0x23, 0x01, 0x03, 0x00, 0x00}, 4},
342 {{0x13, 0x24, 0x01, 0x00, 0x00, 0x00}, 4},
343 {{0x13, 0x25, 0x01, 0x16, 0x00, 0x00}, 4}, /* width 352 */
344 {{0x13, 0x26, 0x01, 0x12, 0x00, 0x00}, 4}, /* height 288 */
345 /* {{0x13, 0x27, 0x01, 0x28, 0x00, 0x00}, 4}, */
346 {{0x13, 0x27, 0x01, 0x68, 0x00, 0x00}, 4},
347 {{0x13, 0x28, 0x01, 0x09, 0x00, 0x00}, 4}, /* red gain ?*/
348 /* {{0x13, 0x28, 0x01, 0x00, 0x00, 0x00}, 4}, */
349 {{0x13, 0x29, 0x01, 0x00, 0x00, 0x00}, 4},
350 /* {{0x13, 0x29, 0x01, 0x0c, 0x00, 0x00}, 4}, */
351 {{0x13, 0x2a, 0x01, 0x00, 0x00, 0x00}, 4},
352 {{0x13, 0x2b, 0x01, 0x00, 0x00, 0x00}, 4},
353 /* {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4}, */
354 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
355 {{0x13, 0x2d, 0x01, 0x02, 0x00, 0x00}, 4},
356 /* {{0x13, 0x2e, 0x01, 0x09, 0x00, 0x00}, 4}, */
357 {{0x13, 0x2e, 0x01, 0x09, 0x00, 0x00}, 4},
358 {{0x13, 0x2f, 0x01, 0x07, 0x00, 0x00}, 4},
359 {{0x12, 0x34, 0x01, 0x00, 0x00, 0x00}, 4},
360 {{0x13, 0x34, 0x01, 0xa1, 0x00, 0x00}, 4},
361 {{0x13, 0x35, 0x01, 0x00, 0x00, 0x00}, 4},
362 {{0x11, 0x02, 0x06, 0x00, 0x00, 0x00}, 4},
363 {{0x11, 0x03, 0x13, 0x00, 0x00, 0x00}, 4}, /*don't mess with*/
364 /*{{0x11, 0x04, 0x06, 0x00, 0x00, 0x00}, 4}, observed */
365 {{0x11, 0x04, 0x00, 0x00, 0x00, 0x00}, 4}, /* brighter */
366 /*{{0x11, 0x05, 0x65, 0x00, 0x00, 0x00}, 4}, observed */
367 {{0x11, 0x05, 0x00, 0x00, 0x00, 0x00}, 4}, /* brighter */
368 {{0x11, 0x06, 0xb1, 0x00, 0x00, 0x00}, 4}, /* observed */
369 {{0x11, 0x07, 0x00, 0x00, 0x00, 0x00}, 4},
370 /*{{0x11, 0x08, 0x06, 0x00, 0x00, 0x00}, 4}, observed */
371 {{0x11, 0x08, 0x0b, 0x00, 0x00, 0x00}, 4},
372 {{0x11, 0x09, 0x01, 0x00, 0x00, 0x00}, 4},
373 {{0x11, 0x0a, 0x01, 0x00, 0x00, 0x00}, 4},
374 {{0x11, 0x0b, 0x01, 0x00, 0x00, 0x00}, 4},
375 {{0x11, 0x0c, 0x01, 0x00, 0x00, 0x00}, 4},
376 {{0x11, 0x0d, 0x00, 0x00, 0x00, 0x00}, 4},
377 {{0x11, 0x0e, 0x04, 0x00, 0x00, 0x00}, 4},
378 /* {{0x11, 0x0f, 0x00, 0x00, 0x00, 0x00}, 4}, */
379 /* brightness or gain. 0 is default. 4 is good
380 * indoors at night with incandescent lighting */
381 {{0x11, 0x0f, 0x04, 0x00, 0x00, 0x00}, 4},
382 {{0x11, 0x10, 0x06, 0x00, 0x00, 0x00}, 4}, /*hstart or hoffs*/
383 {{0x11, 0x11, 0x06, 0x00, 0x00, 0x00}, 4},
384 {{0x11, 0x12, 0x00, 0x00, 0x00, 0x00}, 4},
385 {{0x11, 0x14, 0x02, 0x00, 0x00, 0x00}, 4},
386 {{0x11, 0x13, 0x01, 0x00, 0x00, 0x00}, 4},
387 /* {{0x1b, 0x02, 0x06, 0x00, 0x00, 0x00}, 1}, observed */
388 {{0x1b, 0x02, 0x11, 0x00, 0x00, 0x00}, 1}, /* brighter */
389 /* {{0x1b, 0x13, 0x01, 0x00, 0x00, 0x00}, 1}, observed */
390 {{0x1b, 0x13, 0x11, 0x00, 0x00, 0x00}, 1},
391 {{0x20, 0x34, 0xa1, 0x00, 0x00, 0x00}, 1}, /* compresses */
392 /* Camera should start to capture now. */
395 return run_start_commands(gspca_dev, spy_start_commands,
396 ARRAY_SIZE(spy_start_commands));
399 static int start_cif_cam(struct gspca_dev *gspca_dev)
401 struct init_command cif_start_commands[] = {
402 {{0x0c, 0x01, 0x00, 0x00, 0x00, 0x00}, 4},
403 /* The entire sequence below seems redundant */
404 /* {{0x13, 0x20, 0x01, 0x00, 0x00, 0x00}, 4},
405 {{0x13, 0x21, 0x01, 0x00, 0x00, 0x00}, 4},
406 {{0x13, 0x22, 0x01, 0x06, 0x00, 0x00}, 4},
407 {{0x13, 0x23, 0x01, 0x02, 0x00, 0x00}, 4},
408 {{0x13, 0x24, 0x01, 0x00, 0x00, 0x00}, 4},
409 {{0x13, 0x25, 0x01, 0x16, 0x00, 0x00}, 4}, width?
410 {{0x13, 0x26, 0x01, 0x12, 0x00, 0x00}, 4}, height?
411 {{0x13, 0x27, 0x01, 0x68, 0x00, 0x00}, 4}, subsample?
412 {{0x13, 0x28, 0x01, 0x00, 0x00, 0x00}, 4},
413 {{0x13, 0x29, 0x01, 0x20, 0x00, 0x00}, 4},
414 {{0x13, 0x2a, 0x01, 0x00, 0x00, 0x00}, 4},
415 {{0x13, 0x2b, 0x01, 0x00, 0x00, 0x00}, 4},
416 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
417 {{0x13, 0x2d, 0x01, 0x03, 0x00, 0x00}, 4},
418 {{0x13, 0x2e, 0x01, 0x0f, 0x00, 0x00}, 4},
419 {{0x13, 0x2f, 0x01, 0x0c, 0x00, 0x00}, 4},
420 {{0x12, 0x34, 0x01, 0x00, 0x00, 0x00}, 4},
421 {{0x13, 0x34, 0x01, 0xa1, 0x00, 0x00}, 4},
422 {{0x13, 0x35, 0x01, 0x00, 0x00, 0x00}, 4},*/
423 {{0x1b, 0x21, 0x00, 0x00, 0x00, 0x00}, 1},
424 {{0x1b, 0x17, 0x00, 0x00, 0x00, 0x00}, 1},
425 {{0x1b, 0x19, 0x00, 0x00, 0x00, 0x00}, 1},
426 {{0x1b, 0x02, 0x06, 0x00, 0x00, 0x00}, 1},
427 {{0x1b, 0x03, 0x5a, 0x00, 0x00, 0x00}, 1},
428 {{0x1b, 0x04, 0x27, 0x00, 0x00, 0x00}, 1},
429 {{0x1b, 0x05, 0x01, 0x00, 0x00, 0x00}, 1},
430 {{0x1b, 0x12, 0x14, 0x00, 0x00, 0x00}, 1},
431 {{0x1b, 0x13, 0x00, 0x00, 0x00, 0x00}, 1},
432 {{0x1b, 0x14, 0x00, 0x00, 0x00, 0x00}, 1},
433 {{0x1b, 0x15, 0x00, 0x00, 0x00, 0x00}, 1},
434 {{0x1b, 0x16, 0x00, 0x00, 0x00, 0x00}, 1},
435 {{0x1b, 0x77, 0xa2, 0x00, 0x00, 0x00}, 1},
436 {{0x1b, 0x06, 0x0f, 0x00, 0x00, 0x00}, 1},
437 {{0x1b, 0x07, 0x14, 0x00, 0x00, 0x00}, 1},
438 {{0x1b, 0x08, 0x0f, 0x00, 0x00, 0x00}, 1},
439 {{0x1b, 0x09, 0x10, 0x00, 0x00, 0x00}, 1},
440 {{0x1b, 0x0e, 0x00, 0x00, 0x00, 0x00}, 1},
441 {{0x1b, 0x0f, 0x00, 0x00, 0x00, 0x00}, 1},
442 {{0x1b, 0x12, 0x07, 0x00, 0x00, 0x00}, 1},
443 {{0x1b, 0x10, 0x1f, 0x00, 0x00, 0x00}, 1},
444 {{0x1b, 0x11, 0x01, 0x00, 0x00, 0x00}, 1},
445 {{0x13, 0x25, 0x01, 0x16, 0x00, 0x00}, 1}, /* width/8 */
446 {{0x13, 0x26, 0x01, 0x12, 0x00, 0x00}, 1}, /* height/8 */
447 /* {{0x13, 0x27, 0x01, 0x68, 0x00, 0x00}, 4}, subsample?
448 * {{0x13, 0x28, 0x01, 0x1e, 0x00, 0x00}, 4}, does nothing
449 * {{0x13, 0x27, 0x01, 0x20, 0x00, 0x00}, 4}, */
450 /* {{0x13, 0x29, 0x01, 0x22, 0x00, 0x00}, 4},
452 * but not a change in the resolution setting! */
453 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
454 {{0x13, 0x2d, 0x01, 0x01, 0x00, 0x00}, 4},
455 {{0x13, 0x2e, 0x01, 0x08, 0x00, 0x00}, 4},
456 {{0x13, 0x2f, 0x01, 0x06, 0x00, 0x00}, 4},
457 {{0x13, 0x28, 0x01, 0x00, 0x00, 0x00}, 4},
458 {{0x1b, 0x04, 0x6d, 0x00, 0x00, 0x00}, 1},
459 {{0x1b, 0x05, 0x03, 0x00, 0x00, 0x00}, 1},
460 {{0x20, 0x36, 0x06, 0x00, 0x00, 0x00}, 1},
461 {{0x1b, 0x0e, 0x01, 0x00, 0x00, 0x00}, 1},
462 {{0x12, 0x27, 0x01, 0x00, 0x00, 0x00}, 4},
463 {{0x1b, 0x0f, 0x00, 0x00, 0x00, 0x00}, 1},
464 {{0x20, 0x36, 0x05, 0x00, 0x00, 0x00}, 1},
465 {{0x1b, 0x10, 0x0f, 0x00, 0x00, 0x00}, 1},
466 {{0x1b, 0x02, 0x06, 0x00, 0x00, 0x00}, 1},
467 {{0x1b, 0x11, 0x01, 0x00, 0x00, 0x00}, 1},
468 {{0x20, 0x34, 0xa1, 0x00, 0x00, 0x00}, 1},/* use compression */
469 /* Camera should start to capture now. */
472 return run_start_commands(gspca_dev, cif_start_commands,
473 ARRAY_SIZE(cif_start_commands));
476 static int start_ms350_cam(struct gspca_dev *gspca_dev)
478 struct init_command ms350_start_commands[] = {
479 {{0x0c, 0x01, 0x00, 0x00, 0x00, 0x00}, 4},
480 {{0x16, 0x01, 0x00, 0x00, 0x00, 0x00}, 4},
481 {{0x13, 0x20, 0x01, 0x00, 0x00, 0x00}, 4},
482 {{0x13, 0x21, 0x01, 0x00, 0x00, 0x00}, 4},
483 {{0x13, 0x22, 0x01, 0x04, 0x00, 0x00}, 4},
484 {{0x13, 0x23, 0x01, 0x03, 0x00, 0x00}, 4},
485 {{0x13, 0x24, 0x01, 0x00, 0x00, 0x00}, 4},
486 {{0x13, 0x25, 0x01, 0x16, 0x00, 0x00}, 4},
487 {{0x13, 0x26, 0x01, 0x12, 0x00, 0x00}, 4},
488 {{0x13, 0x27, 0x01, 0x28, 0x00, 0x00}, 4},
489 {{0x13, 0x28, 0x01, 0x09, 0x00, 0x00}, 4},
490 {{0x13, 0x29, 0x01, 0x00, 0x00, 0x00}, 4},
491 {{0x13, 0x2a, 0x01, 0x00, 0x00, 0x00}, 4},
492 {{0x13, 0x2b, 0x01, 0x00, 0x00, 0x00}, 4},
493 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
494 {{0x13, 0x2d, 0x01, 0x03, 0x00, 0x00}, 4},
495 {{0x13, 0x2e, 0x01, 0x0f, 0x00, 0x00}, 4},
496 {{0x13, 0x2f, 0x01, 0x0c, 0x00, 0x00}, 4},
497 {{0x12, 0x34, 0x01, 0x00, 0x00, 0x00}, 4},
498 {{0x13, 0x34, 0x01, 0xa1, 0x00, 0x00}, 4},
499 {{0x13, 0x35, 0x01, 0x00, 0x00, 0x00}, 4},
500 {{0x11, 0x00, 0x01, 0x00, 0x00, 0x00}, 4},
501 {{0x11, 0x01, 0x70, 0x00, 0x00, 0x00}, 4},
502 {{0x11, 0x02, 0x05, 0x00, 0x00, 0x00}, 4},
503 {{0x11, 0x03, 0x5d, 0x00, 0x00, 0x00}, 4},
504 {{0x11, 0x04, 0x07, 0x00, 0x00, 0x00}, 4},
505 {{0x11, 0x05, 0x25, 0x00, 0x00, 0x00}, 4},
506 {{0x11, 0x06, 0x00, 0x00, 0x00, 0x00}, 4},
507 {{0x11, 0x07, 0x09, 0x00, 0x00, 0x00}, 4},
508 {{0x11, 0x08, 0x01, 0x00, 0x00, 0x00}, 4},
509 {{0x11, 0x09, 0x00, 0x00, 0x00, 0x00}, 4},
510 {{0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, 4},
511 {{0x11, 0x0b, 0x01, 0x00, 0x00, 0x00}, 4},
512 {{0x11, 0x0c, 0x00, 0x00, 0x00, 0x00}, 4},
513 {{0x11, 0x0d, 0x0c, 0x00, 0x00, 0x00}, 4},
514 {{0x11, 0x0e, 0x01, 0x00, 0x00, 0x00}, 4},
515 {{0x11, 0x0f, 0x00, 0x00, 0x00, 0x00}, 4},
516 {{0x11, 0x10, 0x00, 0x00, 0x00, 0x00}, 4},
517 {{0x11, 0x11, 0x00, 0x00, 0x00, 0x00}, 4},
518 {{0x11, 0x12, 0x00, 0x00, 0x00, 0x00}, 4},
519 {{0x11, 0x13, 0x63, 0x00, 0x00, 0x00}, 4},
520 {{0x11, 0x15, 0x70, 0x00, 0x00, 0x00}, 4},
521 {{0x11, 0x18, 0x00, 0x00, 0x00, 0x00}, 4},
522 {{0x11, 0x11, 0x01, 0x00, 0x00, 0x00}, 4},
523 {{0x13, 0x25, 0x01, 0x28, 0x00, 0x00}, 4}, /* width */
524 {{0x13, 0x26, 0x01, 0x1e, 0x00, 0x00}, 4}, /* height */
525 {{0x13, 0x28, 0x01, 0x09, 0x00, 0x00}, 4}, /* vstart? */
526 {{0x13, 0x27, 0x01, 0x28, 0x00, 0x00}, 4},
527 {{0x13, 0x29, 0x01, 0x40, 0x00, 0x00}, 4}, /* hstart? */
528 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
529 {{0x13, 0x2d, 0x01, 0x03, 0x00, 0x00}, 4},
530 {{0x13, 0x2e, 0x01, 0x0f, 0x00, 0x00}, 4},
531 {{0x13, 0x2f, 0x01, 0x0c, 0x00, 0x00}, 4},
532 {{0x1b, 0x02, 0x05, 0x00, 0x00, 0x00}, 1},
533 {{0x1b, 0x11, 0x01, 0x00, 0x00, 0x00}, 1},
534 {{0x20, 0x18, 0x00, 0x00, 0x00, 0x00}, 1},
535 {{0x1b, 0x02, 0x0a, 0x00, 0x00, 0x00}, 1},
536 {{0x1b, 0x11, 0x01, 0x00, 0x00, 0x00}, 0},
537 /* Camera should start to capture now. */
540 return run_start_commands(gspca_dev, ms350_start_commands,
541 ARRAY_SIZE(ms350_start_commands));
544 static int start_genius_cam(struct gspca_dev *gspca_dev)
546 struct init_command genius_start_commands[] = {
547 {{0x0c, 0x01, 0x00, 0x00, 0x00, 0x00}, 4},
548 {{0x16, 0x01, 0x00, 0x00, 0x00, 0x00}, 4},
549 {{0x10, 0x00, 0x00, 0x00, 0x00, 0x00}, 4},
550 {{0x13, 0x25, 0x01, 0x16, 0x00, 0x00}, 4},
551 {{0x13, 0x26, 0x01, 0x12, 0x00, 0x00}, 4},
552 /* "preliminary" width and height settings */
553 {{0x13, 0x28, 0x01, 0x0e, 0x00, 0x00}, 4},
554 {{0x13, 0x27, 0x01, 0x20, 0x00, 0x00}, 4},
555 {{0x13, 0x29, 0x01, 0x22, 0x00, 0x00}, 4},
556 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
557 {{0x13, 0x2d, 0x01, 0x02, 0x00, 0x00}, 4},
558 {{0x13, 0x2e, 0x01, 0x09, 0x00, 0x00}, 4},
559 {{0x13, 0x2f, 0x01, 0x07, 0x00, 0x00}, 4},
560 {{0x11, 0x20, 0x00, 0x00, 0x00, 0x00}, 4},
561 {{0x11, 0x21, 0x2d, 0x00, 0x00, 0x00}, 4},
562 {{0x11, 0x22, 0x00, 0x00, 0x00, 0x00}, 4},
563 {{0x11, 0x23, 0x03, 0x00, 0x00, 0x00}, 4},
564 {{0x11, 0x10, 0x00, 0x00, 0x00, 0x00}, 4},
565 {{0x11, 0x11, 0x64, 0x00, 0x00, 0x00}, 4},
566 {{0x11, 0x12, 0x00, 0x00, 0x00, 0x00}, 4},
567 {{0x11, 0x13, 0x91, 0x00, 0x00, 0x00}, 4},
568 {{0x11, 0x14, 0x01, 0x00, 0x00, 0x00}, 4},
569 {{0x11, 0x15, 0x20, 0x00, 0x00, 0x00}, 4},
570 {{0x11, 0x16, 0x01, 0x00, 0x00, 0x00}, 4},
571 {{0x11, 0x17, 0x60, 0x00, 0x00, 0x00}, 4},
572 {{0x11, 0x20, 0x00, 0x00, 0x00, 0x00}, 4},
573 {{0x11, 0x21, 0x2d, 0x00, 0x00, 0x00}, 4},
574 {{0x11, 0x22, 0x00, 0x00, 0x00, 0x00}, 4},
575 {{0x11, 0x23, 0x03, 0x00, 0x00, 0x00}, 4},
576 {{0x11, 0x25, 0x00, 0x00, 0x00, 0x00}, 4},
577 {{0x11, 0x26, 0x02, 0x00, 0x00, 0x00}, 4},
578 {{0x11, 0x27, 0x88, 0x00, 0x00, 0x00}, 4},
579 {{0x11, 0x30, 0x38, 0x00, 0x00, 0x00}, 4},
580 {{0x11, 0x31, 0x2a, 0x00, 0x00, 0x00}, 4},
581 {{0x11, 0x32, 0x2a, 0x00, 0x00, 0x00}, 4},
582 {{0x11, 0x33, 0x2a, 0x00, 0x00, 0x00}, 4},
583 {{0x11, 0x34, 0x02, 0x00, 0x00, 0x00}, 4},
584 {{0x11, 0x5b, 0x0a, 0x00, 0x00, 0x00}, 4},
585 {{0x13, 0x25, 0x01, 0x28, 0x00, 0x00}, 4}, /* real width */
586 {{0x13, 0x26, 0x01, 0x1e, 0x00, 0x00}, 4}, /* real height */
587 {{0x13, 0x28, 0x01, 0x0e, 0x00, 0x00}, 4},
588 {{0x13, 0x27, 0x01, 0x20, 0x00, 0x00}, 4},
589 {{0x13, 0x29, 0x01, 0x62, 0x00, 0x00}, 4},
590 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
591 {{0x13, 0x2d, 0x01, 0x03, 0x00, 0x00}, 4},
592 {{0x13, 0x2e, 0x01, 0x0f, 0x00, 0x00}, 4},
593 {{0x13, 0x2f, 0x01, 0x0c, 0x00, 0x00}, 4},
594 {{0x11, 0x20, 0x00, 0x00, 0x00, 0x00}, 4},
595 {{0x11, 0x21, 0x2a, 0x00, 0x00, 0x00}, 4},
596 {{0x11, 0x22, 0x00, 0x00, 0x00, 0x00}, 4},
597 {{0x11, 0x23, 0x28, 0x00, 0x00, 0x00}, 4},
598 {{0x11, 0x10, 0x00, 0x00, 0x00, 0x00}, 4},
599 {{0x11, 0x11, 0x04, 0x00, 0x00, 0x00}, 4},
600 {{0x11, 0x12, 0x00, 0x00, 0x00, 0x00}, 4},
601 {{0x11, 0x13, 0x03, 0x00, 0x00, 0x00}, 4},
602 {{0x11, 0x14, 0x01, 0x00, 0x00, 0x00}, 4},
603 {{0x11, 0x15, 0xe0, 0x00, 0x00, 0x00}, 4},
604 {{0x11, 0x16, 0x02, 0x00, 0x00, 0x00}, 4},
605 {{0x11, 0x17, 0x80, 0x00, 0x00, 0x00}, 4},
606 {{0x1c, 0x20, 0x00, 0x2a, 0x00, 0x00}, 1},
607 {{0x1c, 0x20, 0x00, 0x2a, 0x00, 0x00}, 1},
608 {{0x20, 0x34, 0xa1, 0x00, 0x00, 0x00}, 0}
609 /* Camera should start to capture now. */
612 return run_start_commands(gspca_dev, genius_start_commands,
613 ARRAY_SIZE(genius_start_commands));
616 static int start_genius_videocam_live(struct gspca_dev *gspca_dev)
619 struct sd *sd = (struct sd *) gspca_dev;
620 struct init_command genius_vcam_live_start_commands[] = {
621 {{0x0c, 0x01, 0x00, 0x00, 0x00, 0x00}, 0},
622 {{0x16, 0x01, 0x00, 0x00, 0x00, 0x00}, 4},
623 {{0x10, 0x00, 0x00, 0x00, 0x00, 0x00}, 4},
624 {{0x13, 0x25, 0x01, 0x16, 0x00, 0x00}, 4},
625 {{0x13, 0x26, 0x01, 0x12, 0x00, 0x00}, 4},
627 {{0x13, 0x28, 0x01, 0x0e, 0x00, 0x00}, 4},
628 {{0x13, 0x27, 0x01, 0x20, 0x00, 0x00}, 4},
629 {{0x13, 0x29, 0x01, 0x22, 0x00, 0x00}, 4},
630 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
631 {{0x13, 0x2d, 0x01, 0x02, 0x00, 0x00}, 4},
632 {{0x13, 0x2e, 0x01, 0x09, 0x00, 0x00}, 4},
633 {{0x13, 0x2f, 0x01, 0x07, 0x00, 0x00}, 4},
634 {{0x11, 0x20, 0x00, 0x00, 0x00, 0x00}, 4},
635 {{0x11, 0x21, 0x2d, 0x00, 0x00, 0x00}, 4},
636 {{0x11, 0x22, 0x00, 0x00, 0x00, 0x00}, 4},
637 {{0x11, 0x23, 0x03, 0x00, 0x00, 0x00}, 4},
638 {{0x11, 0x10, 0x00, 0x00, 0x00, 0x00}, 4},
639 {{0x11, 0x11, 0x64, 0x00, 0x00, 0x00}, 4},
640 {{0x11, 0x12, 0x00, 0x00, 0x00, 0x00}, 4},
641 {{0x11, 0x13, 0x91, 0x00, 0x00, 0x00}, 4},
642 {{0x11, 0x14, 0x01, 0x00, 0x00, 0x00}, 4},
643 {{0x11, 0x15, 0x20, 0x00, 0x00, 0x00}, 4},
644 {{0x11, 0x16, 0x01, 0x00, 0x00, 0x00}, 4},
645 {{0x11, 0x17, 0x60, 0x00, 0x00, 0x00}, 4},
646 {{0x1c, 0x20, 0x00, 0x2d, 0x00, 0x00}, 4},
647 {{0x13, 0x20, 0x01, 0x00, 0x00, 0x00}, 4},
648 {{0x13, 0x21, 0x01, 0x00, 0x00, 0x00}, 4},
649 {{0x13, 0x22, 0x01, 0x00, 0x00, 0x00}, 4},
650 {{0x13, 0x23, 0x01, 0x01, 0x00, 0x00}, 4},
651 {{0x13, 0x24, 0x01, 0x00, 0x00, 0x00}, 4},
652 {{0x13, 0x25, 0x01, 0x16, 0x00, 0x00}, 4},
653 {{0x13, 0x26, 0x01, 0x12, 0x00, 0x00}, 4},
654 {{0x13, 0x27, 0x01, 0x20, 0x00, 0x00}, 4},
655 {{0x13, 0x28, 0x01, 0x0e, 0x00, 0x00}, 4},
656 {{0x13, 0x29, 0x01, 0x22, 0x00, 0x00}, 4},
657 {{0x13, 0x2a, 0x01, 0x00, 0x00, 0x00}, 4},
658 {{0x13, 0x2b, 0x01, 0x00, 0x00, 0x00}, 4},
659 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
660 {{0x13, 0x2d, 0x01, 0x02, 0x00, 0x00}, 4},
661 {{0x13, 0x2e, 0x01, 0x09, 0x00, 0x00}, 4},
662 {{0x13, 0x2f, 0x01, 0x07, 0x00, 0x00}, 4},
663 {{0x12, 0x34, 0x01, 0x00, 0x00, 0x00}, 4},
664 {{0x13, 0x34, 0x01, 0xa1, 0x00, 0x00}, 4},
665 {{0x13, 0x35, 0x01, 0x00, 0x00, 0x00}, 4},
666 {{0x11, 0x01, 0x04, 0x00, 0x00, 0x00}, 4},
667 {{0x11, 0x02, 0x92, 0x00, 0x00, 0x00}, 4},
668 {{0x11, 0x10, 0x00, 0x00, 0x00, 0x00}, 4},
669 {{0x11, 0x11, 0x64, 0x00, 0x00, 0x00}, 4},
670 {{0x11, 0x12, 0x00, 0x00, 0x00, 0x00}, 4},
671 {{0x11, 0x13, 0x91, 0x00, 0x00, 0x00}, 4},
672 {{0x11, 0x14, 0x01, 0x00, 0x00, 0x00}, 4},
673 {{0x11, 0x15, 0x20, 0x00, 0x00, 0x00}, 4},
674 {{0x11, 0x16, 0x01, 0x00, 0x00, 0x00}, 4},
675 {{0x11, 0x17, 0x60, 0x00, 0x00, 0x00}, 4},
676 {{0x11, 0x20, 0x00, 0x00, 0x00, 0x00}, 4},
677 {{0x11, 0x21, 0x2d, 0x00, 0x00, 0x00}, 4},
678 {{0x11, 0x22, 0x00, 0x00, 0x00, 0x00}, 4},
679 {{0x11, 0x23, 0x03, 0x00, 0x00, 0x00}, 4},
680 {{0x11, 0x25, 0x00, 0x00, 0x00, 0x00}, 4},
681 {{0x11, 0x26, 0x02, 0x00, 0x00, 0x00}, 4},
682 {{0x11, 0x27, 0x88, 0x00, 0x00, 0x00}, 4},
683 {{0x11, 0x30, 0x38, 0x00, 0x00, 0x00}, 4},
684 {{0x11, 0x31, 0x2a, 0x00, 0x00, 0x00}, 4},
685 {{0x11, 0x32, 0x2a, 0x00, 0x00, 0x00}, 4},
686 {{0x11, 0x33, 0x2a, 0x00, 0x00, 0x00}, 4},
687 {{0x11, 0x34, 0x02, 0x00, 0x00, 0x00}, 4},
688 {{0x11, 0x5b, 0x0a, 0x00, 0x00, 0x00}, 4},
689 {{0x13, 0x25, 0x01, 0x28, 0x00, 0x00}, 4},
690 {{0x13, 0x26, 0x01, 0x1e, 0x00, 0x00}, 4},
691 {{0x13, 0x28, 0x01, 0x0e, 0x00, 0x00}, 4},
692 {{0x13, 0x27, 0x01, 0x20, 0x00, 0x00}, 4},
693 {{0x13, 0x29, 0x01, 0x62, 0x00, 0x00}, 4},
694 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
695 {{0x13, 0x2d, 0x01, 0x03, 0x00, 0x00}, 4},
696 {{0x13, 0x2e, 0x01, 0x0f, 0x00, 0x00}, 4},
697 {{0x13, 0x2f, 0x01, 0x0c, 0x00, 0x00}, 4},
698 {{0x11, 0x20, 0x00, 0x00, 0x00, 0x00}, 4},
699 {{0x11, 0x21, 0x2a, 0x00, 0x00, 0x00}, 4},
700 {{0x11, 0x22, 0x00, 0x00, 0x00, 0x00}, 4},
701 {{0x11, 0x23, 0x28, 0x00, 0x00, 0x00}, 4},
702 {{0x11, 0x10, 0x00, 0x00, 0x00, 0x00}, 4},
703 {{0x11, 0x11, 0x04, 0x00, 0x00, 0x00}, 4},
704 {{0x11, 0x12, 0x00, 0x00, 0x00, 0x00}, 4},
705 {{0x11, 0x13, 0x03, 0x00, 0x00, 0x00}, 4},
706 {{0x11, 0x14, 0x01, 0x00, 0x00, 0x00}, 4},
707 {{0x11, 0x15, 0xe0, 0x00, 0x00, 0x00}, 4},
708 {{0x11, 0x16, 0x02, 0x00, 0x00, 0x00}, 4},
709 {{0x11, 0x17, 0x80, 0x00, 0x00, 0x00}, 4},
710 {{0x1c, 0x20, 0x00, 0x2a, 0x00, 0x00}, 1},
711 {{0x20, 0x34, 0xa1, 0x00, 0x00, 0x00}, 0},
712 /* Camera should start to capture now. */
713 {{0x12, 0x27, 0x01, 0x00, 0x00, 0x00}, 0},
714 {{0x1b, 0x32, 0x26, 0x00, 0x00, 0x00}, 0},
715 {{0x1d, 0x25, 0x10, 0x20, 0xab, 0x00}, 0},
718 r = run_start_commands(gspca_dev, genius_vcam_live_start_commands,
719 ARRAY_SIZE(genius_vcam_live_start_commands));
724 set_gain(gspca_dev, v4l2_ctrl_g_ctrl(sd->gain));
729 static int start_vivitar_cam(struct gspca_dev *gspca_dev)
731 struct init_command vivitar_start_commands[] = {
732 {{0x0c, 0x01, 0x00, 0x00, 0x00, 0x00}, 4},
733 {{0x13, 0x20, 0x01, 0x00, 0x00, 0x00}, 4},
734 {{0x13, 0x21, 0x01, 0x00, 0x00, 0x00}, 4},
735 {{0x13, 0x22, 0x01, 0x01, 0x00, 0x00}, 4},
736 {{0x13, 0x23, 0x01, 0x01, 0x00, 0x00}, 4},
737 {{0x13, 0x24, 0x01, 0x00, 0x00, 0x00}, 4},
738 {{0x13, 0x25, 0x01, 0x28, 0x00, 0x00}, 4},
739 {{0x13, 0x26, 0x01, 0x1e, 0x00, 0x00}, 4},
740 {{0x13, 0x27, 0x01, 0x20, 0x00, 0x00}, 4},
741 {{0x13, 0x28, 0x01, 0x0a, 0x00, 0x00}, 4},
743 * Above is changed from OEM 0x0b. Fixes Bayer tiling.
744 * Presumably gives a vertical shift of one row.
746 {{0x13, 0x29, 0x01, 0x20, 0x00, 0x00}, 4},
747 /* Above seems to do horizontal shift. */
748 {{0x13, 0x2a, 0x01, 0x00, 0x00, 0x00}, 4},
749 {{0x13, 0x2b, 0x01, 0x00, 0x00, 0x00}, 4},
750 {{0x13, 0x2c, 0x01, 0x02, 0x00, 0x00}, 4},
751 {{0x13, 0x2d, 0x01, 0x03, 0x00, 0x00}, 4},
752 {{0x13, 0x2e, 0x01, 0x0f, 0x00, 0x00}, 4},
753 {{0x13, 0x2f, 0x01, 0x0c, 0x00, 0x00}, 4},
754 /* Above three commands seem to relate to brightness. */
755 {{0x12, 0x34, 0x01, 0x00, 0x00, 0x00}, 4},
756 {{0x13, 0x34, 0x01, 0xa1, 0x00, 0x00}, 4},
757 {{0x13, 0x35, 0x01, 0x00, 0x00, 0x00}, 4},
758 {{0x1b, 0x12, 0x80, 0x00, 0x00, 0x00}, 1},
759 {{0x1b, 0x01, 0x77, 0x00, 0x00, 0x00}, 1},
760 {{0x1b, 0x02, 0x3a, 0x00, 0x00, 0x00}, 1},
761 {{0x1b, 0x12, 0x78, 0x00, 0x00, 0x00}, 1},
762 {{0x1b, 0x13, 0x00, 0x00, 0x00, 0x00}, 1},
763 {{0x1b, 0x14, 0x80, 0x00, 0x00, 0x00}, 1},
764 {{0x1b, 0x15, 0x34, 0x00, 0x00, 0x00}, 1},
765 {{0x1b, 0x1b, 0x04, 0x00, 0x00, 0x00}, 1},
766 {{0x1b, 0x20, 0x44, 0x00, 0x00, 0x00}, 1},
767 {{0x1b, 0x23, 0xee, 0x00, 0x00, 0x00}, 1},
768 {{0x1b, 0x26, 0xa0, 0x00, 0x00, 0x00}, 1},
769 {{0x1b, 0x27, 0x9a, 0x00, 0x00, 0x00}, 1},
770 {{0x1b, 0x28, 0xa0, 0x00, 0x00, 0x00}, 1},
771 {{0x1b, 0x29, 0x30, 0x00, 0x00, 0x00}, 1},
772 {{0x1b, 0x2a, 0x80, 0x00, 0x00, 0x00}, 1},
773 {{0x1b, 0x2b, 0x00, 0x00, 0x00, 0x00}, 1},
774 {{0x1b, 0x2f, 0x3d, 0x00, 0x00, 0x00}, 1},
775 {{0x1b, 0x30, 0x24, 0x00, 0x00, 0x00}, 1},
776 {{0x1b, 0x32, 0x86, 0x00, 0x00, 0x00}, 1},
777 {{0x1b, 0x60, 0xa9, 0x00, 0x00, 0x00}, 1},
778 {{0x1b, 0x61, 0x42, 0x00, 0x00, 0x00}, 1},
779 {{0x1b, 0x65, 0x00, 0x00, 0x00, 0x00}, 1},
780 {{0x1b, 0x69, 0x38, 0x00, 0x00, 0x00}, 1},
781 {{0x1b, 0x6f, 0x88, 0x00, 0x00, 0x00}, 1},
782 {{0x1b, 0x70, 0x0b, 0x00, 0x00, 0x00}, 1},
783 {{0x1b, 0x71, 0x00, 0x00, 0x00, 0x00}, 1},
784 {{0x1b, 0x74, 0x21, 0x00, 0x00, 0x00}, 1},
785 {{0x1b, 0x75, 0x86, 0x00, 0x00, 0x00}, 1},
786 {{0x1b, 0x76, 0x00, 0x00, 0x00, 0x00}, 1},
787 {{0x1b, 0x7d, 0xf3, 0x00, 0x00, 0x00}, 1},
788 {{0x1b, 0x17, 0x1c, 0x00, 0x00, 0x00}, 1},
789 {{0x1b, 0x18, 0xc0, 0x00, 0x00, 0x00}, 1},
790 {{0x1b, 0x19, 0x05, 0x00, 0x00, 0x00}, 1},
791 {{0x1b, 0x1a, 0xf6, 0x00, 0x00, 0x00}, 1},
792 /* {{0x13, 0x25, 0x01, 0x28, 0x00, 0x00}, 4},
793 {{0x13, 0x26, 0x01, 0x1e, 0x00, 0x00}, 4},
794 {{0x13, 0x28, 0x01, 0x0b, 0x00, 0x00}, 4}, */
795 {{0x20, 0x36, 0x06, 0x00, 0x00, 0x00}, 1},
796 {{0x1b, 0x10, 0x26, 0x00, 0x00, 0x00}, 1},
797 {{0x12, 0x27, 0x01, 0x00, 0x00, 0x00}, 4},
798 {{0x1b, 0x76, 0x03, 0x00, 0x00, 0x00}, 1},
799 {{0x20, 0x36, 0x05, 0x00, 0x00, 0x00}, 1},
800 {{0x1b, 0x00, 0x3f, 0x00, 0x00, 0x00}, 1},
801 /* Above is brightness; OEM driver setting is 0x10 */
802 {{0x12, 0x27, 0x01, 0x00, 0x00, 0x00}, 4},
803 {{0x20, 0x29, 0x30, 0x00, 0x00, 0x00}, 1},
804 {{0x20, 0x34, 0xa1, 0x00, 0x00, 0x00}, 1}
807 return run_start_commands(gspca_dev, vivitar_start_commands,
808 ARRAY_SIZE(vivitar_start_commands));
811 static int sd_start(struct gspca_dev *gspca_dev)
813 struct sd *sd = (struct sd *) gspca_dev;
820 err_code = start_genius_cam(gspca_dev);
823 err_code = start_genius_videocam_live(gspca_dev);
826 err_code = start_spy_cam(gspca_dev);
829 err_code = start_cif_cam(gspca_dev);
832 err_code = start_ms350_cam(gspca_dev);
835 err_code = start_vivitar_cam(gspca_dev);
838 pr_err("Starting unknown camera, please report this\n");
847 static void sd_stopN(struct gspca_dev *gspca_dev)
852 result = sn9c2028_read1(gspca_dev);
854 gspca_err(gspca_dev, "Camera Stop read failed\n");
858 result = sn9c2028_command(gspca_dev, data);
860 gspca_err(gspca_dev, "Camera Stop command failed\n");
863 static void do_autogain(struct gspca_dev *gspca_dev, int avg_lum)
865 struct sd *sd = (struct sd *) gspca_dev;
866 s32 cur_gain = v4l2_ctrl_g_ctrl(sd->gain);
871 if (avg_lum < MIN_AVG_LUM) {
872 if (cur_gain == sd->gain->maximum)
875 v4l2_ctrl_s_ctrl(sd->gain, cur_gain);
877 if (avg_lum > MAX_AVG_LUM) {
878 if (cur_gain == sd->gain->minimum)
881 v4l2_ctrl_s_ctrl(sd->gain, cur_gain);
886 static void sd_dqcallback(struct gspca_dev *gspca_dev)
888 struct sd *sd = (struct sd *) gspca_dev;
890 if (sd->autogain == NULL || !v4l2_ctrl_g_ctrl(sd->autogain))
893 do_autogain(gspca_dev, sd->avg_lum);
896 /* Include sn9c2028 sof detection functions */
897 #include "sn9c2028.h"
899 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
900 __u8 *data, /* isoc packet */
901 int len) /* iso packet length */
905 sof = sn9c2028_find_sof(gspca_dev, data, len);
909 /* finish decoding current frame */
911 if (n > sizeof sn9c2028_sof_marker)
912 n -= sizeof sn9c2028_sof_marker;
915 gspca_frame_add(gspca_dev, LAST_PACKET, data, n);
916 /* Start next frame. */
917 gspca_frame_add(gspca_dev, FIRST_PACKET,
918 sn9c2028_sof_marker, sizeof sn9c2028_sof_marker);
922 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
925 /* sub-driver description */
926 static const struct sd_desc sd_desc = {
930 .init_controls = sd_init_controls,
933 .dq_callback = sd_dqcallback,
934 .pkt_scan = sd_pkt_scan,
937 /* -- module initialisation -- */
938 static const struct usb_device_id device_table[] = {
939 {USB_DEVICE(0x0458, 0x7005)}, /* Genius Smart 300, version 2 */
940 {USB_DEVICE(0x0458, 0x7003)}, /* Genius Videocam Live v2 */
941 /* The Genius Smart is untested. I can't find an owner ! */
942 /* {USB_DEVICE(0x0c45, 0x8000)}, DC31VC, Don't know this camera */
943 {USB_DEVICE(0x0c45, 0x8001)}, /* Wild Planet digital spy cam */
944 {USB_DEVICE(0x0c45, 0x8003)}, /* Several small CIF cameras */
945 /* {USB_DEVICE(0x0c45, 0x8006)}, Unknown VGA camera */
946 {USB_DEVICE(0x0c45, 0x8008)}, /* Mini-Shotz ms-350 */
947 {USB_DEVICE(0x0c45, 0x800a)}, /* Vivicam 3350B */
950 MODULE_DEVICE_TABLE(usb, device_table);
952 /* -- device connect -- */
953 static int sd_probe(struct usb_interface *intf,
954 const struct usb_device_id *id)
956 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
960 static struct usb_driver sd_driver = {
962 .id_table = device_table,
964 .disconnect = gspca_disconnect,
966 .suspend = gspca_suspend,
967 .resume = gspca_resume,
968 .reset_resume = gspca_resume,
972 module_usb_driver(sd_driver);