konica.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /*
  2. * Driver for USB webcams based on Konica chipset. This
  3. * chipset is used in Intel YC76 camera.
  4. *
  5. * Copyright (C) 2010 Hans de Goede <hdegoede@redhat.com>
  6. *
  7. * Based on the usbvideo v4l1 konicawc driver which is:
  8. *
  9. * Copyright (C) 2002 Simon Evans <spse@secret.org.uk>
  10. *
  11. * The code for making gspca work with a webcam with 2 isoc endpoints was
  12. * taken from the benq gspca subdriver which is:
  13. *
  14. * Copyright (C) 2009 Jean-Francois Moine (http://moinejf.free.fr)
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation; either version 2 of the License, or
  19. * any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  29. */
  30. #define MODULE_NAME "konica"
  31. #include <linux/input.h>
  32. #include "gspca.h"
  33. MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
  34. MODULE_DESCRIPTION("Konica chipset USB Camera Driver");
  35. MODULE_LICENSE("GPL");
  36. #define WHITEBAL_REG 0x01
  37. #define BRIGHTNESS_REG 0x02
  38. #define SHARPNESS_REG 0x03
  39. #define CONTRAST_REG 0x04
  40. #define SATURATION_REG 0x05
  41. /* specific webcam descriptor */
  42. struct sd {
  43. struct gspca_dev gspca_dev; /* !! must be the first item */
  44. struct urb *last_data_urb;
  45. u8 snapshot_pressed;
  46. u8 brightness;
  47. u8 contrast;
  48. u8 saturation;
  49. u8 whitebal;
  50. u8 sharpness;
  51. };
  52. /* V4L2 controls supported by the driver */
  53. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
  54. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
  55. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
  56. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
  57. static int sd_setsaturation(struct gspca_dev *gspca_dev, __s32 val);
  58. static int sd_getsaturation(struct gspca_dev *gspca_dev, __s32 *val);
  59. static int sd_setwhitebal(struct gspca_dev *gspca_dev, __s32 val);
  60. static int sd_getwhitebal(struct gspca_dev *gspca_dev, __s32 *val);
  61. static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
  62. static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
  63. static const struct ctrl sd_ctrls[] = {
  64. #define SD_BRIGHTNESS 0
  65. {
  66. {
  67. .id = V4L2_CID_BRIGHTNESS,
  68. .type = V4L2_CTRL_TYPE_INTEGER,
  69. .name = "Brightness",
  70. .minimum = 0,
  71. .maximum = 9,
  72. .step = 1,
  73. #define BRIGHTNESS_DEFAULT 4
  74. .default_value = BRIGHTNESS_DEFAULT,
  75. .flags = 0,
  76. },
  77. .set = sd_setbrightness,
  78. .get = sd_getbrightness,
  79. },
  80. #define SD_CONTRAST 1
  81. {
  82. {
  83. .id = V4L2_CID_CONTRAST,
  84. .type = V4L2_CTRL_TYPE_INTEGER,
  85. .name = "Contrast",
  86. .minimum = 0,
  87. .maximum = 9,
  88. .step = 4,
  89. #define CONTRAST_DEFAULT 10
  90. .default_value = CONTRAST_DEFAULT,
  91. .flags = 0,
  92. },
  93. .set = sd_setcontrast,
  94. .get = sd_getcontrast,
  95. },
  96. #define SD_SATURATION 2
  97. {
  98. {
  99. .id = V4L2_CID_SATURATION,
  100. .type = V4L2_CTRL_TYPE_INTEGER,
  101. .name = "Saturation",
  102. .minimum = 0,
  103. .maximum = 9,
  104. .step = 1,
  105. #define SATURATION_DEFAULT 4
  106. .default_value = SATURATION_DEFAULT,
  107. .flags = 0,
  108. },
  109. .set = sd_setsaturation,
  110. .get = sd_getsaturation,
  111. },
  112. #define SD_WHITEBAL 3
  113. {
  114. {
  115. .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE,
  116. .type = V4L2_CTRL_TYPE_INTEGER,
  117. .name = "White Balance",
  118. .minimum = 0,
  119. .maximum = 33,
  120. .step = 1,
  121. #define WHITEBAL_DEFAULT 25
  122. .default_value = WHITEBAL_DEFAULT,
  123. .flags = 0,
  124. },
  125. .set = sd_setwhitebal,
  126. .get = sd_getwhitebal,
  127. },
  128. #define SD_SHARPNESS 4
  129. {
  130. {
  131. .id = V4L2_CID_SHARPNESS,
  132. .type = V4L2_CTRL_TYPE_INTEGER,
  133. .name = "Sharpness",
  134. .minimum = 0,
  135. .maximum = 9,
  136. .step = 1,
  137. #define SHARPNESS_DEFAULT 4
  138. .default_value = SHARPNESS_DEFAULT,
  139. .flags = 0,
  140. },
  141. .set = sd_setsharpness,
  142. .get = sd_getsharpness,
  143. },
  144. };
  145. /* .priv is what goes to register 8 for this mode, known working values:
  146. 0x00 -> 176x144, cropped
  147. 0x01 -> 176x144, cropped
  148. 0x02 -> 176x144, cropped
  149. 0x03 -> 176x144, cropped
  150. 0x04 -> 176x144, binned
  151. 0x05 -> 320x240
  152. 0x06 -> 320x240
  153. 0x07 -> 160x120, cropped
  154. 0x08 -> 160x120, cropped
  155. 0x09 -> 160x120, binned (note has 136 lines)
  156. 0x0a -> 160x120, binned (note has 136 lines)
  157. 0x0b -> 160x120, cropped
  158. */
  159. static const struct v4l2_pix_format vga_mode[] = {
  160. {160, 120, V4L2_PIX_FMT_KONICA420, V4L2_FIELD_NONE,
  161. .bytesperline = 160,
  162. .sizeimage = 160 * 136 * 3 / 2 + 960,
  163. .colorspace = V4L2_COLORSPACE_SRGB,
  164. .priv = 0x0a},
  165. {176, 144, V4L2_PIX_FMT_KONICA420, V4L2_FIELD_NONE,
  166. .bytesperline = 176,
  167. .sizeimage = 176 * 144 * 3 / 2 + 960,
  168. .colorspace = V4L2_COLORSPACE_SRGB,
  169. .priv = 0x04},
  170. {320, 240, V4L2_PIX_FMT_KONICA420, V4L2_FIELD_NONE,
  171. .bytesperline = 320,
  172. .sizeimage = 320 * 240 * 3 / 2 + 960,
  173. .colorspace = V4L2_COLORSPACE_SRGB,
  174. .priv = 0x05},
  175. };
  176. static void sd_isoc_irq(struct urb *urb);
  177. static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index)
  178. {
  179. struct usb_device *dev = gspca_dev->dev;
  180. int ret;
  181. if (gspca_dev->usb_err < 0)
  182. return;
  183. ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
  184. 0x02,
  185. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  186. value,
  187. index,
  188. NULL,
  189. 0,
  190. 1000);
  191. if (ret < 0) {
  192. err("reg_w err %d", ret);
  193. gspca_dev->usb_err = ret;
  194. }
  195. }
  196. static void reg_r(struct gspca_dev *gspca_dev, u16 value, u16 index)
  197. {
  198. struct usb_device *dev = gspca_dev->dev;
  199. int ret;
  200. if (gspca_dev->usb_err < 0)
  201. return;
  202. ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
  203. 0x03,
  204. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  205. value,
  206. index,
  207. gspca_dev->usb_buf,
  208. 2,
  209. 1000);
  210. if (ret < 0) {
  211. err("reg_w err %d", ret);
  212. gspca_dev->usb_err = ret;
  213. }
  214. }
  215. static void konica_stream_on(struct gspca_dev *gspca_dev)
  216. {
  217. reg_w(gspca_dev, 1, 0x0b);
  218. }
  219. static void konica_stream_off(struct gspca_dev *gspca_dev)
  220. {
  221. reg_w(gspca_dev, 0, 0x0b);
  222. }
  223. /* this function is called at probe time */
  224. static int sd_config(struct gspca_dev *gspca_dev,
  225. const struct usb_device_id *id)
  226. {
  227. struct sd *sd = (struct sd *) gspca_dev;
  228. gspca_dev->cam.cam_mode = vga_mode;
  229. gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode);
  230. gspca_dev->cam.no_urb_create = 1;
  231. /* The highest alt setting has an isoc packetsize of 0, so we
  232. don't want to use it */
  233. gspca_dev->nbalt--;
  234. sd->brightness = BRIGHTNESS_DEFAULT;
  235. sd->contrast = CONTRAST_DEFAULT;
  236. sd->saturation = SATURATION_DEFAULT;
  237. sd->whitebal = WHITEBAL_DEFAULT;
  238. sd->sharpness = SHARPNESS_DEFAULT;
  239. return 0;
  240. }
  241. /* this function is called at probe and resume time */
  242. static int sd_init(struct gspca_dev *gspca_dev)
  243. {
  244. /* HDG not sure if these 2 reads are needed */
  245. reg_r(gspca_dev, 0, 0x10);
  246. PDEBUG(D_PROBE, "Reg 0x10 reads: %02x %02x",
  247. gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]);
  248. reg_r(gspca_dev, 0, 0x10);
  249. PDEBUG(D_PROBE, "Reg 0x10 reads: %02x %02x",
  250. gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]);
  251. reg_w(gspca_dev, 0, 0x0d);
  252. return 0;
  253. }
  254. static int sd_start(struct gspca_dev *gspca_dev)
  255. {
  256. struct sd *sd = (struct sd *) gspca_dev;
  257. struct urb *urb;
  258. int i, n, packet_size;
  259. struct usb_host_interface *alt;
  260. struct usb_interface *intf;
  261. intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
  262. alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
  263. if (!alt) {
  264. err("Couldn't get altsetting");
  265. return -EIO;
  266. }
  267. packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
  268. reg_w(gspca_dev, sd->brightness, BRIGHTNESS_REG);
  269. reg_w(gspca_dev, sd->whitebal, WHITEBAL_REG);
  270. reg_w(gspca_dev, sd->contrast, CONTRAST_REG);
  271. reg_w(gspca_dev, sd->saturation, SATURATION_REG);
  272. reg_w(gspca_dev, sd->sharpness, SHARPNESS_REG);
  273. n = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
  274. reg_w(gspca_dev, n, 0x08);
  275. konica_stream_on(gspca_dev);
  276. if (gspca_dev->usb_err)
  277. return gspca_dev->usb_err;
  278. /* create 4 URBs - 2 on endpoint 0x83 and 2 on 0x082 */
  279. #if MAX_NURBS < 4
  280. #error "Not enough URBs in the gspca table"
  281. #endif
  282. #define SD_NPKT 32
  283. for (n = 0; n < 4; n++) {
  284. i = n & 1 ? 0 : 1;
  285. packet_size =
  286. le16_to_cpu(alt->endpoint[i].desc.wMaxPacketSize);
  287. urb = usb_alloc_urb(SD_NPKT, GFP_KERNEL);
  288. if (!urb) {
  289. err("usb_alloc_urb failed");
  290. return -ENOMEM;
  291. }
  292. gspca_dev->urb[n] = urb;
  293. urb->transfer_buffer = usb_alloc_coherent(gspca_dev->dev,
  294. packet_size * SD_NPKT,
  295. GFP_KERNEL,
  296. &urb->transfer_dma);
  297. if (urb->transfer_buffer == NULL) {
  298. err("usb_buffer_alloc failed");
  299. return -ENOMEM;
  300. }
  301. urb->dev = gspca_dev->dev;
  302. urb->context = gspca_dev;
  303. urb->transfer_buffer_length = packet_size * SD_NPKT;
  304. urb->pipe = usb_rcvisocpipe(gspca_dev->dev,
  305. n & 1 ? 0x81 : 0x82);
  306. urb->transfer_flags = URB_ISO_ASAP
  307. | URB_NO_TRANSFER_DMA_MAP;
  308. urb->interval = 1;
  309. urb->complete = sd_isoc_irq;
  310. urb->number_of_packets = SD_NPKT;
  311. for (i = 0; i < SD_NPKT; i++) {
  312. urb->iso_frame_desc[i].length = packet_size;
  313. urb->iso_frame_desc[i].offset = packet_size * i;
  314. }
  315. }
  316. return 0;
  317. }
  318. static void sd_stopN(struct gspca_dev *gspca_dev)
  319. {
  320. struct sd *sd = (struct sd *) gspca_dev;
  321. konica_stream_off(gspca_dev);
  322. #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
  323. /* Don't keep the button in the pressed state "forever" if it was
  324. pressed when streaming is stopped */
  325. if (sd->snapshot_pressed) {
  326. input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
  327. input_sync(gspca_dev->input_dev);
  328. sd->snapshot_pressed = 0;
  329. }
  330. #endif
  331. }
  332. /* reception of an URB */
  333. static void sd_isoc_irq(struct urb *urb)
  334. {
  335. struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context;
  336. struct sd *sd = (struct sd *) gspca_dev;
  337. struct urb *data_urb, *status_urb;
  338. u8 *data;
  339. int i, st;
  340. PDEBUG(D_PACK, "sd isoc irq");
  341. if (!gspca_dev->streaming)
  342. return;
  343. if (urb->status != 0) {
  344. if (urb->status == -ESHUTDOWN)
  345. return; /* disconnection */
  346. #ifdef CONFIG_PM
  347. if (gspca_dev->frozen)
  348. return;
  349. #endif
  350. PDEBUG(D_ERR, "urb status: %d", urb->status);
  351. st = usb_submit_urb(urb, GFP_ATOMIC);
  352. if (st < 0)
  353. err("resubmit urb error %d", st);
  354. return;
  355. }
  356. /* if this is a data URB (ep 0x82), wait */
  357. if (urb->transfer_buffer_length > 32) {
  358. sd->last_data_urb = urb;
  359. return;
  360. }
  361. status_urb = urb;
  362. data_urb = sd->last_data_urb;
  363. sd->last_data_urb = NULL;
  364. if (!data_urb || data_urb->start_frame != status_urb->start_frame) {
  365. PDEBUG(D_ERR|D_PACK, "lost sync on frames");
  366. goto resubmit;
  367. }
  368. if (data_urb->number_of_packets != status_urb->number_of_packets) {
  369. PDEBUG(D_ERR|D_PACK,
  370. "no packets does not match, data: %d, status: %d",
  371. data_urb->number_of_packets,
  372. status_urb->number_of_packets);
  373. goto resubmit;
  374. }
  375. for (i = 0; i < status_urb->number_of_packets; i++) {
  376. if (data_urb->iso_frame_desc[i].status ||
  377. status_urb->iso_frame_desc[i].status) {
  378. PDEBUG(D_ERR|D_PACK,
  379. "pkt %d data-status %d, status-status %d", i,
  380. data_urb->iso_frame_desc[i].status,
  381. status_urb->iso_frame_desc[i].status);
  382. gspca_dev->last_packet_type = DISCARD_PACKET;
  383. continue;
  384. }
  385. if (status_urb->iso_frame_desc[i].actual_length != 1) {
  386. PDEBUG(D_ERR|D_PACK,
  387. "bad status packet length %d",
  388. status_urb->iso_frame_desc[i].actual_length);
  389. gspca_dev->last_packet_type = DISCARD_PACKET;
  390. continue;
  391. }
  392. st = *((u8 *)status_urb->transfer_buffer
  393. + status_urb->iso_frame_desc[i].offset);
  394. data = (u8 *)data_urb->transfer_buffer
  395. + data_urb->iso_frame_desc[i].offset;
  396. /* st: 0x80-0xff: frame start with frame number (ie 0-7f)
  397. * otherwise:
  398. * bit 0 0: keep packet
  399. * 1: drop packet (padding data)
  400. *
  401. * bit 4 0 button not clicked
  402. * 1 button clicked
  403. * button is used to `take a picture' (in software)
  404. */
  405. if (st & 0x80) {
  406. gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
  407. gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
  408. } else {
  409. #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
  410. u8 button_state = st & 0x40 ? 1 : 0;
  411. if (sd->snapshot_pressed != button_state) {
  412. input_report_key(gspca_dev->input_dev,
  413. KEY_CAMERA,
  414. button_state);
  415. input_sync(gspca_dev->input_dev);
  416. sd->snapshot_pressed = button_state;
  417. }
  418. #endif
  419. if (st & 0x01)
  420. continue;
  421. }
  422. gspca_frame_add(gspca_dev, INTER_PACKET, data,
  423. data_urb->iso_frame_desc[i].actual_length);
  424. }
  425. resubmit:
  426. if (data_urb) {
  427. st = usb_submit_urb(data_urb, GFP_ATOMIC);
  428. if (st < 0)
  429. PDEBUG(D_ERR|D_PACK,
  430. "usb_submit_urb(data_urb) ret %d", st);
  431. }
  432. st = usb_submit_urb(status_urb, GFP_ATOMIC);
  433. if (st < 0)
  434. err("usb_submit_urb(status_urb) ret %d", st);
  435. }
  436. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  437. {
  438. struct sd *sd = (struct sd *) gspca_dev;
  439. sd->brightness = val;
  440. if (gspca_dev->streaming) {
  441. konica_stream_off(gspca_dev);
  442. reg_w(gspca_dev, sd->brightness, BRIGHTNESS_REG);
  443. konica_stream_on(gspca_dev);
  444. }
  445. return 0;
  446. }
  447. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  448. {
  449. struct sd *sd = (struct sd *) gspca_dev;
  450. *val = sd->brightness;
  451. return 0;
  452. }
  453. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  454. {
  455. struct sd *sd = (struct sd *) gspca_dev;
  456. sd->contrast = val;
  457. if (gspca_dev->streaming) {
  458. konica_stream_off(gspca_dev);
  459. reg_w(gspca_dev, sd->contrast, CONTRAST_REG);
  460. konica_stream_on(gspca_dev);
  461. }
  462. return 0;
  463. }
  464. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  465. {
  466. struct sd *sd = (struct sd *) gspca_dev;
  467. *val = sd->contrast;
  468. return 0;
  469. }
  470. static int sd_setsaturation(struct gspca_dev *gspca_dev, __s32 val)
  471. {
  472. struct sd *sd = (struct sd *) gspca_dev;
  473. sd->saturation = val;
  474. if (gspca_dev->streaming) {
  475. konica_stream_off(gspca_dev);
  476. reg_w(gspca_dev, sd->saturation, SATURATION_REG);
  477. konica_stream_on(gspca_dev);
  478. }
  479. return 0;
  480. }
  481. static int sd_getsaturation(struct gspca_dev *gspca_dev, __s32 *val)
  482. {
  483. struct sd *sd = (struct sd *) gspca_dev;
  484. *val = sd->saturation;
  485. return 0;
  486. }
  487. static int sd_setwhitebal(struct gspca_dev *gspca_dev, __s32 val)
  488. {
  489. struct sd *sd = (struct sd *) gspca_dev;
  490. sd->whitebal = val;
  491. if (gspca_dev->streaming) {
  492. konica_stream_off(gspca_dev);
  493. reg_w(gspca_dev, sd->whitebal, WHITEBAL_REG);
  494. konica_stream_on(gspca_dev);
  495. }
  496. return 0;
  497. }
  498. static int sd_getwhitebal(struct gspca_dev *gspca_dev, __s32 *val)
  499. {
  500. struct sd *sd = (struct sd *) gspca_dev;
  501. *val = sd->whitebal;
  502. return 0;
  503. }
  504. static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
  505. {
  506. struct sd *sd = (struct sd *) gspca_dev;
  507. sd->sharpness = val;
  508. if (gspca_dev->streaming) {
  509. konica_stream_off(gspca_dev);
  510. reg_w(gspca_dev, sd->sharpness, SHARPNESS_REG);
  511. konica_stream_on(gspca_dev);
  512. }
  513. return 0;
  514. }
  515. static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
  516. {
  517. struct sd *sd = (struct sd *) gspca_dev;
  518. *val = sd->sharpness;
  519. return 0;
  520. }
  521. /* sub-driver description */
  522. static const struct sd_desc sd_desc = {
  523. .name = MODULE_NAME,
  524. .ctrls = sd_ctrls,
  525. .nctrls = ARRAY_SIZE(sd_ctrls),
  526. .config = sd_config,
  527. .init = sd_init,
  528. .start = sd_start,
  529. .stopN = sd_stopN,
  530. #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
  531. .other_input = 1,
  532. #endif
  533. };
  534. /* -- module initialisation -- */
  535. static const struct usb_device_id device_table[] = {
  536. {USB_DEVICE(0x04c8, 0x0720)}, /* Intel YC 76 */
  537. {}
  538. };
  539. MODULE_DEVICE_TABLE(usb, device_table);
  540. /* -- device connect -- */
  541. static int sd_probe(struct usb_interface *intf,
  542. const struct usb_device_id *id)
  543. {
  544. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  545. THIS_MODULE);
  546. }
  547. static struct usb_driver sd_driver = {
  548. .name = MODULE_NAME,
  549. .id_table = device_table,
  550. .probe = sd_probe,
  551. .disconnect = gspca_disconnect,
  552. #ifdef CONFIG_PM
  553. .suspend = gspca_suspend,
  554. .resume = gspca_resume,
  555. #endif
  556. };
  557. /* -- module insert / remove -- */
  558. static int __init sd_mod_init(void)
  559. {
  560. return usb_register(&sd_driver);
  561. }
  562. static void __exit sd_mod_exit(void)
  563. {
  564. usb_deregister(&sd_driver);
  565. }
  566. module_init(sd_mod_init);
  567. module_exit(sd_mod_exit);