blob: 54b4ab68f0b5de452318d6459902db52cac64156 [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
2 * Pixart PAC7311 library
3 * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li
4 *
5 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
6 *
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
10 * any later version.
11 *
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.
16 *
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
20 */
21
Hans de Goede327c4ab2008-09-03 17:12:14 -030022/* Some documentation about various registers as determined by trial and error.
Hans de Goede4b8ceb62012-04-28 10:20:50 -030023 *
24 * Register page 1:
25 *
26 * Address Description
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
33 *
34 * Register page 4:
35 *
36 * Address Description
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.
45 */
Hans de Goede327c4ab2008-09-03 17:12:14 -030046
Joe Perches133a9fe2011-08-21 19:56:57 -030047#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
48
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030049#define MODULE_NAME "pac7311"
50
Hans de Goede32ea3e42010-01-29 11:04:19 -030051#include <linux/input.h>
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030052#include "gspca.h"
Hans de Goedea5340ce2012-04-27 11:40:28 -030053/* Include pac common sof detection functions */
54#include "pac_common.h"
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030055
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030056MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li");
57MODULE_DESCRIPTION("Pixart PAC7311");
58MODULE_LICENSE("GPL");
59
Hans de Goedea5340ce2012-04-27 11:40:28 -030060enum e_ctrl {
61 CONTRAST,
62 GAIN,
63 EXPOSURE,
64 AUTOGAIN,
65 HFLIP,
66 VFLIP,
67 NCTRLS /* number of controls */
68};
69
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030070struct sd {
71 struct gspca_dev gspca_dev; /* !! must be the first item */
Hans de Goedea5340ce2012-04-27 11:40:28 -030072 struct gspca_ctrl ctrls[NCTRLS];
Hans de Goedeccab75e2012-04-27 13:06:26 -030073 int exp_too_low_cnt;
74 int exp_too_high_cnt;
Jean-Francois Moine49b57db2008-09-03 16:47:25 -030075
Hans de Goede327c4ab2008-09-03 17:12:14 -030076 u8 sof_read;
Hans de Goede327c4ab2008-09-03 17:12:14 -030077 u8 autogain_ignore_frames;
78
79 atomic_t avg_lum;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030080};
81
82/* V4L2 controls supported by the driver */
Hans de Goedea5340ce2012-04-27 11:40:28 -030083static void setcontrast(struct gspca_dev *gspca_dev);
84static void setgain(struct gspca_dev *gspca_dev);
85static void setexposure(struct gspca_dev *gspca_dev);
Hans de Goedea5340ce2012-04-27 11:40:28 -030086static void sethvflip(struct gspca_dev *gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030087
Marton Nemeth7e64dc42009-12-30 09:12:41 -030088static const struct ctrl sd_ctrls[] = {
Hans de Goedea5340ce2012-04-27 11:40:28 -030089[CONTRAST] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030090 {
91 .id = V4L2_CID_CONTRAST,
92 .type = V4L2_CTRL_TYPE_INTEGER,
93 .name = "Contrast",
94 .minimum = 0,
Hans de Goedea5340ce2012-04-27 11:40:28 -030095 .maximum = 15,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030096 .step = 1,
Hans de Goedea5340ce2012-04-27 11:40:28 -030097 .default_value = 7,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030098 },
Hans de Goedea5340ce2012-04-27 11:40:28 -030099 .set_control = setcontrast
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300100 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300101[GAIN] = {
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300102 {
103 .id = V4L2_CID_GAIN,
104 .type = V4L2_CTRL_TYPE_INTEGER,
105 .name = "Gain",
106 .minimum = 0,
Hans de Goedea5340ce2012-04-27 11:40:28 -0300107 .maximum = 244,
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300108 .step = 1,
Hans de Goedea5340ce2012-04-27 11:40:28 -0300109 .default_value = 122,
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300110 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300111 .set_control = setgain,
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300112 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300113[EXPOSURE] = {
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300114 {
115 .id = V4L2_CID_EXPOSURE,
116 .type = V4L2_CTRL_TYPE_INTEGER,
117 .name = "Exposure",
Hans de Goedec894d262012-04-25 12:17:19 -0300118 .minimum = 2,
Hans de Goedea5340ce2012-04-27 11:40:28 -0300119 .maximum = 63,
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300120 .step = 1,
Hans de Goedeccab75e2012-04-27 13:06:26 -0300121 .default_value = 3, /* 20 fps, avoid using high compr. */
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300122 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300123 .set_control = setexposure,
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300124 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300125[AUTOGAIN] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300126 {
127 .id = V4L2_CID_AUTOGAIN,
128 .type = V4L2_CTRL_TYPE_BOOLEAN,
129 .name = "Auto Gain",
130 .minimum = 0,
131 .maximum = 1,
132 .step = 1,
Hans de Goedea5340ce2012-04-27 11:40:28 -0300133 .default_value = 1,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300134 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300135 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300136[HFLIP] = {
Jean-Francois Moine41b46972008-09-03 16:47:58 -0300137 {
138 .id = V4L2_CID_HFLIP,
139 .type = V4L2_CTRL_TYPE_BOOLEAN,
140 .name = "Mirror",
141 .minimum = 0,
142 .maximum = 1,
143 .step = 1,
Hans de Goedea5340ce2012-04-27 11:40:28 -0300144 .default_value = 0,
Jean-Francois Moine41b46972008-09-03 16:47:58 -0300145 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300146 .set_control = sethvflip,
Jean-Francois Moine41b46972008-09-03 16:47:58 -0300147 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300148[VFLIP] = {
Jean-Francois Moine41b46972008-09-03 16:47:58 -0300149 {
150 .id = V4L2_CID_VFLIP,
151 .type = V4L2_CTRL_TYPE_BOOLEAN,
152 .name = "Vflip",
153 .minimum = 0,
154 .maximum = 1,
155 .step = 1,
Hans de Goedea5340ce2012-04-27 11:40:28 -0300156 .default_value = 0,
Jean-Francois Moine41b46972008-09-03 16:47:58 -0300157 },
Hans de Goedea5340ce2012-04-27 11:40:28 -0300158 .set_control = sethvflip,
Jean-Francois Moine41b46972008-09-03 16:47:58 -0300159 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300160};
161
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300162static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinef75c4952008-09-03 16:47:35 -0300163 {160, 120, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300164 .bytesperline = 160,
165 .sizeimage = 160 * 120 * 3 / 8 + 590,
166 .colorspace = V4L2_COLORSPACE_JPEG,
167 .priv = 2},
Jean-Francois Moinef75c4952008-09-03 16:47:35 -0300168 {320, 240, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300169 .bytesperline = 320,
170 .sizeimage = 320 * 240 * 3 / 8 + 590,
171 .colorspace = V4L2_COLORSPACE_JPEG,
172 .priv = 1},
Jean-Francois Moinef75c4952008-09-03 16:47:35 -0300173 {640, 480, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300174 .bytesperline = 640,
175 .sizeimage = 640 * 480 * 3 / 8 + 590,
176 .colorspace = V4L2_COLORSPACE_JPEG,
177 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300178};
179
Marton Nemeth5a2e8d92009-10-04 13:53:22 -0300180#define LOAD_PAGE4 254
181#define END_OF_SEQUENCE 0
182
Hans de Goede271315a2008-09-03 17:12:19 -0300183static const __u8 init_7311[] = {
Hans de Goede327c4ab2008-09-03 17:12:14 -0300184 0x78, 0x40, /* Bit_0=start stream, Bit_6=LED */
185 0x78, 0x40, /* Bit_0=start stream, Bit_6=LED */
186 0x78, 0x44, /* Bit_0=start stream, Bit_6=LED */
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300187 0xff, 0x04,
188 0x27, 0x80,
189 0x28, 0xca,
190 0x29, 0x53,
191 0x2a, 0x0e,
192 0xff, 0x01,
193 0x3e, 0x20,
194};
195
196static const __u8 start_7311[] = {
197/* index, len, [value]* */
Jean-Francois Moine285a4f62008-09-03 16:47:33 -0300198 0xff, 1, 0x01, /* page 1 */
199 0x02, 43, 0x48, 0x0a, 0x40, 0x08, 0x00, 0x00, 0x08, 0x00,
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300200 0x06, 0xff, 0x11, 0xff, 0x5a, 0x30, 0x90, 0x4c,
201 0x00, 0x07, 0x00, 0x0a, 0x10, 0x00, 0xa0, 0x10,
202 0x02, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x01, 0x00,
203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 0x00, 0x00, 0x00,
Jean-Francois Moine285a4f62008-09-03 16:47:33 -0300205 0x3e, 42, 0x00, 0x00, 0x78, 0x52, 0x4a, 0x52, 0x78, 0x6e,
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300206 0x48, 0x46, 0x48, 0x6e, 0x5f, 0x49, 0x42, 0x49,
207 0x5f, 0x5f, 0x49, 0x42, 0x49, 0x5f, 0x6e, 0x48,
208 0x46, 0x48, 0x6e, 0x78, 0x52, 0x4a, 0x52, 0x78,
209 0x00, 0x00, 0x09, 0x1b, 0x34, 0x49, 0x5c, 0x9b,
210 0xd0, 0xff,
211 0x78, 6, 0x44, 0x00, 0xf2, 0x01, 0x01, 0x80,
212 0x7f, 18, 0x2a, 0x1c, 0x00, 0xc8, 0x02, 0x58, 0x03, 0x84,
213 0x12, 0x00, 0x1a, 0x04, 0x08, 0x0c, 0x10, 0x14,
214 0x18, 0x20,
215 0x96, 3, 0x01, 0x08, 0x04,
216 0xa0, 4, 0x44, 0x44, 0x44, 0x04,
217 0xf0, 13, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x20, 0x00,
218 0x3f, 0x00, 0x0a, 0x01, 0x00,
Jean-Francois Moine285a4f62008-09-03 16:47:33 -0300219 0xff, 1, 0x04, /* page 4 */
Marton Nemeth5a2e8d92009-10-04 13:53:22 -0300220 0, LOAD_PAGE4, /* load the page 4 */
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300221 0x11, 1, 0x01,
Marton Nemeth5a2e8d92009-10-04 13:53:22 -0300222 0, END_OF_SEQUENCE /* end of sequence */
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300223};
224
Marton Nemeth1408b842009-11-02 08:13:21 -0300225#define SKIP 0xaa
Marton Nemethff75e992009-10-04 13:51:26 -0300226/* page 4 - the value SKIP says skip the index - see reg_w_page() */
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300227static const __u8 page4_7311[] = {
Marton Nemethff75e992009-10-04 13:51:26 -0300228 SKIP, SKIP, 0x04, 0x54, 0x07, 0x2b, 0x09, 0x0f,
229 0x09, 0x00, SKIP, SKIP, 0x07, 0x00, 0x00, 0x62,
230 0x08, SKIP, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x00, 0x03, 0xa0, 0x01, 0xf4, SKIP,
232 SKIP, 0x00, 0x08, SKIP, 0x03, SKIP, 0x00, 0x68,
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300233 0xca, 0x10, 0x06, 0x78, 0x00, 0x00, 0x00, 0x00,
234 0x23, 0x28, 0x04, 0x11, 0x00, 0x00
235};
236
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300237static void reg_w_buf(struct gspca_dev *gspca_dev,
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300238 __u8 index,
Jean-François Moine0aeb5ec2010-12-28 06:59:04 -0300239 const u8 *buffer, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300240{
Marton Nemeth4f7309e2009-11-05 05:35:08 -0300241 int ret;
242
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300243 if (gspca_dev->usb_err < 0)
244 return;
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300245 memcpy(gspca_dev->usb_buf, buffer, len);
Marton Nemeth4f7309e2009-11-05 05:35:08 -0300246 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300247 usb_sndctrlpipe(gspca_dev->dev, 0),
Jean-François Moinea1317132010-06-24 04:50:26 -0300248 0, /* request */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300249 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -0300250 0, /* value */
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300251 index, gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300252 500);
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300253 if (ret < 0) {
Joe Perches133a9fe2011-08-21 19:56:57 -0300254 pr_err("reg_w_buf() failed index 0x%02x, error %d\n",
255 index, ret);
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300256 gspca_dev->usb_err = ret;
257 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300258}
259
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300260
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300261static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300262 __u8 index,
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300263 __u8 value)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300264{
Marton Nemeth4f7309e2009-11-05 05:35:08 -0300265 int ret;
266
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300267 if (gspca_dev->usb_err < 0)
268 return;
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300269 gspca_dev->usb_buf[0] = value;
Marton Nemeth4f7309e2009-11-05 05:35:08 -0300270 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300271 usb_sndctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -0300272 0, /* request */
273 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300274 0, index, gspca_dev->usb_buf, 1,
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -0300275 500);
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300276 if (ret < 0) {
Joe Perches133a9fe2011-08-21 19:56:57 -0300277 pr_err("reg_w() failed index 0x%02x, value 0x%02x, error %d\n",
278 index, value, ret);
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300279 gspca_dev->usb_err = ret;
280 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300281}
282
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300283static void reg_w_seq(struct gspca_dev *gspca_dev,
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300284 const __u8 *seq, int len)
285{
286 while (--len >= 0) {
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300287 reg_w(gspca_dev, seq[0], seq[1]);
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300288 seq += 2;
289 }
290}
291
292/* load the beginning of a page */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300293static void reg_w_page(struct gspca_dev *gspca_dev,
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300294 const __u8 *page, int len)
295{
296 int index;
Márton Némethb1784b32009-11-07 05:52:02 -0300297 int ret = 0;
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300298
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300299 if (gspca_dev->usb_err < 0)
300 return;
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300301 for (index = 0; index < len; index++) {
Marton Nemethff75e992009-10-04 13:51:26 -0300302 if (page[index] == SKIP) /* skip this index */
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300303 continue;
304 gspca_dev->usb_buf[0] = page[index];
Marton Nemeth4f7309e2009-11-05 05:35:08 -0300305 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300306 usb_sndctrlpipe(gspca_dev->dev, 0),
307 0, /* request */
308 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
309 0, index, gspca_dev->usb_buf, 1,
310 500);
Márton Némethb1784b32009-11-07 05:52:02 -0300311 if (ret < 0) {
Joe Perches133a9fe2011-08-21 19:56:57 -0300312 pr_err("reg_w_page() failed index 0x%02x, value 0x%02x, error %d\n",
313 index, page[index], ret);
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300314 gspca_dev->usb_err = ret;
Márton Némethb1784b32009-11-07 05:52:02 -0300315 break;
316 }
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300317 }
318}
319
320/* output a variable sequence */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300321static void reg_w_var(struct gspca_dev *gspca_dev,
Marton Nemeth1408b842009-11-02 08:13:21 -0300322 const __u8 *seq,
Marton Nemeth1408b842009-11-02 08:13:21 -0300323 const __u8 *page4, unsigned int page4_len)
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300324{
325 int index, len;
326
327 for (;;) {
328 index = *seq++;
329 len = *seq++;
330 switch (len) {
Marton Nemeth5a2e8d92009-10-04 13:53:22 -0300331 case END_OF_SEQUENCE:
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300332 return;
Marton Nemeth5a2e8d92009-10-04 13:53:22 -0300333 case LOAD_PAGE4:
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300334 reg_w_page(gspca_dev, page4, page4_len);
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300335 break;
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300336 default:
Marton Nemeth24067bb2009-10-04 13:54:48 -0300337 if (len > USB_BUF_SZ) {
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300338 PDEBUG(D_ERR|D_STREAM,
339 "Incorrect variable sequence");
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300340 return;
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300341 }
342 while (len > 0) {
343 if (len < 8) {
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300344 reg_w_buf(gspca_dev,
Márton Némethb1784b32009-11-07 05:52:02 -0300345 index, seq, len);
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300346 seq += len;
347 break;
348 }
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300349 reg_w_buf(gspca_dev, index, seq, 8);
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300350 seq += 8;
351 index += 8;
352 len -= 8;
353 }
354 }
355 }
356 /* not reached */
357}
358
Marton Nemeth1408b842009-11-02 08:13:21 -0300359/* this function is called at probe time for pac7311 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300360static int sd_config(struct gspca_dev *gspca_dev,
361 const struct usb_device_id *id)
362{
363 struct sd *sd = (struct sd *) gspca_dev;
Hans de Goedea5340ce2012-04-27 11:40:28 -0300364 struct cam *cam = &gspca_dev->cam;
Jean-Francois Moine49b57db2008-09-03 16:47:25 -0300365
Marton Nemeth1408b842009-11-02 08:13:21 -0300366 cam->cam_mode = vga_mode;
367 cam->nmodes = ARRAY_SIZE(vga_mode);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300368
Hans de Goedea5340ce2012-04-27 11:40:28 -0300369 gspca_dev->cam.ctrls = sd->ctrls;
370
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300371 return 0;
372}
373
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300374static void setcontrast(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300375{
376 struct sd *sd = (struct sd *) gspca_dev;
377
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300378 reg_w(gspca_dev, 0xff, 0x04);
Hans de Goedea5340ce2012-04-27 11:40:28 -0300379 reg_w(gspca_dev, 0x10, sd->ctrls[CONTRAST].val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300380 /* load registers to sensor (Bit 0, auto clear) */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300381 reg_w(gspca_dev, 0x11, 0x01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300382}
383
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300384static void setgain(struct gspca_dev *gspca_dev)
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300385{
386 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300387
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300388 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
389 reg_w(gspca_dev, 0x0e, 0x00);
Hans de Goedea5340ce2012-04-27 11:40:28 -0300390 reg_w(gspca_dev, 0x0f, sd->ctrls[GAIN].max - sd->ctrls[GAIN].val + 1);
Marton Nemeth1408b842009-11-02 08:13:21 -0300391
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300392 /* load registers to sensor (Bit 0, auto clear) */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300393 reg_w(gspca_dev, 0x11, 0x01);
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300394}
395
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300396static void setexposure(struct gspca_dev *gspca_dev)
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300397{
398 struct sd *sd = (struct sd *) gspca_dev;
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300399
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300400 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
Hans de Goedea5340ce2012-04-27 11:40:28 -0300401 reg_w(gspca_dev, 0x02, sd->ctrls[EXPOSURE].val);
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300402
Hans de Goede51ae23d2012-04-18 06:12:57 -0300403 /* load registers to sensor (Bit 0, auto clear) */
404 reg_w(gspca_dev, 0x11, 0x01);
405
Hans de Goede4b8ceb62012-04-28 10:20:50 -0300406 /*
407 * Page 1 register 8 must always be 0x08 except when not in
408 * 640x480 mode and page 4 reg 2 <= 3 then it must be 9
409 */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300410 reg_w(gspca_dev, 0xff, 0x01);
Marton Nemeth1408b842009-11-02 08:13:21 -0300411 if (gspca_dev->cam.cam_mode[(int)gspca_dev->curr_mode].priv &&
Hans de Goedea5340ce2012-04-27 11:40:28 -0300412 sd->ctrls[EXPOSURE].val <= 3) {
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300413 reg_w(gspca_dev, 0x08, 0x09);
Márton Némethb1784b32009-11-07 05:52:02 -0300414 } else {
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300415 reg_w(gspca_dev, 0x08, 0x08);
Márton Némethb1784b32009-11-07 05:52:02 -0300416 }
Marton Nemeth1408b842009-11-02 08:13:21 -0300417
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300418 /* load registers to sensor (Bit 0, auto clear) */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300419 reg_w(gspca_dev, 0x11, 0x01);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -0300420}
421
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300422static void sethvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine41b46972008-09-03 16:47:58 -0300423{
424 struct sd *sd = (struct sd *) gspca_dev;
425 __u8 data;
426
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300427 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
Hans de Goedea5340ce2012-04-27 11:40:28 -0300428 data = (sd->ctrls[HFLIP].val ? 0x04 : 0x00) |
429 (sd->ctrls[VFLIP].val ? 0x08 : 0x00);
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300430 reg_w(gspca_dev, 0x21, data);
431
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300432 /* load registers to sensor (Bit 0, auto clear) */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300433 reg_w(gspca_dev, 0x11, 0x01);
Jean-Francois Moine41b46972008-09-03 16:47:58 -0300434}
435
Marton Nemeth1408b842009-11-02 08:13:21 -0300436/* this function is called at probe and resume time for pac7311 */
Jean-Francois Moine012d6b02008-09-03 17:12:16 -0300437static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300438{
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300439 reg_w_seq(gspca_dev, init_7311, sizeof(init_7311)/2);
440 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300441}
442
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -0300443static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300444{
Jean-Francois Moinee52a5572008-09-03 16:47:21 -0300445 struct sd *sd = (struct sd *) gspca_dev;
446
Hans de Goede327c4ab2008-09-03 17:12:14 -0300447 sd->sof_read = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300448
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300449 reg_w_var(gspca_dev, start_7311,
Marton Nemeth1408b842009-11-02 08:13:21 -0300450 page4_7311, sizeof(page4_7311));
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300451 setcontrast(gspca_dev);
452 setgain(gspca_dev);
453 setexposure(gspca_dev);
454 sethvflip(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300455
456 /* set correct resolution */
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300457 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) {
Hans de Goedeb053c1d2012-04-25 12:00:49 -0300458 case 2: /* 160x120 */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300459 reg_w(gspca_dev, 0xff, 0x01);
460 reg_w(gspca_dev, 0x17, 0x20);
461 reg_w(gspca_dev, 0x87, 0x10);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300462 break;
Hans de Goedeb053c1d2012-04-25 12:00:49 -0300463 case 1: /* 320x240 */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300464 reg_w(gspca_dev, 0xff, 0x01);
465 reg_w(gspca_dev, 0x17, 0x30);
466 reg_w(gspca_dev, 0x87, 0x11);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300467 break;
468 case 0: /* 640x480 */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300469 reg_w(gspca_dev, 0xff, 0x01);
470 reg_w(gspca_dev, 0x17, 0x00);
471 reg_w(gspca_dev, 0x87, 0x12);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300472 break;
473 }
474
Hans de Goede327c4ab2008-09-03 17:12:14 -0300475 sd->sof_read = 0;
476 sd->autogain_ignore_frames = 0;
477 atomic_set(&sd->avg_lum, -1);
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300478
479 /* start stream */
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300480 reg_w(gspca_dev, 0xff, 0x01);
481 reg_w(gspca_dev, 0x78, 0x05);
Marton Nemeth1408b842009-11-02 08:13:21 -0300482
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300483 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300484}
485
486static void sd_stopN(struct gspca_dev *gspca_dev)
487{
Jean-Francois Moine14799f62010-01-13 15:28:22 -0300488 reg_w(gspca_dev, 0xff, 0x04);
489 reg_w(gspca_dev, 0x27, 0x80);
490 reg_w(gspca_dev, 0x28, 0xca);
491 reg_w(gspca_dev, 0x29, 0x53);
492 reg_w(gspca_dev, 0x2a, 0x0e);
493 reg_w(gspca_dev, 0xff, 0x01);
494 reg_w(gspca_dev, 0x3e, 0x20);
495 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
496 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
497 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300498}
499
Hans de Goedeccab75e2012-04-27 13:06:26 -0300500#define WANT_COARSE_EXPO_AUTOGAIN
Hans de Goedea5340ce2012-04-27 11:40:28 -0300501#include "autogain_functions.h"
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300502
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -0300503static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300504{
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300505 struct sd *sd = (struct sd *) gspca_dev;
506 int avg_lum = atomic_read(&sd->avg_lum);
Hans de Goede038ec7c2008-09-03 17:12:18 -0300507 int desired_lum, deadzone;
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300508
Hans de Goedea5340ce2012-04-27 11:40:28 -0300509 if (sd->ctrls[AUTOGAIN].val == 0 || avg_lum == -1)
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300510 return;
511
Marton Nemeth1408b842009-11-02 08:13:21 -0300512 desired_lum = 200;
513 deadzone = 20;
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300514
515 if (sd->autogain_ignore_frames > 0)
516 sd->autogain_ignore_frames--;
Hans de Goedeccab75e2012-04-27 13:06:26 -0300517 else if (coarse_grained_expo_autogain(gspca_dev, avg_lum, desired_lum,
518 deadzone))
Hans de Goede8a5b2e92008-09-03 17:12:17 -0300519 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300520}
521
Marton Nemeth56f6f552009-10-04 13:58:19 -0300522/* JPEG header, part 1 */
Marton Nemethcc409c02009-11-02 08:09:34 -0300523static const unsigned char pac_jpeg_header1[] = {
Marton Nemeth56f6f552009-10-04 13:58:19 -0300524 0xff, 0xd8, /* SOI: Start of Image */
525
526 0xff, 0xc0, /* SOF0: Start of Frame (Baseline DCT) */
527 0x00, 0x11, /* length = 17 bytes (including this length field) */
528 0x08 /* Precision: 8 */
529 /* 2 bytes is placed here: number of image lines */
530 /* 2 bytes is placed here: samples per line */
Hans de Goede327c4ab2008-09-03 17:12:14 -0300531};
532
Marton Nemeth56f6f552009-10-04 13:58:19 -0300533/* JPEG header, continued */
Marton Nemethcc409c02009-11-02 08:09:34 -0300534static const unsigned char pac_jpeg_header2[] = {
Marton Nemeth56f6f552009-10-04 13:58:19 -0300535 0x03, /* Number of image components: 3 */
536 0x01, 0x21, 0x00, /* ID=1, Subsampling 1x1, Quantization table: 0 */
537 0x02, 0x11, 0x01, /* ID=2, Subsampling 2x1, Quantization table: 1 */
538 0x03, 0x11, 0x01, /* ID=3, Subsampling 2x1, Quantization table: 1 */
539
540 0xff, 0xda, /* SOS: Start Of Scan */
541 0x00, 0x0c, /* length = 12 bytes (including this length field) */
542 0x03, /* number of components: 3 */
543 0x01, 0x00, /* selector 1, table 0x00 */
544 0x02, 0x11, /* selector 2, table 0x11 */
545 0x03, 0x11, /* selector 3, table 0x11 */
546 0x00, 0x3f, /* Spectral selection: 0 .. 63 */
547 0x00 /* Successive approximation: 0 */
Hans de Goede327c4ab2008-09-03 17:12:14 -0300548};
549
Marton Nemethcc409c02009-11-02 08:09:34 -0300550static void pac_start_frame(struct gspca_dev *gspca_dev,
Marton Nemethcc409c02009-11-02 08:09:34 -0300551 __u16 lines, __u16 samples_per_line)
552{
553 unsigned char tmpbuf[4];
554
Jean-Francois Moine76dd2722009-11-13 09:21:03 -0300555 gspca_frame_add(gspca_dev, FIRST_PACKET,
Marton Nemethcc409c02009-11-02 08:09:34 -0300556 pac_jpeg_header1, sizeof(pac_jpeg_header1));
557
558 tmpbuf[0] = lines >> 8;
559 tmpbuf[1] = lines & 0xff;
560 tmpbuf[2] = samples_per_line >> 8;
561 tmpbuf[3] = samples_per_line & 0xff;
562
Jean-Francois Moine76dd2722009-11-13 09:21:03 -0300563 gspca_frame_add(gspca_dev, INTER_PACKET,
Marton Nemethcc409c02009-11-02 08:09:34 -0300564 tmpbuf, sizeof(tmpbuf));
Jean-Francois Moine76dd2722009-11-13 09:21:03 -0300565 gspca_frame_add(gspca_dev, INTER_PACKET,
Marton Nemethcc409c02009-11-02 08:09:34 -0300566 pac_jpeg_header2, sizeof(pac_jpeg_header2));
567}
568
Jean-Francois Moinee52a5572008-09-03 16:47:21 -0300569/* this function is run at interrupt level */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300570static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine76dd2722009-11-13 09:21:03 -0300571 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300572 int len) /* iso packet length */
573{
574 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moineb192ca92010-06-27 03:08:19 -0300575 u8 *image;
Hans de Goede327c4ab2008-09-03 17:12:14 -0300576 unsigned char *sof;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300577
Marton Nemetha6b69e42009-11-02 08:05:51 -0300578 sof = pac_find_sof(&sd->sof_read, data, len);
Hans de Goede327c4ab2008-09-03 17:12:14 -0300579 if (sof) {
Hans de Goede327c4ab2008-09-03 17:12:14 -0300580 int n, lum_offset, footer_length;
Jean-Francois Moinee52a5572008-09-03 16:47:21 -0300581
Hans de Goede4b8ceb62012-04-28 10:20:50 -0300582 /*
583 * 6 bytes after the FF D9 EOF marker a number of lumination
584 * bytes are send corresponding to different parts of the
585 * image, the 14th and 15th byte after the EOF seem to
586 * correspond to the center of the image.
587 */
Marton Nemeth1408b842009-11-02 08:13:21 -0300588 lum_offset = 24 + sizeof pac_sof_marker;
589 footer_length = 26;
Hans de Goede327c4ab2008-09-03 17:12:14 -0300590
591 /* Finish decoding current frame */
592 n = (sof - data) - (footer_length + sizeof pac_sof_marker);
593 if (n < 0) {
Jean-François Moineb192ca92010-06-27 03:08:19 -0300594 gspca_dev->image_len += n;
Hans de Goede327c4ab2008-09-03 17:12:14 -0300595 n = 0;
Jean-François Moineb192ca92010-06-27 03:08:19 -0300596 } else {
597 gspca_frame_add(gspca_dev, INTER_PACKET, data, n);
Hans de Goede327c4ab2008-09-03 17:12:14 -0300598 }
Jean-François Moinef7059ea2010-07-06 04:32:27 -0300599 image = gspca_dev->image;
600 if (image != NULL
Jean-François Moineb192ca92010-06-27 03:08:19 -0300601 && image[gspca_dev->image_len - 2] == 0xff
602 && image[gspca_dev->image_len - 1] == 0xd9)
603 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
Hans de Goede327c4ab2008-09-03 17:12:14 -0300604
605 n = sof - data;
606 len -= n;
607 data = sof;
608
609 /* Get average lumination */
610 if (gspca_dev->last_packet_type == LAST_PACKET &&
Hans de Goede038ec7c2008-09-03 17:12:18 -0300611 n >= lum_offset)
612 atomic_set(&sd->avg_lum, data[-lum_offset] +
Hans de Goede327c4ab2008-09-03 17:12:14 -0300613 data[-lum_offset + 1]);
Hans de Goede038ec7c2008-09-03 17:12:18 -0300614 else
Hans de Goede327c4ab2008-09-03 17:12:14 -0300615 atomic_set(&sd->avg_lum, -1);
Hans de Goede327c4ab2008-09-03 17:12:14 -0300616
617 /* Start the new frame with the jpeg header */
Jean-François Moineb192ca92010-06-27 03:08:19 -0300618 pac_start_frame(gspca_dev,
Marton Nemeth1408b842009-11-02 08:13:21 -0300619 gspca_dev->height, gspca_dev->width);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300620 }
Jean-Francois Moine76dd2722009-11-13 09:21:03 -0300621 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300622}
623
Jean-François Moine28566432010-10-01 07:33:26 -0300624#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede32ea3e42010-01-29 11:04:19 -0300625static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
626 u8 *data, /* interrupt packet data */
627 int len) /* interrupt packet length */
628{
629 int ret = -EINVAL;
630 u8 data0, data1;
631
632 if (len == 2) {
633 data0 = data[0];
634 data1 = data[1];
635 if ((data0 == 0x00 && data1 == 0x11) ||
636 (data0 == 0x22 && data1 == 0x33) ||
637 (data0 == 0x44 && data1 == 0x55) ||
638 (data0 == 0x66 && data1 == 0x77) ||
639 (data0 == 0x88 && data1 == 0x99) ||
640 (data0 == 0xaa && data1 == 0xbb) ||
641 (data0 == 0xcc && data1 == 0xdd) ||
642 (data0 == 0xee && data1 == 0xff)) {
643 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
644 input_sync(gspca_dev->input_dev);
645 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
646 input_sync(gspca_dev->input_dev);
647 ret = 0;
648 }
649 }
650
651 return ret;
652}
653#endif
654
Márton Némethaabcdfb2010-01-05 12:39:02 -0300655static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300656 .name = MODULE_NAME,
657 .ctrls = sd_ctrls,
658 .nctrls = ARRAY_SIZE(sd_ctrls),
659 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -0300660 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300661 .start = sd_start,
662 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300663 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -0300664 .dq_callback = do_autogain,
Jean-François Moine28566432010-10-01 07:33:26 -0300665#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede32ea3e42010-01-29 11:04:19 -0300666 .int_pkt_scan = sd_int_pkt_scan,
667#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300668};
669
670/* -- module initialisation -- */
Jean-François Moine95c967c2011-01-13 05:20:29 -0300671static const struct usb_device_id device_table[] = {
Marton Nemeth1408b842009-11-02 08:13:21 -0300672 {USB_DEVICE(0x093a, 0x2600)},
673 {USB_DEVICE(0x093a, 0x2601)},
674 {USB_DEVICE(0x093a, 0x2603)},
675 {USB_DEVICE(0x093a, 0x2608)},
676 {USB_DEVICE(0x093a, 0x260e)},
677 {USB_DEVICE(0x093a, 0x260f)},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300678 {}
679};
680MODULE_DEVICE_TABLE(usb, device_table);
681
682/* -- device connect -- */
Jean-François Moine95c967c2011-01-13 05:20:29 -0300683static int sd_probe(struct usb_interface *intf,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300684 const struct usb_device_id *id)
685{
686 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
687 THIS_MODULE);
688}
689
690static struct usb_driver sd_driver = {
691 .name = MODULE_NAME,
692 .id_table = device_table,
693 .probe = sd_probe,
694 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -0300695#ifdef CONFIG_PM
696 .suspend = gspca_suspend,
697 .resume = gspca_resume,
698#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300699};
700
Greg Kroah-Hartmanecb3b2b2011-11-18 09:46:12 -0800701module_usb_driver(sd_driver);