]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/media/video/gspca/pac207.c
V4L/DVB: gspca - main: Function gspca_dev_probe2 added
[mirror_ubuntu-artful-kernel.git] / drivers / media / video / gspca / pac207.c
CommitLineData
e2997a72
HG
1/*
2 * Pixart PAC207BCA library
3 *
dc1fe157 4 * Copyright (C) 2008 Hans de Goede <hdgoede@redhat.com>
e2997a72
HG
5 * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li
6 * Copyleft (C) 2005 Michel Xhaard mxhaard@magic.fr
7 *
8 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
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 * (at your option) 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
26#define MODULE_NAME "pac207"
27
937a6f54 28#include <linux/input.h>
e2997a72
HG
29#include "gspca.h"
30
dc1fe157 31MODULE_AUTHOR("Hans de Goede <hdgoede@redhat.com>");
e2997a72
HG
32MODULE_DESCRIPTION("Pixart PAC207");
33MODULE_LICENSE("GPL");
34
35#define PAC207_CTRL_TIMEOUT 100 /* ms */
36
37#define PAC207_BRIGHTNESS_MIN 0
38#define PAC207_BRIGHTNESS_MAX 255
0e4a9099
HG
39#define PAC207_BRIGHTNESS_DEFAULT 46
40
41#define PAC207_EXPOSURE_MIN 3
e2997a72 42#define PAC207_EXPOSURE_MAX 26
0e4a9099
HG
43#define PAC207_EXPOSURE_DEFAULT 5 /* power on default: 3 */
44#define PAC207_EXPOSURE_KNEE 8 /* 4 = 30 fps, 11 = 8, 15 = 6 */
e2997a72
HG
45
46#define PAC207_GAIN_MIN 0
47#define PAC207_GAIN_MAX 31
48#define PAC207_GAIN_DEFAULT 9 /* power on default: 9 */
0e4a9099 49#define PAC207_GAIN_KNEE 31
e2997a72
HG
50
51#define PAC207_AUTOGAIN_DEADZONE 30
e2997a72 52
e2997a72
HG
53/* specific webcam descriptor */
54struct sd {
55 struct gspca_dev gspca_dev; /* !! must be the first item */
56
e2997a72
HG
57 u8 mode;
58
59 u8 brightness;
60 u8 exposure;
61 u8 autogain;
62 u8 gain;
63
64 u8 sof_read;
ab8f12cf 65 u8 header_read;
e2997a72
HG
66 u8 autogain_ignore_frames;
67
68 atomic_t avg_lum;
69};
70
71/* V4L2 controls supported by the driver */
72static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
73static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
74static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val);
75static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val);
76static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
77static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
78static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val);
79static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val);
80
7e64dc4c 81static const struct ctrl sd_ctrls[] = {
e2997a72
HG
82#define SD_BRIGHTNESS 0
83 {
84 {
85 .id = V4L2_CID_BRIGHTNESS,
86 .type = V4L2_CTRL_TYPE_INTEGER,
87 .name = "Brightness",
88 .minimum = PAC207_BRIGHTNESS_MIN,
89 .maximum = PAC207_BRIGHTNESS_MAX,
90 .step = 1,
91 .default_value = PAC207_BRIGHTNESS_DEFAULT,
92 .flags = 0,
93 },
94 .set = sd_setbrightness,
95 .get = sd_getbrightness,
96 },
97#define SD_EXPOSURE 1
98 {
99 {
100 .id = V4L2_CID_EXPOSURE,
101 .type = V4L2_CTRL_TYPE_INTEGER,
52897d86 102 .name = "Exposure",
e2997a72
HG
103 .minimum = PAC207_EXPOSURE_MIN,
104 .maximum = PAC207_EXPOSURE_MAX,
105 .step = 1,
106 .default_value = PAC207_EXPOSURE_DEFAULT,
107 .flags = 0,
108 },
109 .set = sd_setexposure,
110 .get = sd_getexposure,
111 },
112#define SD_AUTOGAIN 2
113 {
114 {
115 .id = V4L2_CID_AUTOGAIN,
116 .type = V4L2_CTRL_TYPE_BOOLEAN,
117 .name = "Auto Gain",
118 .minimum = 0,
119 .maximum = 1,
120 .step = 1,
66e4124f
JFM
121#define AUTOGAIN_DEF 1
122 .default_value = AUTOGAIN_DEF,
e2997a72
HG
123 .flags = 0,
124 },
125 .set = sd_setautogain,
126 .get = sd_getautogain,
127 },
128#define SD_GAIN 3
129 {
130 {
131 .id = V4L2_CID_GAIN,
132 .type = V4L2_CTRL_TYPE_INTEGER,
52897d86 133 .name = "Gain",
e2997a72
HG
134 .minimum = PAC207_GAIN_MIN,
135 .maximum = PAC207_GAIN_MAX,
136 .step = 1,
137 .default_value = PAC207_GAIN_DEFAULT,
138 .flags = 0,
139 },
140 .set = sd_setgain,
141 .get = sd_getgain,
142 },
143};
144
cc611b8a 145static const struct v4l2_pix_format sif_mode[] = {
c2446b3e
JFM
146 {176, 144, V4L2_PIX_FMT_PAC207, V4L2_FIELD_NONE,
147 .bytesperline = 176,
148 .sizeimage = (176 + 2) * 144,
149 /* uncompressed, add 2 bytes / line for line header */
150 .colorspace = V4L2_COLORSPACE_SRGB,
151 .priv = 1},
152 {352, 288, V4L2_PIX_FMT_PAC207, V4L2_FIELD_NONE,
153 .bytesperline = 352,
80544d3c
HG
154 /* compressed, but only when needed (not compressed
155 when the framerate is low) */
156 .sizeimage = (352 + 2) * 288,
c2446b3e
JFM
157 .colorspace = V4L2_COLORSPACE_SRGB,
158 .priv = 0},
e2997a72
HG
159};
160
161static const __u8 pac207_sensor_init[][8] = {
0e4a9099
HG
162 {0x10, 0x12, 0x0d, 0x12, 0x0c, 0x01, 0x29, 0x84},
163 {0x49, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30},
e2997a72 164 {0x00, 0x00, 0x00, 0x70, 0xa0, 0xf8, 0x00, 0x00},
e2997a72
HG
165 {0x32, 0x00, 0x96, 0x00, 0xA2, 0x02, 0xaf, 0x00},
166};
167
739570bb 168static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
e2997a72
HG
169 const u8 *buffer, u16 length)
170{
171 struct usb_device *udev = gspca_dev->dev;
172 int err;
e2997a72 173
739570bb 174 memcpy(gspca_dev->usb_buf, buffer, length);
e2997a72
HG
175
176 err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x01,
177 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
739570bb
JFM
178 0x00, index,
179 gspca_dev->usb_buf, length, PAC207_CTRL_TIMEOUT);
e2997a72
HG
180 if (err < 0)
181 PDEBUG(D_ERR,
182 "Failed to write registers to index 0x%04X, error %d)",
183 index, err);
184
185 return err;
186}
187
188
903e10aa 189static int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value)
e2997a72
HG
190{
191 struct usb_device *udev = gspca_dev->dev;
192 int err;
193
194 err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00,
195 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
196 value, index, NULL, 0, PAC207_CTRL_TIMEOUT);
197 if (err)
198 PDEBUG(D_ERR, "Failed to write a register (index 0x%04X,"
199 " value 0x%02X, error %d)", index, value, err);
200
201 return err;
202}
203
903e10aa 204static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
e2997a72
HG
205{
206 struct usb_device *udev = gspca_dev->dev;
e2997a72
HG
207 int res;
208
209 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00,
210 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
739570bb
JFM
211 0x00, index,
212 gspca_dev->usb_buf, 1, PAC207_CTRL_TIMEOUT);
e2997a72
HG
213 if (res < 0) {
214 PDEBUG(D_ERR,
215 "Failed to read a register (index 0x%04X, error %d)",
216 index, res);
217 return res;
218 }
219
739570bb 220 return gspca_dev->usb_buf[0];
e2997a72
HG
221}
222
e2997a72
HG
223/* this function is called at probe time */
224static int sd_config(struct gspca_dev *gspca_dev,
225 const struct usb_device_id *id)
226{
4aa0d037 227 struct sd *sd = (struct sd *) gspca_dev;
e2997a72
HG
228 struct cam *cam;
229 u8 idreg[2];
230
231 idreg[0] = pac207_read_reg(gspca_dev, 0x0000);
232 idreg[1] = pac207_read_reg(gspca_dev, 0x0001);
233 idreg[0] = ((idreg[0] & 0x0F) << 4) | ((idreg[1] & 0xf0) >> 4);
234 idreg[1] = idreg[1] & 0x0f;
235 PDEBUG(D_PROBE, "Pixart Sensor ID 0x%02X Chips ID 0x%02X",
236 idreg[0], idreg[1]);
237
238 if (idreg[0] != 0x27) {
239 PDEBUG(D_PROBE, "Error invalid sensor ID!");
240 return -ENODEV;
241 }
242
e2997a72
HG
243 PDEBUG(D_PROBE,
244 "Pixart PAC207BCA Image Processor and Control Chip detected"
245 " (vid/pid 0x%04X:0x%04X)", id->idVendor, id->idProduct);
246
247 cam = &gspca_dev->cam;
e2997a72
HG
248 cam->cam_mode = sif_mode;
249 cam->nmodes = ARRAY_SIZE(sif_mode);
4aa0d037
JFM
250 sd->brightness = PAC207_BRIGHTNESS_DEFAULT;
251 sd->exposure = PAC207_EXPOSURE_DEFAULT;
252 sd->gain = PAC207_GAIN_DEFAULT;
66e4124f 253 sd->autogain = AUTOGAIN_DEF;
e2997a72
HG
254
255 return 0;
256}
257
012d6b02
JFM
258/* this function is called at probe and resume time */
259static int sd_init(struct gspca_dev *gspca_dev)
e2997a72 260{
66e4124f
JFM
261 pac207_write_reg(gspca_dev, 0x41, 0x00);
262 /* Bit_0=Image Format,
263 * Bit_1=LED,
264 * Bit_2=Compression test mode enable */
265 pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */
e2997a72 266
e2997a72
HG
267 return 0;
268}
269
270/* -- start the camera -- */
72ab97ce 271static int sd_start(struct gspca_dev *gspca_dev)
e2997a72
HG
272{
273 struct sd *sd = (struct sd *) gspca_dev;
274 __u8 mode;
275
276 pac207_write_reg(gspca_dev, 0x0f, 0x10); /* Power control (Bit 6-0) */
277 pac207_write_regs(gspca_dev, 0x0002, pac207_sensor_init[0], 8);
278 pac207_write_regs(gspca_dev, 0x000a, pac207_sensor_init[1], 8);
279 pac207_write_regs(gspca_dev, 0x0012, pac207_sensor_init[2], 8);
c529e556 280 pac207_write_regs(gspca_dev, 0x0042, pac207_sensor_init[3], 8);
e2997a72
HG
281
282 /* Compression Balance */
283 if (gspca_dev->width == 176)
284 pac207_write_reg(gspca_dev, 0x4a, 0xff);
285 else
0e4a9099 286 pac207_write_reg(gspca_dev, 0x4a, 0x30);
e2997a72
HG
287 pac207_write_reg(gspca_dev, 0x4b, 0x00); /* Sram test value */
288 pac207_write_reg(gspca_dev, 0x08, sd->brightness);
289
290 /* PGA global gain (Bit 4-0) */
291 pac207_write_reg(gspca_dev, 0x0e, sd->gain);
292 pac207_write_reg(gspca_dev, 0x02, sd->exposure); /* PXCK = 12MHz /n */
293
294 mode = 0x02; /* Image Format (Bit 0), LED (1), Compr. test mode (2) */
d43fa32f 295 if (gspca_dev->width == 176) { /* 176x144 */
e2997a72
HG
296 mode |= 0x01;
297 PDEBUG(D_STREAM, "pac207_start mode 176x144");
d43fa32f 298 } else { /* 352x288 */
e2997a72 299 PDEBUG(D_STREAM, "pac207_start mode 352x288");
d43fa32f 300 }
e2997a72
HG
301 pac207_write_reg(gspca_dev, 0x41, mode);
302
303 pac207_write_reg(gspca_dev, 0x13, 0x01); /* Bit 0, auto clear */
304 pac207_write_reg(gspca_dev, 0x1c, 0x01); /* not documented */
6a7eba24 305 msleep(10);
e2997a72
HG
306 pac207_write_reg(gspca_dev, 0x40, 0x01); /* Start ISO pipe */
307
308 sd->sof_read = 0;
309 sd->autogain_ignore_frames = 0;
310 atomic_set(&sd->avg_lum, -1);
72ab97ce 311 return 0;
e2997a72
HG
312}
313
314static void sd_stopN(struct gspca_dev *gspca_dev)
315{
316 pac207_write_reg(gspca_dev, 0x40, 0x00); /* Stop ISO pipe */
317 pac207_write_reg(gspca_dev, 0x41, 0x00); /* Turn of LED */
318 pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */
319}
320
8a5b2e90
HG
321/* Include pac common sof detection functions */
322#include "pac_common.h"
323
e2997a72
HG
324static void pac207_do_auto_gain(struct gspca_dev *gspca_dev)
325{
326 struct sd *sd = (struct sd *) gspca_dev;
e2997a72
HG
327 int avg_lum = atomic_read(&sd->avg_lum);
328
dcef3237 329 if (avg_lum == -1)
e2997a72
HG
330 return;
331
dcef3237 332 if (sd->autogain_ignore_frames > 0)
e2997a72 333 sd->autogain_ignore_frames--;
dcef3237 334 else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum,
0e4a9099 335 100, PAC207_AUTOGAIN_DEADZONE,
dcef3237 336 PAC207_GAIN_KNEE, PAC207_EXPOSURE_KNEE))
8a5b2e90 337 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
e2997a72
HG
338}
339
e2997a72 340static void sd_pkt_scan(struct gspca_dev *gspca_dev,
76dd272b 341 u8 *data,
e2997a72
HG
342 int len)
343{
ab8f12cf 344 struct sd *sd = (struct sd *) gspca_dev;
e2997a72 345 unsigned char *sof;
e2997a72 346
a6b69e40 347 sof = pac_find_sof(&sd->sof_read, data, len);
e2997a72 348 if (sof) {
ab8f12cf
HG
349 int n;
350
e2997a72 351 /* finish decoding current frame */
ab8f12cf 352 n = sof - data;
327c4abf
HG
353 if (n > sizeof pac_sof_marker)
354 n -= sizeof pac_sof_marker;
ab8f12cf
HG
355 else
356 n = 0;
76dd272b
JFM
357 gspca_frame_add(gspca_dev, LAST_PACKET,
358 data, n);
ab8f12cf 359 sd->header_read = 0;
76dd272b 360 gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
e2997a72
HG
361 len -= sof - data;
362 data = sof;
363 }
ab8f12cf
HG
364 if (sd->header_read < 11) {
365 int needed;
e2997a72 366
ab8f12cf
HG
367 /* get average lumination from frame header (byte 5) */
368 if (sd->header_read < 5) {
369 needed = 5 - sd->header_read;
370 if (len >= needed)
371 atomic_set(&sd->avg_lum, data[needed - 1]);
372 }
373 /* skip the rest of the header */
374 needed = 11 - sd->header_read;
375 if (len <= needed) {
376 sd->header_read += len;
377 return;
378 }
379 data += needed;
380 len -= needed;
381 sd->header_read = 11;
382 }
e2997a72 383
76dd272b 384 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
e2997a72
HG
385}
386
387static void setbrightness(struct gspca_dev *gspca_dev)
388{
389 struct sd *sd = (struct sd *) gspca_dev;
390
391 pac207_write_reg(gspca_dev, 0x08, sd->brightness);
392 pac207_write_reg(gspca_dev, 0x13, 0x01); /* Bit 0, auto clear */
393 pac207_write_reg(gspca_dev, 0x1c, 0x01); /* not documented */
394}
395
396static void setexposure(struct gspca_dev *gspca_dev)
397{
398 struct sd *sd = (struct sd *) gspca_dev;
399
400 pac207_write_reg(gspca_dev, 0x02, sd->exposure);
401 pac207_write_reg(gspca_dev, 0x13, 0x01); /* Bit 0, auto clear */
402 pac207_write_reg(gspca_dev, 0x1c, 0x01); /* not documented */
403}
404
405static void setgain(struct gspca_dev *gspca_dev)
406{
407 struct sd *sd = (struct sd *) gspca_dev;
408
409 pac207_write_reg(gspca_dev, 0x0e, sd->gain);
410 pac207_write_reg(gspca_dev, 0x13, 0x01); /* Bit 0, auto clear */
411 pac207_write_reg(gspca_dev, 0x1c, 0x01); /* not documented */
412}
413
414static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
415{
416 struct sd *sd = (struct sd *) gspca_dev;
417
418 sd->brightness = val;
419 if (gspca_dev->streaming)
420 setbrightness(gspca_dev);
421 return 0;
422}
423
424static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
425{
426 struct sd *sd = (struct sd *) gspca_dev;
427
428 *val = sd->brightness;
429 return 0;
430}
431
432static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val)
433{
434 struct sd *sd = (struct sd *) gspca_dev;
435
e2997a72
HG
436 sd->exposure = val;
437 if (gspca_dev->streaming)
438 setexposure(gspca_dev);
439 return 0;
440}
441
442static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val)
443{
444 struct sd *sd = (struct sd *) gspca_dev;
445
446 *val = sd->exposure;
447 return 0;
448}
449
450static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val)
451{
452 struct sd *sd = (struct sd *) gspca_dev;
453
e2997a72
HG
454 sd->gain = val;
455 if (gspca_dev->streaming)
456 setgain(gspca_dev);
457 return 0;
458}
459
460static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val)
461{
462 struct sd *sd = (struct sd *) gspca_dev;
463
464 *val = sd->gain;
465 return 0;
466}
467
468static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
469{
470 struct sd *sd = (struct sd *) gspca_dev;
471
472 sd->autogain = val;
473 /* when switching to autogain set defaults to make sure
474 we are on a valid point of the autogain gain /
475 exposure knee graph, and give this change time to
476 take effect before doing autogain. */
477 if (sd->autogain) {
478 sd->exposure = PAC207_EXPOSURE_DEFAULT;
479 sd->gain = PAC207_GAIN_DEFAULT;
480 if (gspca_dev->streaming) {
481 sd->autogain_ignore_frames =
8a5b2e90 482 PAC_AUTOGAIN_IGNORE_FRAMES;
e2997a72
HG
483 setexposure(gspca_dev);
484 setgain(gspca_dev);
485 }
486 }
487
488 return 0;
489}
490
491static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
492{
493 struct sd *sd = (struct sd *) gspca_dev;
494
495 *val = sd->autogain;
496 return 0;
497}
498
937a6f54
HG
499#ifdef CONFIG_INPUT
500static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
501 u8 *data, /* interrupt packet data */
502 int len) /* interrput packet length */
503{
504 int ret = -EINVAL;
505
506 if (len == 2 && data[0] == 0x5a && data[1] == 0x5a) {
507 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
508 input_sync(gspca_dev->input_dev);
509 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
510 input_sync(gspca_dev->input_dev);
511 ret = 0;
512 }
513
514 return ret;
515}
516#endif
517
e2997a72 518/* sub-driver description */
a5ae2062 519static const struct sd_desc sd_desc = {
e2997a72
HG
520 .name = MODULE_NAME,
521 .ctrls = sd_ctrls,
522 .nctrls = ARRAY_SIZE(sd_ctrls),
523 .config = sd_config,
012d6b02 524 .init = sd_init,
e2997a72
HG
525 .start = sd_start,
526 .stopN = sd_stopN,
e2997a72
HG
527 .dq_callback = pac207_do_auto_gain,
528 .pkt_scan = sd_pkt_scan,
937a6f54
HG
529#ifdef CONFIG_INPUT
530 .int_pkt_scan = sd_int_pkt_scan,
531#endif
e2997a72
HG
532};
533
534/* -- module initialisation -- */
a5ae2062 535static const __devinitdata struct usb_device_id device_table[] = {
9d64fdb1
JFM
536 {USB_DEVICE(0x041e, 0x4028)},
537 {USB_DEVICE(0x093a, 0x2460)},
87945895 538 {USB_DEVICE(0x093a, 0x2461)},
9d64fdb1
JFM
539 {USB_DEVICE(0x093a, 0x2463)},
540 {USB_DEVICE(0x093a, 0x2464)},
541 {USB_DEVICE(0x093a, 0x2468)},
542 {USB_DEVICE(0x093a, 0x2470)},
543 {USB_DEVICE(0x093a, 0x2471)},
544 {USB_DEVICE(0x093a, 0x2472)},
db91235e 545 {USB_DEVICE(0x093a, 0x2474)},
d654dca7 546 {USB_DEVICE(0x093a, 0x2476)},
91711874 547 {USB_DEVICE(0x145f, 0x013a)},
9d64fdb1 548 {USB_DEVICE(0x2001, 0xf115)},
e2997a72
HG
549 {}
550};
551MODULE_DEVICE_TABLE(usb, device_table);
552
553/* -- device connect -- */
554static int sd_probe(struct usb_interface *intf,
555 const struct usb_device_id *id)
556{
d43fa32f
JFM
557 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
558 THIS_MODULE);
e2997a72
HG
559}
560
561static struct usb_driver sd_driver = {
562 .name = MODULE_NAME,
563 .id_table = device_table,
564 .probe = sd_probe,
565 .disconnect = gspca_disconnect,
6a709749
JFM
566#ifdef CONFIG_PM
567 .suspend = gspca_suspend,
568 .resume = gspca_resume,
569#endif
e2997a72
HG
570};
571
572/* -- module insert / remove -- */
573static int __init sd_mod_init(void)
574{
f69e9529
AK
575 int ret;
576 ret = usb_register(&sd_driver);
577 if (ret < 0)
e6b14849 578 return ret;
903e10aa 579 PDEBUG(D_PROBE, "registered");
e2997a72
HG
580 return 0;
581}
582static void __exit sd_mod_exit(void)
583{
584 usb_deregister(&sd_driver);
585 PDEBUG(D_PROBE, "deregistered");
586}
587
588module_init(sd_mod_init);
589module_exit(sd_mod_exit);