2 * Pixart PAC7311 library
3 * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li
5 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 /* Some documentation about various registers as determined by trial and error.
27 0x08 Unknown compressor related, must always be 8 except when not
28 in 640x480 resolution and page 4 reg 2 <= 3 then set it to 9 !
29 0x1b Auto white balance related, bit 0 is AWB enable (inverted)
30 bits 345 seem to toggle per color gains on/off (inverted)
31 0x78 Global control, bit 6 controls the LED (inverted)
32 0x80 JPEG compression ratio ? Best not touched
37 0x02 Clock divider 2-63, fps =~ 60 / val. Must be a multiple of 3 on
38 the 7302, so one of 3, 6, 9, ..., except when between 6 and 12?
39 0x0f Master gain 1-245, low value = high gain
40 0x10 Another gain 0-15, limited influence (1-2x gain I guess)
41 0x21 Bitfield: 0-1 unused, 2-3 vflip/hflip, 4-5 unknown, 6-7 unused
42 0x27 Seems to toggle various gains on / off, Setting bit 7 seems to
43 completely disable the analog amplification block. Set to 0x68
44 for max gain, 0x14 for minimal gain.
47 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
49 #define MODULE_NAME "pac7311"
51 #include <linux/input.h>
54 MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li");
55 MODULE_DESCRIPTION("Pixart PAC7311");
56 MODULE_LICENSE("GPL");
59 struct gspca_dev gspca_dev; /* !! must be the first item */
61 unsigned char contrast;
63 unsigned char exposure;
64 unsigned char autogain;
69 u8 autogain_ignore_frames;
74 /* V4L2 controls supported by the driver */
75 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
76 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
77 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
78 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
79 static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
80 static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
81 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
82 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
83 static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val);
84 static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val);
85 static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val);
86 static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val);
88 static const struct ctrl sd_ctrls[] = {
91 .id = V4L2_CID_CONTRAST,
92 .type = V4L2_CTRL_TYPE_INTEGER,
95 #define CONTRAST_MAX 255
96 .maximum = CONTRAST_MAX,
98 #define CONTRAST_DEF 127
99 .default_value = CONTRAST_DEF,
101 .set = sd_setcontrast,
102 .get = sd_getcontrast,
107 .type = V4L2_CTRL_TYPE_INTEGER,
114 #define GAIN_KNEE 255 /* Gain seems to cause little noise on the pac73xx */
115 .default_value = GAIN_DEF,
122 .id = V4L2_CID_EXPOSURE,
123 .type = V4L2_CTRL_TYPE_INTEGER,
126 #define EXPOSURE_MAX 255
127 .maximum = EXPOSURE_MAX,
129 #define EXPOSURE_DEF 16 /* 32 ms / 30 fps */
130 #define EXPOSURE_KNEE 50 /* 100 ms / 10 fps */
131 .default_value = EXPOSURE_DEF,
133 .set = sd_setexposure,
134 .get = sd_getexposure,
138 .id = V4L2_CID_AUTOGAIN,
139 .type = V4L2_CTRL_TYPE_BOOLEAN,
144 #define AUTOGAIN_DEF 1
145 .default_value = AUTOGAIN_DEF,
147 .set = sd_setautogain,
148 .get = sd_getautogain,
152 .id = V4L2_CID_HFLIP,
153 .type = V4L2_CTRL_TYPE_BOOLEAN,
159 .default_value = HFLIP_DEF,
166 .id = V4L2_CID_VFLIP,
167 .type = V4L2_CTRL_TYPE_BOOLEAN,
173 .default_value = VFLIP_DEF,
180 static const struct v4l2_pix_format vga_mode[] = {
181 {160, 120, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
183 .sizeimage = 160 * 120 * 3 / 8 + 590,
184 .colorspace = V4L2_COLORSPACE_JPEG,
186 {320, 240, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
188 .sizeimage = 320 * 240 * 3 / 8 + 590,
189 .colorspace = V4L2_COLORSPACE_JPEG,
191 {640, 480, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
193 .sizeimage = 640 * 480 * 3 / 8 + 590,
194 .colorspace = V4L2_COLORSPACE_JPEG,
198 #define LOAD_PAGE4 254
199 #define END_OF_SEQUENCE 0
201 static const __u8 init_7311[] = {
202 0x78, 0x40, /* Bit_0=start stream, Bit_6=LED */
203 0x78, 0x40, /* Bit_0=start stream, Bit_6=LED */
204 0x78, 0x44, /* Bit_0=start stream, Bit_6=LED */
214 static const __u8 start_7311[] = {
215 /* index, len, [value]* */
216 0xff, 1, 0x01, /* page 1 */
217 0x02, 43, 0x48, 0x0a, 0x40, 0x08, 0x00, 0x00, 0x08, 0x00,
218 0x06, 0xff, 0x11, 0xff, 0x5a, 0x30, 0x90, 0x4c,
219 0x00, 0x07, 0x00, 0x0a, 0x10, 0x00, 0xa0, 0x10,
220 0x02, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x01, 0x00,
221 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223 0x3e, 42, 0x00, 0x00, 0x78, 0x52, 0x4a, 0x52, 0x78, 0x6e,
224 0x48, 0x46, 0x48, 0x6e, 0x5f, 0x49, 0x42, 0x49,
225 0x5f, 0x5f, 0x49, 0x42, 0x49, 0x5f, 0x6e, 0x48,
226 0x46, 0x48, 0x6e, 0x78, 0x52, 0x4a, 0x52, 0x78,
227 0x00, 0x00, 0x09, 0x1b, 0x34, 0x49, 0x5c, 0x9b,
229 0x78, 6, 0x44, 0x00, 0xf2, 0x01, 0x01, 0x80,
230 0x7f, 18, 0x2a, 0x1c, 0x00, 0xc8, 0x02, 0x58, 0x03, 0x84,
231 0x12, 0x00, 0x1a, 0x04, 0x08, 0x0c, 0x10, 0x14,
233 0x96, 3, 0x01, 0x08, 0x04,
234 0xa0, 4, 0x44, 0x44, 0x44, 0x04,
235 0xf0, 13, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x20, 0x00,
236 0x3f, 0x00, 0x0a, 0x01, 0x00,
237 0xff, 1, 0x04, /* page 4 */
238 0, LOAD_PAGE4, /* load the page 4 */
240 0, END_OF_SEQUENCE /* end of sequence */
244 /* page 4 - the value SKIP says skip the index - see reg_w_page() */
245 static const __u8 page4_7311[] = {
246 SKIP, SKIP, 0x04, 0x54, 0x07, 0x2b, 0x09, 0x0f,
247 0x09, 0x00, SKIP, SKIP, 0x07, 0x00, 0x00, 0x62,
248 0x08, SKIP, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
249 0x00, 0x00, 0x00, 0x03, 0xa0, 0x01, 0xf4, SKIP,
250 SKIP, 0x00, 0x08, SKIP, 0x03, SKIP, 0x00, 0x68,
251 0xca, 0x10, 0x06, 0x78, 0x00, 0x00, 0x00, 0x00,
252 0x23, 0x28, 0x04, 0x11, 0x00, 0x00
255 static void reg_w_buf(struct gspca_dev *gspca_dev,
257 const u8 *buffer, int len)
261 if (gspca_dev->usb_err < 0)
263 memcpy(gspca_dev->usb_buf, buffer, len);
264 ret = usb_control_msg(gspca_dev->dev,
265 usb_sndctrlpipe(gspca_dev->dev, 0),
267 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
269 index, gspca_dev->usb_buf, len,
272 pr_err("reg_w_buf() failed index 0x%02x, error %d\n",
274 gspca_dev->usb_err = ret;
279 static void reg_w(struct gspca_dev *gspca_dev,
285 if (gspca_dev->usb_err < 0)
287 gspca_dev->usb_buf[0] = value;
288 ret = usb_control_msg(gspca_dev->dev,
289 usb_sndctrlpipe(gspca_dev->dev, 0),
291 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
292 0, index, gspca_dev->usb_buf, 1,
295 pr_err("reg_w() failed index 0x%02x, value 0x%02x, error %d\n",
297 gspca_dev->usb_err = ret;
301 static void reg_w_seq(struct gspca_dev *gspca_dev,
302 const __u8 *seq, int len)
305 reg_w(gspca_dev, seq[0], seq[1]);
310 /* load the beginning of a page */
311 static void reg_w_page(struct gspca_dev *gspca_dev,
312 const __u8 *page, int len)
317 if (gspca_dev->usb_err < 0)
319 for (index = 0; index < len; index++) {
320 if (page[index] == SKIP) /* skip this index */
322 gspca_dev->usb_buf[0] = page[index];
323 ret = usb_control_msg(gspca_dev->dev,
324 usb_sndctrlpipe(gspca_dev->dev, 0),
326 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
327 0, index, gspca_dev->usb_buf, 1,
330 pr_err("reg_w_page() failed index 0x%02x, value 0x%02x, error %d\n",
331 index, page[index], ret);
332 gspca_dev->usb_err = ret;
338 /* output a variable sequence */
339 static void reg_w_var(struct gspca_dev *gspca_dev,
341 const __u8 *page4, unsigned int page4_len)
349 case END_OF_SEQUENCE:
352 reg_w_page(gspca_dev, page4, page4_len);
355 if (len > USB_BUF_SZ) {
356 PDEBUG(D_ERR|D_STREAM,
357 "Incorrect variable sequence");
367 reg_w_buf(gspca_dev, index, seq, 8);
377 /* this function is called at probe time for pac7311 */
378 static int sd_config(struct gspca_dev *gspca_dev,
379 const struct usb_device_id *id)
381 struct sd *sd = (struct sd *) gspca_dev;
384 cam = &gspca_dev->cam;
386 cam->cam_mode = vga_mode;
387 cam->nmodes = ARRAY_SIZE(vga_mode);
389 sd->contrast = CONTRAST_DEF;
391 sd->exposure = EXPOSURE_DEF;
392 sd->autogain = AUTOGAIN_DEF;
393 sd->hflip = HFLIP_DEF;
394 sd->vflip = VFLIP_DEF;
398 static void setcontrast(struct gspca_dev *gspca_dev)
400 struct sd *sd = (struct sd *) gspca_dev;
402 reg_w(gspca_dev, 0xff, 0x04);
403 reg_w(gspca_dev, 0x10, sd->contrast >> 4);
404 /* load registers to sensor (Bit 0, auto clear) */
405 reg_w(gspca_dev, 0x11, 0x01);
408 static void setgain(struct gspca_dev *gspca_dev)
410 struct sd *sd = (struct sd *) gspca_dev;
411 int gain = GAIN_MAX - sd->gain;
417 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
418 reg_w(gspca_dev, 0x0e, 0x00);
419 reg_w(gspca_dev, 0x0f, gain);
421 /* load registers to sensor (Bit 0, auto clear) */
422 reg_w(gspca_dev, 0x11, 0x01);
425 static void setexposure(struct gspca_dev *gspca_dev)
427 struct sd *sd = (struct sd *) gspca_dev;
430 /* register 2 of page 4 contains the clock divider configuring the
431 no fps according to the formula: 60 / reg. sd->exposure is the
432 desired exposure time in ms. */
433 reg = 120 * sd->exposure / 1000;
439 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
440 reg_w(gspca_dev, 0x02, reg);
442 /* load registers to sensor (Bit 0, auto clear) */
443 reg_w(gspca_dev, 0x11, 0x01);
445 /* Page 1 register 8 must always be 0x08 except when not in
446 640x480 mode and page 4 reg 2 <= 3 then it must be 9 */
447 reg_w(gspca_dev, 0xff, 0x01);
448 if (gspca_dev->cam.cam_mode[(int)gspca_dev->curr_mode].priv &&
450 reg_w(gspca_dev, 0x08, 0x09);
452 reg_w(gspca_dev, 0x08, 0x08);
455 /* load registers to sensor (Bit 0, auto clear) */
456 reg_w(gspca_dev, 0x11, 0x01);
459 static void sethvflip(struct gspca_dev *gspca_dev)
461 struct sd *sd = (struct sd *) gspca_dev;
464 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
465 data = (sd->hflip ? 0x04 : 0x00) | (sd->vflip ? 0x08 : 0x00);
466 reg_w(gspca_dev, 0x21, data);
468 /* load registers to sensor (Bit 0, auto clear) */
469 reg_w(gspca_dev, 0x11, 0x01);
472 /* this function is called at probe and resume time for pac7311 */
473 static int sd_init(struct gspca_dev *gspca_dev)
475 reg_w_seq(gspca_dev, init_7311, sizeof(init_7311)/2);
476 return gspca_dev->usb_err;
479 static int sd_start(struct gspca_dev *gspca_dev)
481 struct sd *sd = (struct sd *) gspca_dev;
485 reg_w_var(gspca_dev, start_7311,
486 page4_7311, sizeof(page4_7311));
487 setcontrast(gspca_dev);
489 setexposure(gspca_dev);
490 sethvflip(gspca_dev);
492 /* set correct resolution */
493 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) {
494 case 2: /* 160x120 */
495 reg_w(gspca_dev, 0xff, 0x01);
496 reg_w(gspca_dev, 0x17, 0x20);
497 reg_w(gspca_dev, 0x87, 0x10);
499 case 1: /* 320x240 */
500 reg_w(gspca_dev, 0xff, 0x01);
501 reg_w(gspca_dev, 0x17, 0x30);
502 reg_w(gspca_dev, 0x87, 0x11);
504 case 0: /* 640x480 */
505 reg_w(gspca_dev, 0xff, 0x01);
506 reg_w(gspca_dev, 0x17, 0x00);
507 reg_w(gspca_dev, 0x87, 0x12);
512 sd->autogain_ignore_frames = 0;
513 atomic_set(&sd->avg_lum, -1);
516 reg_w(gspca_dev, 0xff, 0x01);
517 reg_w(gspca_dev, 0x78, 0x05);
519 return gspca_dev->usb_err;
522 static void sd_stopN(struct gspca_dev *gspca_dev)
524 reg_w(gspca_dev, 0xff, 0x04);
525 reg_w(gspca_dev, 0x27, 0x80);
526 reg_w(gspca_dev, 0x28, 0xca);
527 reg_w(gspca_dev, 0x29, 0x53);
528 reg_w(gspca_dev, 0x2a, 0x0e);
529 reg_w(gspca_dev, 0xff, 0x01);
530 reg_w(gspca_dev, 0x3e, 0x20);
531 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
532 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
533 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
536 /* Include pac common sof detection functions */
537 #include "pac_common.h"
539 static void do_autogain(struct gspca_dev *gspca_dev)
541 struct sd *sd = (struct sd *) gspca_dev;
542 int avg_lum = atomic_read(&sd->avg_lum);
543 int desired_lum, deadzone;
551 if (sd->autogain_ignore_frames > 0)
552 sd->autogain_ignore_frames--;
553 else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, desired_lum,
554 deadzone, GAIN_KNEE, EXPOSURE_KNEE))
555 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
558 /* JPEG header, part 1 */
559 static const unsigned char pac_jpeg_header1[] = {
560 0xff, 0xd8, /* SOI: Start of Image */
562 0xff, 0xc0, /* SOF0: Start of Frame (Baseline DCT) */
563 0x00, 0x11, /* length = 17 bytes (including this length field) */
564 0x08 /* Precision: 8 */
565 /* 2 bytes is placed here: number of image lines */
566 /* 2 bytes is placed here: samples per line */
569 /* JPEG header, continued */
570 static const unsigned char pac_jpeg_header2[] = {
571 0x03, /* Number of image components: 3 */
572 0x01, 0x21, 0x00, /* ID=1, Subsampling 1x1, Quantization table: 0 */
573 0x02, 0x11, 0x01, /* ID=2, Subsampling 2x1, Quantization table: 1 */
574 0x03, 0x11, 0x01, /* ID=3, Subsampling 2x1, Quantization table: 1 */
576 0xff, 0xda, /* SOS: Start Of Scan */
577 0x00, 0x0c, /* length = 12 bytes (including this length field) */
578 0x03, /* number of components: 3 */
579 0x01, 0x00, /* selector 1, table 0x00 */
580 0x02, 0x11, /* selector 2, table 0x11 */
581 0x03, 0x11, /* selector 3, table 0x11 */
582 0x00, 0x3f, /* Spectral selection: 0 .. 63 */
583 0x00 /* Successive approximation: 0 */
586 static void pac_start_frame(struct gspca_dev *gspca_dev,
587 __u16 lines, __u16 samples_per_line)
589 unsigned char tmpbuf[4];
591 gspca_frame_add(gspca_dev, FIRST_PACKET,
592 pac_jpeg_header1, sizeof(pac_jpeg_header1));
594 tmpbuf[0] = lines >> 8;
595 tmpbuf[1] = lines & 0xff;
596 tmpbuf[2] = samples_per_line >> 8;
597 tmpbuf[3] = samples_per_line & 0xff;
599 gspca_frame_add(gspca_dev, INTER_PACKET,
600 tmpbuf, sizeof(tmpbuf));
601 gspca_frame_add(gspca_dev, INTER_PACKET,
602 pac_jpeg_header2, sizeof(pac_jpeg_header2));
605 /* this function is run at interrupt level */
606 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
607 u8 *data, /* isoc packet */
608 int len) /* iso packet length */
610 struct sd *sd = (struct sd *) gspca_dev;
614 sof = pac_find_sof(&sd->sof_read, data, len);
616 int n, lum_offset, footer_length;
618 /* 6 bytes after the FF D9 EOF marker a number of lumination
619 bytes are send corresponding to different parts of the
620 image, the 14th and 15th byte after the EOF seem to
621 correspond to the center of the image */
622 lum_offset = 24 + sizeof pac_sof_marker;
625 /* Finish decoding current frame */
626 n = (sof - data) - (footer_length + sizeof pac_sof_marker);
628 gspca_dev->image_len += n;
631 gspca_frame_add(gspca_dev, INTER_PACKET, data, n);
633 image = gspca_dev->image;
635 && image[gspca_dev->image_len - 2] == 0xff
636 && image[gspca_dev->image_len - 1] == 0xd9)
637 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
643 /* Get average lumination */
644 if (gspca_dev->last_packet_type == LAST_PACKET &&
646 atomic_set(&sd->avg_lum, data[-lum_offset] +
647 data[-lum_offset + 1]);
649 atomic_set(&sd->avg_lum, -1);
651 /* Start the new frame with the jpeg header */
652 pac_start_frame(gspca_dev,
653 gspca_dev->height, gspca_dev->width);
655 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
658 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
660 struct sd *sd = (struct sd *) gspca_dev;
663 if (gspca_dev->streaming)
664 setcontrast(gspca_dev);
665 return gspca_dev->usb_err;
668 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
670 struct sd *sd = (struct sd *) gspca_dev;
676 static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val)
678 struct sd *sd = (struct sd *) gspca_dev;
681 if (gspca_dev->streaming)
683 return gspca_dev->usb_err;
686 static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val)
688 struct sd *sd = (struct sd *) gspca_dev;
694 static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val)
696 struct sd *sd = (struct sd *) gspca_dev;
699 if (gspca_dev->streaming)
700 setexposure(gspca_dev);
701 return gspca_dev->usb_err;
704 static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val)
706 struct sd *sd = (struct sd *) gspca_dev;
712 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
714 struct sd *sd = (struct sd *) gspca_dev;
717 /* when switching to autogain set defaults to make sure
718 we are on a valid point of the autogain gain /
719 exposure knee graph, and give this change time to
720 take effect before doing autogain. */
722 sd->exposure = EXPOSURE_DEF;
724 if (gspca_dev->streaming) {
725 sd->autogain_ignore_frames =
726 PAC_AUTOGAIN_IGNORE_FRAMES;
727 setexposure(gspca_dev);
732 return gspca_dev->usb_err;
735 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
737 struct sd *sd = (struct sd *) gspca_dev;
743 static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
745 struct sd *sd = (struct sd *) gspca_dev;
748 if (gspca_dev->streaming)
749 sethvflip(gspca_dev);
750 return gspca_dev->usb_err;
753 static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val)
755 struct sd *sd = (struct sd *) gspca_dev;
761 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
763 struct sd *sd = (struct sd *) gspca_dev;
766 if (gspca_dev->streaming)
767 sethvflip(gspca_dev);
768 return gspca_dev->usb_err;
771 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
773 struct sd *sd = (struct sd *) gspca_dev;
779 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
780 static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
781 u8 *data, /* interrupt packet data */
782 int len) /* interrupt packet length */
790 if ((data0 == 0x00 && data1 == 0x11) ||
791 (data0 == 0x22 && data1 == 0x33) ||
792 (data0 == 0x44 && data1 == 0x55) ||
793 (data0 == 0x66 && data1 == 0x77) ||
794 (data0 == 0x88 && data1 == 0x99) ||
795 (data0 == 0xaa && data1 == 0xbb) ||
796 (data0 == 0xcc && data1 == 0xdd) ||
797 (data0 == 0xee && data1 == 0xff)) {
798 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
799 input_sync(gspca_dev->input_dev);
800 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
801 input_sync(gspca_dev->input_dev);
810 static const struct sd_desc sd_desc = {
813 .nctrls = ARRAY_SIZE(sd_ctrls),
818 .pkt_scan = sd_pkt_scan,
819 .dq_callback = do_autogain,
820 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
821 .int_pkt_scan = sd_int_pkt_scan,
825 /* -- module initialisation -- */
826 static const struct usb_device_id device_table[] = {
827 {USB_DEVICE(0x093a, 0x2600)},
828 {USB_DEVICE(0x093a, 0x2601)},
829 {USB_DEVICE(0x093a, 0x2603)},
830 {USB_DEVICE(0x093a, 0x2608)},
831 {USB_DEVICE(0x093a, 0x260e)},
832 {USB_DEVICE(0x093a, 0x260f)},
835 MODULE_DEVICE_TABLE(usb, device_table);
837 /* -- device connect -- */
838 static int sd_probe(struct usb_interface *intf,
839 const struct usb_device_id *id)
841 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
845 static struct usb_driver sd_driver = {
847 .id_table = device_table,
849 .disconnect = gspca_disconnect,
851 .suspend = gspca_suspend,
852 .resume = gspca_resume,
856 module_usb_driver(sd_driver);