s2250-board.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /*
  2. * Copyright (C) 2008 Sensoray Company Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License (Version 2) as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software Foundation,
  15. * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  16. */
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/usb.h>
  20. #include <linux/i2c.h>
  21. #include <linux/videodev2.h>
  22. #include <linux/slab.h>
  23. #include <media/v4l2-device.h>
  24. #include <media/v4l2-common.h>
  25. #include <media/v4l2-subdev.h>
  26. #include "go7007-priv.h"
  27. MODULE_DESCRIPTION("Sensoray 2250/2251 i2c v4l2 subdev driver");
  28. MODULE_LICENSE("GPL v2");
  29. #define TLV320_ADDRESS 0x34
  30. #define VPX322_ADDR_ANALOGCONTROL1 0x02
  31. #define VPX322_ADDR_BRIGHTNESS0 0x0127
  32. #define VPX322_ADDR_BRIGHTNESS1 0x0131
  33. #define VPX322_ADDR_CONTRAST0 0x0128
  34. #define VPX322_ADDR_CONTRAST1 0x0132
  35. #define VPX322_ADDR_HUE 0x00dc
  36. #define VPX322_ADDR_SAT 0x0030
  37. struct go7007_usb_board {
  38. unsigned int flags;
  39. struct go7007_board_info main_info;
  40. };
  41. struct go7007_usb {
  42. struct go7007_usb_board *board;
  43. struct mutex i2c_lock;
  44. struct usb_device *usbdev;
  45. struct urb *video_urbs[8];
  46. struct urb *audio_urbs[8];
  47. struct urb *intr_urb;
  48. };
  49. static unsigned char aud_regs[] = {
  50. 0x1e, 0x00,
  51. 0x00, 0x17,
  52. 0x02, 0x17,
  53. 0x04, 0xf9,
  54. 0x06, 0xf9,
  55. 0x08, 0x02,
  56. 0x0a, 0x00,
  57. 0x0c, 0x00,
  58. 0x0a, 0x00,
  59. 0x0c, 0x00,
  60. 0x0e, 0x02,
  61. 0x10, 0x00,
  62. 0x12, 0x01,
  63. 0x00, 0x00,
  64. };
  65. static unsigned char vid_regs[] = {
  66. 0xF2, 0x0f,
  67. 0xAA, 0x00,
  68. 0xF8, 0xff,
  69. 0x00, 0x00,
  70. };
  71. static u16 vid_regs_fp[] = {
  72. 0x028, 0x067,
  73. 0x120, 0x016,
  74. 0x121, 0xcF2,
  75. 0x122, 0x0F2,
  76. 0x123, 0x00c,
  77. 0x124, 0x2d0,
  78. 0x125, 0x2e0,
  79. 0x126, 0x004,
  80. 0x128, 0x1E0,
  81. 0x12A, 0x016,
  82. 0x12B, 0x0F2,
  83. 0x12C, 0x0F2,
  84. 0x12D, 0x00c,
  85. 0x12E, 0x2d0,
  86. 0x12F, 0x2e0,
  87. 0x130, 0x004,
  88. 0x132, 0x1E0,
  89. 0x140, 0x060,
  90. 0x153, 0x00C,
  91. 0x154, 0x200,
  92. 0x150, 0x801,
  93. 0x000, 0x000
  94. };
  95. /* PAL specific values */
  96. static u16 vid_regs_fp_pal[] =
  97. {
  98. 0x120, 0x017,
  99. 0x121, 0xd22,
  100. 0x122, 0x122,
  101. 0x12A, 0x017,
  102. 0x12B, 0x122,
  103. 0x12C, 0x122,
  104. 0x140, 0x060,
  105. 0x000, 0x000,
  106. };
  107. struct s2250 {
  108. struct v4l2_subdev sd;
  109. v4l2_std_id std;
  110. int input;
  111. int brightness;
  112. int contrast;
  113. int saturation;
  114. int hue;
  115. int reg12b_val;
  116. int audio_input;
  117. struct i2c_client *audio;
  118. };
  119. static inline struct s2250 *to_state(struct v4l2_subdev *sd)
  120. {
  121. return container_of(sd, struct s2250, sd);
  122. }
  123. /* from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
  124. static int go7007_usb_vendor_request(struct go7007 *go, u16 request,
  125. u16 value, u16 index, void *transfer_buffer, int length, int in)
  126. {
  127. struct go7007_usb *usb = go->hpi_context;
  128. int timeout = 5000;
  129. if (in) {
  130. return usb_control_msg(usb->usbdev,
  131. usb_rcvctrlpipe(usb->usbdev, 0), request,
  132. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  133. value, index, transfer_buffer, length, timeout);
  134. } else {
  135. return usb_control_msg(usb->usbdev,
  136. usb_sndctrlpipe(usb->usbdev, 0), request,
  137. USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  138. value, index, transfer_buffer, length, timeout);
  139. }
  140. }
  141. /* end from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
  142. static int write_reg(struct i2c_client *client, u8 reg, u8 value)
  143. {
  144. struct go7007 *go = i2c_get_adapdata(client->adapter);
  145. struct go7007_usb *usb;
  146. int rc;
  147. int dev_addr = client->addr << 1; /* firmware wants 8-bit address */
  148. u8 *buf;
  149. if (go == NULL)
  150. return -ENODEV;
  151. if (go->status == STATUS_SHUTDOWN)
  152. return -EBUSY;
  153. buf = kzalloc(16, GFP_KERNEL);
  154. if (buf == NULL)
  155. return -ENOMEM;
  156. usb = go->hpi_context;
  157. if (mutex_lock_interruptible(&usb->i2c_lock) != 0) {
  158. printk(KERN_INFO "i2c lock failed\n");
  159. kfree(buf);
  160. return -EINTR;
  161. }
  162. rc = go7007_usb_vendor_request(go, 0x55, dev_addr,
  163. (reg<<8 | value),
  164. buf,
  165. 16, 1);
  166. mutex_unlock(&usb->i2c_lock);
  167. kfree(buf);
  168. return rc;
  169. }
  170. static int write_reg_fp(struct i2c_client *client, u16 addr, u16 val)
  171. {
  172. struct go7007 *go = i2c_get_adapdata(client->adapter);
  173. struct go7007_usb *usb;
  174. u8 *buf;
  175. struct s2250 *dec = i2c_get_clientdata(client);
  176. if (go == NULL)
  177. return -ENODEV;
  178. if (go->status == STATUS_SHUTDOWN)
  179. return -EBUSY;
  180. buf = kzalloc(16, GFP_KERNEL);
  181. if (buf == NULL)
  182. return -ENOMEM;
  183. memset(buf, 0xcd, 6);
  184. usb = go->hpi_context;
  185. if (mutex_lock_interruptible(&usb->i2c_lock) != 0) {
  186. printk(KERN_INFO "i2c lock failed\n");
  187. kfree(buf);
  188. return -EINTR;
  189. }
  190. if (go7007_usb_vendor_request(go, 0x57, addr, val, buf, 16, 1) < 0) {
  191. kfree(buf);
  192. return -EFAULT;
  193. }
  194. mutex_unlock(&usb->i2c_lock);
  195. if (buf[0] == 0) {
  196. unsigned int subaddr, val_read;
  197. subaddr = (buf[4] << 8) + buf[5];
  198. val_read = (buf[2] << 8) + buf[3];
  199. kfree(buf);
  200. if (val_read != val) {
  201. printk(KERN_INFO "invalid fp write %x %x\n",
  202. val_read, val);
  203. return -EFAULT;
  204. }
  205. if (subaddr != addr) {
  206. printk(KERN_INFO "invalid fp write addr %x %x\n",
  207. subaddr, addr);
  208. return -EFAULT;
  209. }
  210. } else {
  211. kfree(buf);
  212. return -EFAULT;
  213. }
  214. /* save last 12b value */
  215. if (addr == 0x12b)
  216. dec->reg12b_val = val;
  217. return 0;
  218. }
  219. static int read_reg_fp(struct i2c_client *client, u16 addr, u16 *val)
  220. {
  221. struct go7007 *go = i2c_get_adapdata(client->adapter);
  222. struct go7007_usb *usb;
  223. u8 *buf;
  224. if (go == NULL)
  225. return -ENODEV;
  226. if (go->status == STATUS_SHUTDOWN)
  227. return -EBUSY;
  228. buf = kzalloc(16, GFP_KERNEL);
  229. if (buf == NULL)
  230. return -ENOMEM;
  231. memset(buf, 0xcd, 6);
  232. usb = go->hpi_context;
  233. if (mutex_lock_interruptible(&usb->i2c_lock) != 0) {
  234. printk(KERN_INFO "i2c lock failed\n");
  235. kfree(buf);
  236. return -EINTR;
  237. }
  238. if (go7007_usb_vendor_request(go, 0x58, addr, 0, buf, 16, 1) < 0) {
  239. kfree(buf);
  240. return -EFAULT;
  241. }
  242. mutex_unlock(&usb->i2c_lock);
  243. *val = (buf[0] << 8) | buf[1];
  244. kfree(buf);
  245. return 0;
  246. }
  247. static int write_regs(struct i2c_client *client, u8 *regs)
  248. {
  249. int i;
  250. for (i = 0; !((regs[i] == 0x00) && (regs[i+1] == 0x00)); i += 2) {
  251. if (write_reg(client, regs[i], regs[i+1]) < 0) {
  252. printk(KERN_INFO "s2250: failed\n");
  253. return -1;
  254. }
  255. }
  256. return 0;
  257. }
  258. static int write_regs_fp(struct i2c_client *client, u16 *regs)
  259. {
  260. int i;
  261. for (i = 0; !((regs[i] == 0x00) && (regs[i+1] == 0x00)); i += 2) {
  262. if (write_reg_fp(client, regs[i], regs[i+1]) < 0) {
  263. printk(KERN_INFO "s2250: failed fp\n");
  264. return -1;
  265. }
  266. }
  267. return 0;
  268. }
  269. /* ------------------------------------------------------------------------- */
  270. static int s2250_s_video_routing(struct v4l2_subdev *sd, u32 input, u32 output,
  271. u32 config)
  272. {
  273. struct s2250 *state = to_state(sd);
  274. struct i2c_client *client = v4l2_get_subdevdata(sd);
  275. int vidsys;
  276. vidsys = (state->std == V4L2_STD_NTSC) ? 0x01 : 0x00;
  277. if (input == 0) {
  278. /* composite */
  279. write_reg_fp(client, 0x20, 0x020 | vidsys);
  280. write_reg_fp(client, 0x21, 0x662);
  281. write_reg_fp(client, 0x140, 0x060);
  282. } else if (input == 1) {
  283. /* S-Video */
  284. write_reg_fp(client, 0x20, 0x040 | vidsys);
  285. write_reg_fp(client, 0x21, 0x666);
  286. write_reg_fp(client, 0x140, 0x060);
  287. } else {
  288. return -EINVAL;
  289. }
  290. state->input = input;
  291. return 0;
  292. }
  293. static int s2250_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
  294. {
  295. struct s2250 *state = to_state(sd);
  296. struct i2c_client *client = v4l2_get_subdevdata(sd);
  297. u16 vidsource;
  298. vidsource = (state->input == 1) ? 0x040 : 0x020;
  299. switch (norm) {
  300. case V4L2_STD_NTSC:
  301. write_regs_fp(client, vid_regs_fp);
  302. write_reg_fp(client, 0x20, vidsource | 1);
  303. break;
  304. case V4L2_STD_PAL:
  305. write_regs_fp(client, vid_regs_fp);
  306. write_regs_fp(client, vid_regs_fp_pal);
  307. write_reg_fp(client, 0x20, vidsource);
  308. break;
  309. default:
  310. return -EINVAL;
  311. }
  312. state->std = norm;
  313. return 0;
  314. }
  315. static int s2250_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *query)
  316. {
  317. switch (query->id) {
  318. case V4L2_CID_BRIGHTNESS:
  319. return v4l2_ctrl_query_fill(query, 0, 100, 1, 50);
  320. case V4L2_CID_CONTRAST:
  321. return v4l2_ctrl_query_fill(query, 0, 100, 1, 50);
  322. case V4L2_CID_SATURATION:
  323. return v4l2_ctrl_query_fill(query, 0, 100, 1, 50);
  324. case V4L2_CID_HUE:
  325. return v4l2_ctrl_query_fill(query, -50, 50, 1, 0);
  326. default:
  327. return -EINVAL;
  328. }
  329. return 0;
  330. }
  331. static int s2250_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
  332. {
  333. struct s2250 *state = to_state(sd);
  334. struct i2c_client *client = v4l2_get_subdevdata(sd);
  335. int value1;
  336. u16 oldvalue;
  337. switch (ctrl->id) {
  338. case V4L2_CID_BRIGHTNESS:
  339. if (ctrl->value > 100)
  340. state->brightness = 100;
  341. else if (ctrl->value < 0)
  342. state->brightness = 0;
  343. else
  344. state->brightness = ctrl->value;
  345. value1 = (state->brightness - 50) * 255 / 100;
  346. read_reg_fp(client, VPX322_ADDR_BRIGHTNESS0, &oldvalue);
  347. write_reg_fp(client, VPX322_ADDR_BRIGHTNESS0,
  348. value1 | (oldvalue & ~0xff));
  349. read_reg_fp(client, VPX322_ADDR_BRIGHTNESS1, &oldvalue);
  350. write_reg_fp(client, VPX322_ADDR_BRIGHTNESS1,
  351. value1 | (oldvalue & ~0xff));
  352. write_reg_fp(client, 0x140, 0x60);
  353. break;
  354. case V4L2_CID_CONTRAST:
  355. if (ctrl->value > 100)
  356. state->contrast = 100;
  357. else if (ctrl->value < 0)
  358. state->contrast = 0;
  359. else
  360. state->contrast = ctrl->value;
  361. value1 = state->contrast * 0x40 / 100;
  362. if (value1 > 0x3f)
  363. value1 = 0x3f; /* max */
  364. read_reg_fp(client, VPX322_ADDR_CONTRAST0, &oldvalue);
  365. write_reg_fp(client, VPX322_ADDR_CONTRAST0,
  366. value1 | (oldvalue & ~0x3f));
  367. read_reg_fp(client, VPX322_ADDR_CONTRAST1, &oldvalue);
  368. write_reg_fp(client, VPX322_ADDR_CONTRAST1,
  369. value1 | (oldvalue & ~0x3f));
  370. write_reg_fp(client, 0x140, 0x60);
  371. break;
  372. case V4L2_CID_SATURATION:
  373. if (ctrl->value > 100)
  374. state->saturation = 100;
  375. else if (ctrl->value < 0)
  376. state->saturation = 0;
  377. else
  378. state->saturation = ctrl->value;
  379. value1 = state->saturation * 4140 / 100;
  380. if (value1 > 4094)
  381. value1 = 4094;
  382. write_reg_fp(client, VPX322_ADDR_SAT, value1);
  383. break;
  384. case V4L2_CID_HUE:
  385. if (ctrl->value > 50)
  386. state->hue = 50;
  387. else if (ctrl->value < -50)
  388. state->hue = -50;
  389. else
  390. state->hue = ctrl->value;
  391. /* clamp the hue range */
  392. value1 = state->hue * 280 / 50;
  393. write_reg_fp(client, VPX322_ADDR_HUE, value1);
  394. break;
  395. default:
  396. return -EINVAL;
  397. }
  398. return 0;
  399. }
  400. static int s2250_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
  401. {
  402. struct s2250 *state = to_state(sd);
  403. switch (ctrl->id) {
  404. case V4L2_CID_BRIGHTNESS:
  405. ctrl->value = state->brightness;
  406. break;
  407. case V4L2_CID_CONTRAST:
  408. ctrl->value = state->contrast;
  409. break;
  410. case V4L2_CID_SATURATION:
  411. ctrl->value = state->saturation;
  412. break;
  413. case V4L2_CID_HUE:
  414. ctrl->value = state->hue;
  415. break;
  416. default:
  417. return -EINVAL;
  418. }
  419. return 0;
  420. }
  421. static int s2250_s_mbus_fmt(struct v4l2_subdev *sd,
  422. struct v4l2_mbus_framefmt *fmt)
  423. {
  424. struct s2250 *state = to_state(sd);
  425. struct i2c_client *client = v4l2_get_subdevdata(sd);
  426. if (fmt->height < 640) {
  427. write_reg_fp(client, 0x12b, state->reg12b_val | 0x400);
  428. write_reg_fp(client, 0x140, 0x060);
  429. } else {
  430. write_reg_fp(client, 0x12b, state->reg12b_val & ~0x400);
  431. write_reg_fp(client, 0x140, 0x060);
  432. }
  433. return 0;
  434. }
  435. static int s2250_s_audio_routing(struct v4l2_subdev *sd, u32 input, u32 output,
  436. u32 config)
  437. {
  438. struct s2250 *state = to_state(sd);
  439. switch (input) {
  440. case 0:
  441. write_reg(state->audio, 0x08, 0x02); /* Line In */
  442. break;
  443. case 1:
  444. write_reg(state->audio, 0x08, 0x04); /* Mic */
  445. break;
  446. case 2:
  447. write_reg(state->audio, 0x08, 0x05); /* Mic Boost */
  448. break;
  449. default:
  450. return -EINVAL;
  451. }
  452. state->audio_input = input;
  453. return 0;
  454. }
  455. static int s2250_log_status(struct v4l2_subdev *sd)
  456. {
  457. struct s2250 *state = to_state(sd);
  458. v4l2_info(sd, "Standard: %s\n", state->std == V4L2_STD_NTSC ? "NTSC" :
  459. state->std == V4L2_STD_PAL ? "PAL" :
  460. state->std == V4L2_STD_SECAM ? "SECAM" :
  461. "unknown");
  462. v4l2_info(sd, "Input: %s\n", state->input == 0 ? "Composite" :
  463. state->input == 1 ? "S-video" :
  464. "error");
  465. v4l2_info(sd, "Brightness: %d\n", state->brightness);
  466. v4l2_info(sd, "Contrast: %d\n", state->contrast);
  467. v4l2_info(sd, "Saturation: %d\n", state->saturation);
  468. v4l2_info(sd, "Hue: %d\n", state->hue); return 0;
  469. v4l2_info(sd, "Audio input: %s\n", state->audio_input == 0 ? "Line In" :
  470. state->audio_input == 1 ? "Mic" :
  471. state->audio_input == 2 ? "Mic Boost" :
  472. "error");
  473. return 0;
  474. }
  475. /* --------------------------------------------------------------------------*/
  476. static const struct v4l2_subdev_core_ops s2250_core_ops = {
  477. .log_status = s2250_log_status,
  478. .g_ctrl = s2250_g_ctrl,
  479. .s_ctrl = s2250_s_ctrl,
  480. .queryctrl = s2250_queryctrl,
  481. .s_std = s2250_s_std,
  482. };
  483. static const struct v4l2_subdev_audio_ops s2250_audio_ops = {
  484. .s_routing = s2250_s_audio_routing,
  485. };
  486. static const struct v4l2_subdev_video_ops s2250_video_ops = {
  487. .s_routing = s2250_s_video_routing,
  488. .s_mbus_fmt = s2250_s_mbus_fmt,
  489. };
  490. static const struct v4l2_subdev_ops s2250_ops = {
  491. .core = &s2250_core_ops,
  492. .audio = &s2250_audio_ops,
  493. .video = &s2250_video_ops,
  494. };
  495. /* --------------------------------------------------------------------------*/
  496. static int s2250_probe(struct i2c_client *client,
  497. const struct i2c_device_id *id)
  498. {
  499. struct i2c_client *audio;
  500. struct i2c_adapter *adapter = client->adapter;
  501. struct s2250 *state;
  502. struct v4l2_subdev *sd;
  503. u8 *data;
  504. struct go7007 *go = i2c_get_adapdata(adapter);
  505. struct go7007_usb *usb = go->hpi_context;
  506. audio = i2c_new_dummy(adapter, TLV320_ADDRESS >> 1);
  507. if (audio == NULL)
  508. return -ENOMEM;
  509. state = kmalloc(sizeof(struct s2250), GFP_KERNEL);
  510. if (state == NULL) {
  511. i2c_unregister_device(audio);
  512. return -ENOMEM;
  513. }
  514. sd = &state->sd;
  515. v4l2_i2c_subdev_init(sd, client, &s2250_ops);
  516. v4l2_info(sd, "initializing %s at address 0x%x on %s\n",
  517. "Sensoray 2250/2251", client->addr, client->adapter->name);
  518. state->std = V4L2_STD_NTSC;
  519. state->brightness = 50;
  520. state->contrast = 50;
  521. state->saturation = 50;
  522. state->hue = 0;
  523. state->audio = audio;
  524. /* initialize the audio */
  525. if (write_regs(audio, aud_regs) < 0) {
  526. printk(KERN_ERR
  527. "s2250: error initializing audio\n");
  528. i2c_unregister_device(audio);
  529. kfree(state);
  530. return 0;
  531. }
  532. if (write_regs(client, vid_regs) < 0) {
  533. printk(KERN_ERR
  534. "s2250: error initializing decoder\n");
  535. i2c_unregister_device(audio);
  536. kfree(state);
  537. return 0;
  538. }
  539. if (write_regs_fp(client, vid_regs_fp) < 0) {
  540. printk(KERN_ERR
  541. "s2250: error initializing decoder\n");
  542. i2c_unregister_device(audio);
  543. kfree(state);
  544. return 0;
  545. }
  546. /* set default channel */
  547. /* composite */
  548. write_reg_fp(client, 0x20, 0x020 | 1);
  549. write_reg_fp(client, 0x21, 0x662);
  550. write_reg_fp(client, 0x140, 0x060);
  551. /* set default audio input */
  552. state->audio_input = 0;
  553. write_reg(client, 0x08, 0x02); /* Line In */
  554. if (mutex_lock_interruptible(&usb->i2c_lock) == 0) {
  555. data = kzalloc(16, GFP_KERNEL);
  556. if (data != NULL) {
  557. int rc;
  558. rc = go7007_usb_vendor_request(go, 0x41, 0, 0,
  559. data, 16, 1);
  560. if (rc > 0) {
  561. u8 mask;
  562. data[0] = 0;
  563. mask = 1<<5;
  564. data[0] &= ~mask;
  565. data[1] |= mask;
  566. go7007_usb_vendor_request(go, 0x40, 0,
  567. (data[1]<<8)
  568. + data[1],
  569. data, 16, 0);
  570. }
  571. kfree(data);
  572. }
  573. mutex_unlock(&usb->i2c_lock);
  574. }
  575. v4l2_info(sd, "initialized successfully\n");
  576. return 0;
  577. }
  578. static int s2250_remove(struct i2c_client *client)
  579. {
  580. struct v4l2_subdev *sd = i2c_get_clientdata(client);
  581. v4l2_device_unregister_subdev(sd);
  582. kfree(to_state(sd));
  583. return 0;
  584. }
  585. static const struct i2c_device_id s2250_id[] = {
  586. { "s2250", 0 },
  587. { }
  588. };
  589. MODULE_DEVICE_TABLE(i2c, s2250_id);
  590. static struct i2c_driver s2250_driver = {
  591. .driver = {
  592. .owner = THIS_MODULE,
  593. .name = "s2250",
  594. },
  595. .probe = s2250_probe,
  596. .remove = s2250_remove,
  597. .id_table = s2250_id,
  598. };
  599. static __init int init_s2250(void)
  600. {
  601. return i2c_add_driver(&s2250_driver);
  602. }
  603. static __exit void exit_s2250(void)
  604. {
  605. i2c_del_driver(&s2250_driver);
  606. }
  607. module_init(init_s2250);
  608. module_exit(exit_s2250);