blob: ad97b0be5f39b6bf4967e212373ad6618f2001fc [file] [log] [blame]
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -03001/*
2 * ov534/ov772x gspca driver
3 * Copyright (C) 2008 Antonio Ospite <ospite@studenti.unina.it>
Jim Paris0f7a50b2008-12-10 05:45:14 -03004 * Copyright (C) 2008 Jim Paris <jim@jtan.com>
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -03005 *
6 * Based on a prototype written by Mark Ferrell <majortrips@gmail.com>
7 * USB protocol reverse engineered by Jim Paris <jim@jtan.com>
8 * https://jim.sh/svn/jim/devl/playstation/ps3/eye/test/
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#define MODULE_NAME "ov534"
26
27#include "gspca.h"
28
29#define OV534_REG_ADDRESS 0xf1 /* ? */
30#define OV534_REG_SUBADDR 0xf2
31#define OV534_REG_WRITE 0xf3
32#define OV534_REG_READ 0xf4
33#define OV534_REG_OPERATION 0xf5
34#define OV534_REG_STATUS 0xf6
35
36#define OV534_OP_WRITE_3 0x37
37#define OV534_OP_WRITE_2 0x33
38#define OV534_OP_READ_2 0xf9
39
40#define CTRL_TIMEOUT 500
41
42MODULE_AUTHOR("Antonio Ospite <ospite@studenti.unina.it>");
43MODULE_DESCRIPTION("GSPCA/OV534 USB Camera Driver");
44MODULE_LICENSE("GPL");
45
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030046/* specific webcam descriptor */
47struct sd {
48 struct gspca_dev gspca_dev; /* !! must be the first item */
Jean-Francois Moine8c252052008-12-04 05:06:08 -030049 __u32 last_fid;
50 __u32 last_pts;
Jim Paris11d9f252008-12-10 06:06:20 -030051 int frame_rate;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030052};
53
54/* V4L2 controls supported by the driver */
55static struct ctrl sd_ctrls[] = {
56};
57
58static struct v4l2_pix_format vga_mode[] = {
59 {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
60 .bytesperline = 640 * 2,
61 .sizeimage = 640 * 480 * 2,
62 .colorspace = V4L2_COLORSPACE_JPEG,
63 .priv = 0},
64};
65
Antonio Ospite9e1e7b02008-12-03 14:10:01 -030066static void ov534_reg_write(struct usb_device *udev, u16 reg, u8 val)
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030067{
Antonio Ospite9e1e7b02008-12-03 14:10:01 -030068 u8 data = val;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030069 int ret;
70
Antonio Ospite9e1e7b02008-12-03 14:10:01 -030071 PDEBUG(D_USBO, "reg=0x%04x, val=0%02x", reg, val);
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030072 ret = usb_control_msg(udev,
73 usb_sndctrlpipe(udev, 0),
74 0x1,
75 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
76 0x0, reg, &data, 1, CTRL_TIMEOUT);
77 if (ret < 0)
78 PDEBUG(D_ERR, "write failed");
79}
80
Antonio Ospite9e1e7b02008-12-03 14:10:01 -030081static u8 ov534_reg_read(struct usb_device *udev, u16 reg)
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030082{
Antonio Ospite9e1e7b02008-12-03 14:10:01 -030083 u8 data;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030084 int ret;
85
86 ret = usb_control_msg(udev,
87 usb_rcvctrlpipe(udev, 0),
88 0x1,
89 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
90 0x0, reg, &data, 1, CTRL_TIMEOUT);
Antonio Ospite9e1e7b02008-12-03 14:10:01 -030091 PDEBUG(D_USBI, "reg=0x%04x, data=0x%02x", reg, data);
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030092 if (ret < 0)
93 PDEBUG(D_ERR, "read failed");
94 return data;
95}
96
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -030097/* Two bits control LED: 0x21 bit 7 and 0x23 bit 7.
98 * (direction and output)? */
99static void ov534_set_led(struct usb_device *udev, int status)
100{
Antonio Ospite9e1e7b02008-12-03 14:10:01 -0300101 u8 data;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300102
103 PDEBUG(D_CONF, "led status: %d", status);
104
105 data = ov534_reg_read(udev, 0x21);
106 data |= 0x80;
107 ov534_reg_write(udev, 0x21, data);
108
109 data = ov534_reg_read(udev, 0x23);
110 if (status)
111 data |= 0x80;
112 else
113 data &= ~(0x80);
114
115 ov534_reg_write(udev, 0x23, data);
116}
117
118static int sccb_check_status(struct usb_device *udev)
119{
Antonio Ospite9e1e7b02008-12-03 14:10:01 -0300120 u8 data;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300121 int i;
122
123 for (i = 0; i < 5; i++) {
124 data = ov534_reg_read(udev, OV534_REG_STATUS);
125
Antonio Ospite9e1e7b02008-12-03 14:10:01 -0300126 switch (data) {
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300127 case 0x00:
128 return 1;
129 case 0x04:
130 return 0;
131 case 0x03:
132 break;
133 default:
134 PDEBUG(D_ERR, "sccb status 0x%02x, attempt %d/5\n",
135 data, i + 1);
136 }
137 }
138 return 0;
139}
140
Antonio Ospite9e1e7b02008-12-03 14:10:01 -0300141static void sccb_reg_write(struct usb_device *udev, u16 reg, u8 val)
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300142{
Antonio Ospite9e1e7b02008-12-03 14:10:01 -0300143 PDEBUG(D_USBO, "reg: 0x%04x, val: 0x%02x", reg, val);
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300144 ov534_reg_write(udev, OV534_REG_SUBADDR, reg);
145 ov534_reg_write(udev, OV534_REG_WRITE, val);
146 ov534_reg_write(udev, OV534_REG_OPERATION, OV534_OP_WRITE_3);
147
148 if (!sccb_check_status(udev))
149 PDEBUG(D_ERR, "sccb_reg_write failed");
150}
151
Antonio Ospitee6e48372008-12-14 05:48:07 -0300152static u8 sccb_reg_read(struct usb_device *udev, u16 reg)
153{
154 ov534_reg_write(udev, OV534_REG_SUBADDR, reg);
155 ov534_reg_write(udev, OV534_REG_OPERATION, OV534_OP_WRITE_2);
156 if (!sccb_check_status(udev))
157 PDEBUG(D_ERR, "sccb_reg_read failed 1");
158
159 ov534_reg_write(udev, OV534_REG_OPERATION, OV534_OP_READ_2);
160 if (!sccb_check_status(udev))
161 PDEBUG(D_ERR, "sccb_reg_read failed 2");
162
163 return ov534_reg_read(udev, OV534_REG_READ);
164}
165
Jim Paris47dfd212008-12-04 04:28:27 -0300166static const __u8 ov534_reg_initdata[][2] = {
167 { 0xe7, 0x3a },
168
169 { OV534_REG_ADDRESS, 0x42 }, /* select OV772x sensor */
170
171 { 0xc2, 0x0c },
172 { 0x88, 0xf8 },
173 { 0xc3, 0x69 },
174 { 0x89, 0xff },
175 { 0x76, 0x03 },
176 { 0x92, 0x01 },
177 { 0x93, 0x18 },
178 { 0x94, 0x10 },
179 { 0x95, 0x10 },
180 { 0xe2, 0x00 },
181 { 0xe7, 0x3e },
182
Jim Paris47dfd212008-12-04 04:28:27 -0300183 { 0x96, 0x00 },
184
185 { 0x97, 0x20 },
186 { 0x97, 0x20 },
187 { 0x97, 0x20 },
188 { 0x97, 0x0a },
189 { 0x97, 0x3f },
190 { 0x97, 0x4a },
191 { 0x97, 0x20 },
192 { 0x97, 0x15 },
193 { 0x97, 0x0b },
194
195 { 0x8e, 0x40 },
196 { 0x1f, 0x81 },
197 { 0x34, 0x05 },
198 { 0xe3, 0x04 },
199 { 0x88, 0x00 },
200 { 0x89, 0x00 },
201 { 0x76, 0x00 },
202 { 0xe7, 0x2e },
203 { 0x31, 0xf9 },
204 { 0x25, 0x42 },
205 { 0x21, 0xf0 },
206
207 { 0x1c, 0x00 },
208 { 0x1d, 0x40 },
Jim Paris0f7a50b2008-12-10 05:45:14 -0300209 { 0x1d, 0x02 }, /* payload size 0x0200 * 4 = 2048 bytes */
210 { 0x1d, 0x00 }, /* payload size */
Jim Paris5ea9c4d2008-12-04 04:36:14 -0300211 { 0x1d, 0x02 }, /* frame size 0x025800 * 4 = 614400 */
212 { 0x1d, 0x58 }, /* frame size */
213 { 0x1d, 0x00 }, /* frame size */
Jim Paris47dfd212008-12-04 04:28:27 -0300214
Jim Parisc06eb612008-12-10 05:47:44 -0300215 { 0x1c, 0x0a },
216 { 0x1d, 0x08 }, /* turn on UVC header */
217 { 0x1d, 0x0e }, /* .. */
218
Jim Paris47dfd212008-12-04 04:28:27 -0300219 { 0x8d, 0x1c },
220 { 0x8e, 0x80 },
221 { 0xe5, 0x04 },
222
223 { 0xc0, 0x50 },
224 { 0xc1, 0x3c },
225 { 0xc2, 0x0c },
226};
227
228static const __u8 ov772x_reg_initdata[][2] = {
229 { 0x12, 0x80 },
230 { 0x11, 0x01 },
231
232 { 0x3d, 0x03 },
233 { 0x17, 0x26 },
234 { 0x18, 0xa0 },
235 { 0x19, 0x07 },
236 { 0x1a, 0xf0 },
237 { 0x32, 0x00 },
238 { 0x29, 0xa0 },
239 { 0x2c, 0xf0 },
240 { 0x65, 0x20 },
241 { 0x11, 0x01 },
242 { 0x42, 0x7f },
243 { 0x63, 0xe0 },
244 { 0x64, 0xff },
245 { 0x66, 0x00 },
246 { 0x13, 0xf0 },
247 { 0x0d, 0x41 },
248 { 0x0f, 0xc5 },
249 { 0x14, 0x11 },
250
251 { 0x22, 0x7f },
252 { 0x23, 0x03 },
253 { 0x24, 0x40 },
254 { 0x25, 0x30 },
255 { 0x26, 0xa1 },
256 { 0x2a, 0x00 },
257 { 0x2b, 0x00 },
258 { 0x6b, 0xaa },
259 { 0x13, 0xff },
260
261 { 0x90, 0x05 },
262 { 0x91, 0x01 },
263 { 0x92, 0x03 },
264 { 0x93, 0x00 },
265 { 0x94, 0x60 },
266 { 0x95, 0x3c },
267 { 0x96, 0x24 },
268 { 0x97, 0x1e },
269 { 0x98, 0x62 },
270 { 0x99, 0x80 },
271 { 0x9a, 0x1e },
272 { 0x9b, 0x08 },
273 { 0x9c, 0x20 },
274 { 0x9e, 0x81 },
275
276 { 0xa6, 0x04 },
277 { 0x7e, 0x0c },
278 { 0x7f, 0x16 },
279 { 0x80, 0x2a },
280 { 0x81, 0x4e },
281 { 0x82, 0x61 },
282 { 0x83, 0x6f },
283 { 0x84, 0x7b },
284 { 0x85, 0x86 },
285 { 0x86, 0x8e },
286 { 0x87, 0x97 },
287 { 0x88, 0xa4 },
288 { 0x89, 0xaf },
289 { 0x8a, 0xc5 },
290 { 0x8b, 0xd7 },
291 { 0x8c, 0xe8 },
292 { 0x8d, 0x20 },
293
294 { 0x0c, 0x90 },
295
296 { 0x2b, 0x00 },
297 { 0x22, 0x7f },
298 { 0x23, 0x03 },
299 { 0x11, 0x01 },
300 { 0x0c, 0xd0 },
301 { 0x64, 0xff },
302 { 0x0d, 0x41 },
303
304 { 0x14, 0x41 },
305 { 0x0e, 0xcd },
306 { 0xac, 0xbf },
307 { 0x8e, 0x00 },
308 { 0x0c, 0xd0 }
309};
310
Jim Paris11d9f252008-12-10 06:06:20 -0300311/* set framerate */
312static void ov534_set_frame_rate(struct gspca_dev *gspca_dev)
313{
314 struct sd *sd = (struct sd *) gspca_dev;
315 int fr = sd->frame_rate;
316
317 switch (fr) {
318 case 50:
319 sccb_reg_write(gspca_dev->dev, 0x11, 0x01);
320 sccb_reg_write(gspca_dev->dev, 0x0d, 0x41);
321 ov534_reg_write(gspca_dev->dev, 0xe5, 0x02);
322 break;
323 case 40:
324 sccb_reg_write(gspca_dev->dev, 0x11, 0x02);
325 sccb_reg_write(gspca_dev->dev, 0x0d, 0xc1);
326 ov534_reg_write(gspca_dev->dev, 0xe5, 0x04);
327 break;
328/* case 30: */
329 default:
330 fr = 30;
331 sccb_reg_write(gspca_dev->dev, 0x11, 0x04);
332 sccb_reg_write(gspca_dev->dev, 0x0d, 0x81);
333 ov534_reg_write(gspca_dev->dev, 0xe5, 0x02);
334 break;
335 case 15:
336 sccb_reg_write(gspca_dev->dev, 0x11, 0x03);
337 sccb_reg_write(gspca_dev->dev, 0x0d, 0x41);
338 ov534_reg_write(gspca_dev->dev, 0xe5, 0x04);
339 break;
340 }
341
342 sd->frame_rate = fr;
343 PDEBUG(D_PROBE, "frame_rate: %d", fr);
344}
Jim Paris47dfd212008-12-04 04:28:27 -0300345
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300346/* setup method */
347static void ov534_setup(struct usb_device *udev)
348{
Jim Paris47dfd212008-12-04 04:28:27 -0300349 int i;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300350
Jim Paris47dfd212008-12-04 04:28:27 -0300351 /* Initialize bridge chip */
352 for (i = 0; i < ARRAY_SIZE(ov534_reg_initdata); i++)
353 ov534_reg_write(udev, ov534_reg_initdata[i][0],
354 ov534_reg_initdata[i][1]);
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300355
Antonio Ospitee6e48372008-12-14 05:48:07 -0300356 PDEBUG(D_PROBE, "sensor is ov%02x%02x",
357 sccb_reg_read(udev, 0x0a), sccb_reg_read(udev, 0x0b));
358
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300359 ov534_set_led(udev, 1);
360
Jim Paris47dfd212008-12-04 04:28:27 -0300361 /* Initialize sensor */
362 for (i = 0; i < ARRAY_SIZE(ov772x_reg_initdata); i++)
363 sccb_reg_write(udev, ov772x_reg_initdata[i][0],
364 ov772x_reg_initdata[i][1]);
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300365
366 ov534_reg_write(udev, 0xe0, 0x09);
367 ov534_set_led(udev, 0);
368}
369
370/* this function is called at probe time */
371static int sd_config(struct gspca_dev *gspca_dev,
372 const struct usb_device_id *id)
373{
374 struct cam *cam;
375
376 cam = &gspca_dev->cam;
377
378 cam->epaddr = 0x01;
379 cam->cam_mode = vga_mode;
380 cam->nmodes = ARRAY_SIZE(vga_mode);
381
Jim Paris0f7a50b2008-12-10 05:45:14 -0300382 cam->bulk_size = 16384;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300383 cam->bulk_nurbs = 2;
384
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300385 return 0;
386}
387
388/* this function is called at probe and resume time */
389static int sd_init(struct gspca_dev *gspca_dev)
390{
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300391 ov534_setup(gspca_dev->dev);
Jim Paris11d9f252008-12-10 06:06:20 -0300392 ov534_set_frame_rate(gspca_dev);
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300393
394 return 0;
395}
396
397static int sd_start(struct gspca_dev *gspca_dev)
398{
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300399 /* start streaming data */
400 ov534_set_led(gspca_dev->dev, 1);
401 ov534_reg_write(gspca_dev->dev, 0xe0, 0x00);
402
403 return 0;
404}
405
406static void sd_stopN(struct gspca_dev *gspca_dev)
407{
408 /* stop streaming data */
409 ov534_reg_write(gspca_dev->dev, 0xe0, 0x09);
410 ov534_set_led(gspca_dev->dev, 0);
411}
412
Jim Parisfb139222008-12-04 04:52:40 -0300413/* Values for bmHeaderInfo (Video and Still Image Payload Headers, 2.4.3.3) */
414#define UVC_STREAM_EOH (1 << 7)
415#define UVC_STREAM_ERR (1 << 6)
416#define UVC_STREAM_STI (1 << 5)
417#define UVC_STREAM_RES (1 << 4)
418#define UVC_STREAM_SCR (1 << 3)
419#define UVC_STREAM_PTS (1 << 2)
420#define UVC_STREAM_EOF (1 << 1)
421#define UVC_STREAM_FID (1 << 0)
422
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300423static void sd_pkt_scan(struct gspca_dev *gspca_dev, struct gspca_frame *frame,
424 __u8 *data, int len)
425{
Jean-Francois Moine8c252052008-12-04 05:06:08 -0300426 struct sd *sd = (struct sd *) gspca_dev;
Jim Parisfb139222008-12-04 04:52:40 -0300427 __u32 this_pts;
Jim Parisfb139222008-12-04 04:52:40 -0300428 int this_fid;
Jim Paris0f7a50b2008-12-10 05:45:14 -0300429 int remaining_len = len;
430 __u8 *next_data = data;
431
432scan_next:
433 if (remaining_len <= 0)
434 return;
435
436 data = next_data;
437 len = min(remaining_len, 2048);
438 remaining_len -= len;
439 next_data += len;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300440
Antonio Ospite15e32092008-12-14 05:41:56 -0300441 /* Payloads are prefixed with a UVC-style header. We
Jim Parisfb139222008-12-04 04:52:40 -0300442 consider a frame to start when the FID toggles, or the PTS
443 changes. A frame ends when EOF is set, and we've received
444 the correct number of bytes. */
445
446 /* Verify UVC header. Header length is always 12 */
447 if (data[0] != 12 || len < 12) {
448 PDEBUG(D_PACK, "bad header");
449 goto discard;
450 }
451
452 /* Check errors */
453 if (data[1] & UVC_STREAM_ERR) {
454 PDEBUG(D_PACK, "payload error");
455 goto discard;
456 }
457
458 /* Extract PTS and FID */
459 if (!(data[1] & UVC_STREAM_PTS)) {
460 PDEBUG(D_PACK, "PTS not present");
461 goto discard;
462 }
463 this_pts = (data[5] << 24) | (data[4] << 16) | (data[3] << 8) | data[2];
464 this_fid = (data[1] & UVC_STREAM_FID) ? 1 : 0;
465
466 /* If PTS or FID has changed, start a new frame. */
Jean-Francois Moine8c252052008-12-04 05:06:08 -0300467 if (this_pts != sd->last_pts || this_fid != sd->last_fid) {
Jim Parisfb139222008-12-04 04:52:40 -0300468 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, NULL, 0);
Jean-Francois Moine8c252052008-12-04 05:06:08 -0300469 sd->last_pts = this_pts;
470 sd->last_fid = this_fid;
Jim Parisfb139222008-12-04 04:52:40 -0300471 }
472
473 /* Add the data from this payload */
474 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
475 data + 12, len - 12);
476
477 /* If this packet is marked as EOF, end the frame */
478 if (data[1] & UVC_STREAM_EOF) {
Jean-Francois Moine8c252052008-12-04 05:06:08 -0300479 sd->last_pts = 0;
Jim Parisfb139222008-12-04 04:52:40 -0300480
481 if ((frame->data_end - frame->data) !=
482 (gspca_dev->width * gspca_dev->height * 2)) {
483 PDEBUG(D_PACK, "short frame");
484 goto discard;
485 }
486
487 gspca_frame_add(gspca_dev, LAST_PACKET, frame, NULL, 0);
488 }
489
Jim Paris0f7a50b2008-12-10 05:45:14 -0300490 /* Done this payload */
491 goto scan_next;
Jim Parisfb139222008-12-04 04:52:40 -0300492
493discard:
494 /* Discard data until a new frame starts. */
495 gspca_frame_add(gspca_dev, DISCARD_PACKET, frame, NULL, 0);
Jim Paris0f7a50b2008-12-10 05:45:14 -0300496 goto scan_next;
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300497}
498
Jim Paris11d9f252008-12-10 06:06:20 -0300499/* get stream parameters (framerate) */
500int sd_get_streamparm(struct gspca_dev *gspca_dev,
501 struct v4l2_streamparm *parm)
502{
503 struct v4l2_captureparm *cp = &parm->parm.capture;
504 struct v4l2_fract *tpf = &cp->timeperframe;
505 struct sd *sd = (struct sd *) gspca_dev;
506
507 if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
508 return -EINVAL;
509
510 cp->capability |= V4L2_CAP_TIMEPERFRAME;
511 tpf->numerator = 1;
512 tpf->denominator = sd->frame_rate;
513
514 return 0;
515}
516
517/* set stream parameters (framerate) */
518int sd_set_streamparm(struct gspca_dev *gspca_dev,
519 struct v4l2_streamparm *parm)
520{
521 struct v4l2_captureparm *cp = &parm->parm.capture;
522 struct v4l2_fract *tpf = &cp->timeperframe;
523 struct sd *sd = (struct sd *) gspca_dev;
524
525 if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
526 return -EINVAL;
527
528 /* Set requested framerate */
529 sd->frame_rate = tpf->denominator / tpf->numerator;
530 ov534_set_frame_rate(gspca_dev);
531
532 /* Return the actual framerate */
533 tpf->numerator = 1;
534 tpf->denominator = sd->frame_rate;
535
536 return 0;
537}
538
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300539/* sub-driver description */
540static const struct sd_desc sd_desc = {
541 .name = MODULE_NAME,
542 .ctrls = sd_ctrls,
543 .nctrls = ARRAY_SIZE(sd_ctrls),
544 .config = sd_config,
545 .init = sd_init,
546 .start = sd_start,
547 .stopN = sd_stopN,
548 .pkt_scan = sd_pkt_scan,
Jim Paris11d9f252008-12-10 06:06:20 -0300549 .get_streamparm = sd_get_streamparm,
550 .set_streamparm = sd_set_streamparm,
Antonio Ospitefbb4c6d2008-11-22 05:23:39 -0300551};
552
553/* -- module initialisation -- */
554static const __devinitdata struct usb_device_id device_table[] = {
555 {USB_DEVICE(0x06f8, 0x3002)}, /* Hercules Blog Webcam */
556 {USB_DEVICE(0x06f8, 0x3003)}, /* Hercules Dualpix HD Weblog */
557 {USB_DEVICE(0x1415, 0x2000)}, /* Sony HD Eye for PS3 (SLEH 00201) */
558 {}
559};
560
561MODULE_DEVICE_TABLE(usb, device_table);
562
563/* -- device connect -- */
564static int sd_probe(struct usb_interface *intf, const struct usb_device_id *id)
565{
566 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
567 THIS_MODULE);
568}
569
570static struct usb_driver sd_driver = {
571 .name = MODULE_NAME,
572 .id_table = device_table,
573 .probe = sd_probe,
574 .disconnect = gspca_disconnect,
575#ifdef CONFIG_PM
576 .suspend = gspca_suspend,
577 .resume = gspca_resume,
578#endif
579};
580
581/* -- module insert / remove -- */
582static int __init sd_mod_init(void)
583{
584 if (usb_register(&sd_driver) < 0)
585 return -1;
586 PDEBUG(D_PROBE, "registered");
587 return 0;
588}
589
590static void __exit sd_mod_exit(void)
591{
592 usb_deregister(&sd_driver);
593 PDEBUG(D_PROBE, "deregistered");
594}
595
596module_init(sd_mod_init);
597module_exit(sd_mod_exit);