vpx3220.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /*
  2. * vpx3220a, vpx3216b & vpx3214c video decoder driver version 0.0.1
  3. *
  4. * Copyright (C) 2001 Laurent Pinchart <lpinchart@freegates.be>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <linux/module.h>
  21. #include <linux/init.h>
  22. #include <linux/delay.h>
  23. #include <linux/types.h>
  24. #include <linux/slab.h>
  25. #include <linux/byteorder/swab.h>
  26. #include <asm/io.h>
  27. #include <asm/uaccess.h>
  28. #include <linux/i2c.h>
  29. #define I2C_NAME(x) (x)->name
  30. #include <linux/videodev.h>
  31. #include <linux/video_decoder.h>
  32. #define I2C_VPX3220 0x86
  33. #define VPX3220_DEBUG KERN_DEBUG "vpx3220: "
  34. static int debug = 0;
  35. module_param(debug, int, 0);
  36. MODULE_PARM_DESC(debug, "Debug level (0-1)");
  37. #define dprintk(num, format, args...) \
  38. do { \
  39. if (debug >= num) \
  40. printk(format, ##args); \
  41. } while (0)
  42. #define VPX_TIMEOUT_COUNT 10
  43. /* ----------------------------------------------------------------------- */
  44. struct vpx3220 {
  45. unsigned char reg[255];
  46. int norm;
  47. int input;
  48. int enable;
  49. int bright;
  50. int contrast;
  51. int hue;
  52. int sat;
  53. };
  54. static char *inputs[] = { "internal", "composite", "svideo" };
  55. /* ----------------------------------------------------------------------- */
  56. static inline int
  57. vpx3220_write (struct i2c_client *client,
  58. u8 reg,
  59. u8 value)
  60. {
  61. struct vpx3220 *decoder = i2c_get_clientdata(client);
  62. decoder->reg[reg] = value;
  63. return i2c_smbus_write_byte_data(client, reg, value);
  64. }
  65. static inline int
  66. vpx3220_read (struct i2c_client *client,
  67. u8 reg)
  68. {
  69. return i2c_smbus_read_byte_data(client, reg);
  70. }
  71. static int
  72. vpx3220_fp_status (struct i2c_client *client)
  73. {
  74. unsigned char status;
  75. unsigned int i;
  76. for (i = 0; i < VPX_TIMEOUT_COUNT; i++) {
  77. status = vpx3220_read(client, 0x29);
  78. if (!(status & 4))
  79. return 0;
  80. udelay(10);
  81. if (need_resched())
  82. cond_resched();
  83. }
  84. return -1;
  85. }
  86. static int
  87. vpx3220_fp_write (struct i2c_client *client,
  88. u8 fpaddr,
  89. u16 data)
  90. {
  91. /* Write the 16-bit address to the FPWR register */
  92. if (i2c_smbus_write_word_data(client, 0x27, swab16(fpaddr)) == -1) {
  93. dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__);
  94. return -1;
  95. }
  96. if (vpx3220_fp_status(client) < 0)
  97. return -1;
  98. /* Write the 16-bit data to the FPDAT register */
  99. if (i2c_smbus_write_word_data(client, 0x28, swab16(data)) == -1) {
  100. dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__);
  101. return -1;
  102. }
  103. return 0;
  104. }
  105. static u16
  106. vpx3220_fp_read (struct i2c_client *client,
  107. u16 fpaddr)
  108. {
  109. s16 data;
  110. /* Write the 16-bit address to the FPRD register */
  111. if (i2c_smbus_write_word_data(client, 0x26, swab16(fpaddr)) == -1) {
  112. dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__);
  113. return -1;
  114. }
  115. if (vpx3220_fp_status(client) < 0)
  116. return -1;
  117. /* Read the 16-bit data from the FPDAT register */
  118. data = i2c_smbus_read_word_data(client, 0x28);
  119. if (data == -1) {
  120. dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__);
  121. return -1;
  122. }
  123. return swab16(data);
  124. }
  125. static int
  126. vpx3220_write_block (struct i2c_client *client,
  127. const u8 *data,
  128. unsigned int len)
  129. {
  130. u8 reg;
  131. int ret = -1;
  132. while (len >= 2) {
  133. reg = *data++;
  134. if ((ret =
  135. vpx3220_write(client, reg, *data++)) < 0)
  136. break;
  137. len -= 2;
  138. }
  139. return ret;
  140. }
  141. static int
  142. vpx3220_write_fp_block (struct i2c_client *client,
  143. const u16 *data,
  144. unsigned int len)
  145. {
  146. u8 reg;
  147. int ret = 0;
  148. while (len > 1) {
  149. reg = *data++;
  150. ret |= vpx3220_fp_write(client, reg, *data++);
  151. len -= 2;
  152. }
  153. return ret;
  154. }
  155. /* ---------------------------------------------------------------------- */
  156. static const unsigned short init_ntsc[] = {
  157. 0x1c, 0x00, /* NTSC tint angle */
  158. 0x88, 17, /* Window 1 vertical */
  159. 0x89, 240, /* Vertical lines in */
  160. 0x8a, 240, /* Vertical lines out */
  161. 0x8b, 000, /* Horizontal begin */
  162. 0x8c, 640, /* Horizontal length */
  163. 0x8d, 640, /* Number of pixels */
  164. 0x8f, 0xc00, /* Disable window 2 */
  165. 0xf0, 0x73, /* 13.5 MHz transport, Forced
  166. * mode, latch windows */
  167. 0xf2, 0x13, /* NTSC M, composite input */
  168. 0xe7, 0x1e1, /* Enable vertical standard
  169. * locking @ 240 lines */
  170. };
  171. static const unsigned short init_pal[] = {
  172. 0x88, 23, /* Window 1 vertical begin */
  173. 0x89, 288, /* Vertical lines in (16 lines
  174. * skipped by the VFE) */
  175. 0x8a, 288, /* Vertical lines out (16 lines
  176. * skipped by the VFE) */
  177. 0x8b, 16, /* Horizontal begin */
  178. 0x8c, 768, /* Horizontal length */
  179. 0x8d, 784, /* Number of pixels
  180. * Must be >= Horizontal begin + Horizontal length */
  181. 0x8f, 0xc00, /* Disable window 2 */
  182. 0xf0, 0x77, /* 13.5 MHz transport, Forced
  183. * mode, latch windows */
  184. 0xf2, 0x3d1, /* PAL B,G,H,I, composite input */
  185. 0xe7, 0x241, /* PAL/SECAM set to 288 lines */
  186. };
  187. static const unsigned short init_secam[] = {
  188. 0x88, 23, /* Window 1 vertical begin */
  189. 0x89, 288, /* Vertical lines in (16 lines
  190. * skipped by the VFE) */
  191. 0x8a, 288, /* Vertical lines out (16 lines
  192. * skipped by the VFE) */
  193. 0x8b, 16, /* Horizontal begin */
  194. 0x8c, 768, /* Horizontal length */
  195. 0x8d, 784, /* Number of pixels
  196. * Must be >= Horizontal begin + Horizontal length */
  197. 0x8f, 0xc00, /* Disable window 2 */
  198. 0xf0, 0x77, /* 13.5 MHz transport, Forced
  199. * mode, latch windows */
  200. 0xf2, 0x3d5, /* SECAM, composite input */
  201. 0xe7, 0x241, /* PAL/SECAM set to 288 lines */
  202. };
  203. static const unsigned char init_common[] = {
  204. 0xf2, 0x00, /* Disable all outputs */
  205. 0x33, 0x0d, /* Luma : VIN2, Chroma : CIN
  206. * (clamp off) */
  207. 0xd8, 0xa8, /* HREF/VREF active high, VREF
  208. * pulse = 2, Odd/Even flag */
  209. 0x20, 0x03, /* IF compensation 0dB/oct */
  210. 0xe0, 0xff, /* Open up all comparators */
  211. 0xe1, 0x00,
  212. 0xe2, 0x7f,
  213. 0xe3, 0x80,
  214. 0xe4, 0x7f,
  215. 0xe5, 0x80,
  216. 0xe6, 0x00, /* Brightness set to 0 */
  217. 0xe7, 0xe0, /* Contrast to 1.0, noise shaping
  218. * 10 to 8 2-bit error diffusion */
  219. 0xe8, 0xf8, /* YUV422, CbCr binary offset,
  220. * ... (p.32) */
  221. 0xea, 0x18, /* LLC2 connected, output FIFO
  222. * reset with VACTintern */
  223. 0xf0, 0x8a, /* Half full level to 10, bus
  224. * shuffler [7:0, 23:16, 15:8] */
  225. 0xf1, 0x18, /* Single clock, sync mode, no
  226. * FE delay, no HLEN counter */
  227. 0xf8, 0x12, /* Port A, PIXCLK, HF# & FE#
  228. * strength to 2 */
  229. 0xf9, 0x24, /* Port B, HREF, VREF, PREF &
  230. * ALPHA strength to 4 */
  231. };
  232. static const unsigned short init_fp[] = {
  233. 0x59, 0,
  234. 0xa0, 2070, /* ACC reference */
  235. 0xa3, 0,
  236. 0xa4, 0,
  237. 0xa8, 30,
  238. 0xb2, 768,
  239. 0xbe, 27,
  240. 0x58, 0,
  241. 0x26, 0,
  242. 0x4b, 0x298, /* PLL gain */
  243. };
  244. static void
  245. vpx3220_dump_i2c (struct i2c_client *client)
  246. {
  247. int len = sizeof(init_common);
  248. const unsigned char *data = init_common;
  249. while (len > 1) {
  250. dprintk(1,
  251. KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n",
  252. *data, vpx3220_read(client, *data));
  253. data += 2;
  254. len -= 2;
  255. }
  256. }
  257. static int
  258. vpx3220_command (struct i2c_client *client,
  259. unsigned int cmd,
  260. void *arg)
  261. {
  262. struct vpx3220 *decoder = i2c_get_clientdata(client);
  263. switch (cmd) {
  264. case 0:
  265. {
  266. vpx3220_write_block(client, init_common,
  267. sizeof(init_common));
  268. vpx3220_write_fp_block(client, init_fp,
  269. sizeof(init_fp) >> 1);
  270. switch (decoder->norm) {
  271. case VIDEO_MODE_NTSC:
  272. vpx3220_write_fp_block(client, init_ntsc,
  273. sizeof(init_ntsc) >> 1);
  274. break;
  275. case VIDEO_MODE_PAL:
  276. vpx3220_write_fp_block(client, init_pal,
  277. sizeof(init_pal) >> 1);
  278. break;
  279. case VIDEO_MODE_SECAM:
  280. vpx3220_write_fp_block(client, init_secam,
  281. sizeof(init_secam) >> 1);
  282. break;
  283. default:
  284. vpx3220_write_fp_block(client, init_pal,
  285. sizeof(init_pal) >> 1);
  286. break;
  287. }
  288. }
  289. break;
  290. case DECODER_DUMP:
  291. {
  292. vpx3220_dump_i2c(client);
  293. }
  294. break;
  295. case DECODER_GET_CAPABILITIES:
  296. {
  297. struct video_decoder_capability *cap = arg;
  298. dprintk(1, KERN_DEBUG "%s: DECODER_GET_CAPABILITIES\n",
  299. I2C_NAME(client));
  300. cap->flags = VIDEO_DECODER_PAL |
  301. VIDEO_DECODER_NTSC |
  302. VIDEO_DECODER_SECAM |
  303. VIDEO_DECODER_AUTO |
  304. VIDEO_DECODER_CCIR;
  305. cap->inputs = 3;
  306. cap->outputs = 1;
  307. }
  308. break;
  309. case DECODER_GET_STATUS:
  310. {
  311. int res = 0, status;
  312. dprintk(1, KERN_INFO "%s: DECODER_GET_STATUS\n",
  313. I2C_NAME(client));
  314. status = vpx3220_fp_read(client, 0x0f3);
  315. dprintk(1, KERN_INFO "%s: status: 0x%04x\n", I2C_NAME(client),
  316. status);
  317. if (status < 0)
  318. return status;
  319. if ((status & 0x20) == 0) {
  320. res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR;
  321. switch (status & 0x18) {
  322. case 0x00:
  323. case 0x10:
  324. case 0x14:
  325. case 0x18:
  326. res |= DECODER_STATUS_PAL;
  327. break;
  328. case 0x08:
  329. res |= DECODER_STATUS_SECAM;
  330. break;
  331. case 0x04:
  332. case 0x0c:
  333. case 0x1c:
  334. res |= DECODER_STATUS_NTSC;
  335. break;
  336. }
  337. }
  338. *(int *) arg = res;
  339. }
  340. break;
  341. case DECODER_SET_NORM:
  342. {
  343. int *iarg = arg, data;
  344. int temp_input;
  345. /* Here we back up the input selection because it gets
  346. overwritten when we fill the registers with the
  347. choosen video norm */
  348. temp_input = vpx3220_fp_read(client, 0xf2);
  349. dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n",
  350. I2C_NAME(client), *iarg);
  351. switch (*iarg) {
  352. case VIDEO_MODE_NTSC:
  353. vpx3220_write_fp_block(client, init_ntsc,
  354. sizeof(init_ntsc) >> 1);
  355. dprintk(1, KERN_INFO "%s: norm switched to NTSC\n",
  356. I2C_NAME(client));
  357. break;
  358. case VIDEO_MODE_PAL:
  359. vpx3220_write_fp_block(client, init_pal,
  360. sizeof(init_pal) >> 1);
  361. dprintk(1, KERN_INFO "%s: norm switched to PAL\n",
  362. I2C_NAME(client));
  363. break;
  364. case VIDEO_MODE_SECAM:
  365. vpx3220_write_fp_block(client, init_secam,
  366. sizeof(init_secam) >> 1);
  367. dprintk(1, KERN_INFO "%s: norm switched to SECAM\n",
  368. I2C_NAME(client));
  369. break;
  370. case VIDEO_MODE_AUTO:
  371. /* FIXME This is only preliminary support */
  372. data = vpx3220_fp_read(client, 0xf2) & 0x20;
  373. vpx3220_fp_write(client, 0xf2, 0x00c0 | data);
  374. dprintk(1, KERN_INFO "%s: norm switched to Auto\n",
  375. I2C_NAME(client));
  376. break;
  377. default:
  378. return -EINVAL;
  379. }
  380. decoder->norm = *iarg;
  381. /* And here we set the backed up video input again */
  382. vpx3220_fp_write(client, 0xf2, temp_input | 0x0010);
  383. udelay(10);
  384. }
  385. break;
  386. case DECODER_SET_INPUT:
  387. {
  388. int *iarg = arg, data;
  389. /* RJ: *iarg = 0: ST8 (PCTV) input
  390. *iarg = 1: COMPOSITE input
  391. *iarg = 2: SVHS input */
  392. const int input[3][2] = {
  393. {0x0c, 0},
  394. {0x0d, 0},
  395. {0x0e, 1}
  396. };
  397. if (*iarg < 0 || *iarg > 2)
  398. return -EINVAL;
  399. dprintk(1, KERN_INFO "%s: input switched to %s\n",
  400. I2C_NAME(client), inputs[*iarg]);
  401. vpx3220_write(client, 0x33, input[*iarg][0]);
  402. data = vpx3220_fp_read(client, 0xf2) & ~(0x0020);
  403. if (data < 0)
  404. return data;
  405. /* 0x0010 is required to latch the setting */
  406. vpx3220_fp_write(client, 0xf2,
  407. data | (input[*iarg][1] << 5) | 0x0010);
  408. udelay(10);
  409. }
  410. break;
  411. case DECODER_SET_OUTPUT:
  412. {
  413. int *iarg = arg;
  414. /* not much choice of outputs */
  415. if (*iarg != 0) {
  416. return -EINVAL;
  417. }
  418. }
  419. break;
  420. case DECODER_ENABLE_OUTPUT:
  421. {
  422. int *iarg = arg;
  423. dprintk(1, KERN_DEBUG "%s: DECODER_ENABLE_OUTPUT %d\n",
  424. I2C_NAME(client), *iarg);
  425. vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00));
  426. }
  427. break;
  428. case DECODER_SET_PICTURE:
  429. {
  430. struct video_picture *pic = arg;
  431. if (decoder->bright != pic->brightness) {
  432. /* We want -128 to 128 we get 0-65535 */
  433. decoder->bright = pic->brightness;
  434. vpx3220_write(client, 0xe6,
  435. (decoder->bright - 32768) >> 8);
  436. }
  437. if (decoder->contrast != pic->contrast) {
  438. /* We want 0 to 64 we get 0-65535 */
  439. /* Bit 7 and 8 is for noise shaping */
  440. decoder->contrast = pic->contrast;
  441. vpx3220_write(client, 0xe7,
  442. (decoder->contrast >> 10) + 192);
  443. }
  444. if (decoder->sat != pic->colour) {
  445. /* We want 0 to 4096 we get 0-65535 */
  446. decoder->sat = pic->colour;
  447. vpx3220_fp_write(client, 0xa0,
  448. decoder->sat >> 4);
  449. }
  450. if (decoder->hue != pic->hue) {
  451. /* We want -512 to 512 we get 0-65535 */
  452. decoder->hue = pic->hue;
  453. vpx3220_fp_write(client, 0x1c,
  454. ((decoder->hue - 32768) >> 6) & 0xFFF);
  455. }
  456. }
  457. break;
  458. default:
  459. return -EINVAL;
  460. }
  461. return 0;
  462. }
  463. static int
  464. vpx3220_init_client (struct i2c_client *client)
  465. {
  466. vpx3220_write_block(client, init_common, sizeof(init_common));
  467. vpx3220_write_fp_block(client, init_fp, sizeof(init_fp) >> 1);
  468. /* Default to PAL */
  469. vpx3220_write_fp_block(client, init_pal, sizeof(init_pal) >> 1);
  470. return 0;
  471. }
  472. /* -----------------------------------------------------------------------
  473. * Client managment code
  474. */
  475. /*
  476. * Generic i2c probe
  477. * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
  478. */
  479. static unsigned short normal_i2c[] =
  480. { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4,
  481. I2C_CLIENT_END
  482. };
  483. static unsigned short ignore = I2C_CLIENT_END;
  484. static struct i2c_client_address_data addr_data = {
  485. .normal_i2c = normal_i2c,
  486. .probe = &ignore,
  487. .ignore = &ignore,
  488. };
  489. static struct i2c_driver vpx3220_i2c_driver;
  490. static int
  491. vpx3220_detach_client (struct i2c_client *client)
  492. {
  493. struct vpx3220 *decoder = i2c_get_clientdata(client);
  494. int err;
  495. err = i2c_detach_client(client);
  496. if (err) {
  497. return err;
  498. }
  499. kfree(decoder);
  500. kfree(client);
  501. return 0;
  502. }
  503. static int
  504. vpx3220_detect_client (struct i2c_adapter *adapter,
  505. int address,
  506. int kind)
  507. {
  508. int err;
  509. struct i2c_client *client;
  510. struct vpx3220 *decoder;
  511. dprintk(1, VPX3220_DEBUG "%s\n", __func__);
  512. /* Check if the adapter supports the needed features */
  513. if (!i2c_check_functionality
  514. (adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
  515. return 0;
  516. client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
  517. if (client == NULL) {
  518. return -ENOMEM;
  519. }
  520. client->addr = address;
  521. client->adapter = adapter;
  522. client->driver = &vpx3220_i2c_driver;
  523. /* Check for manufacture ID and part number */
  524. if (kind < 0) {
  525. u8 id;
  526. u16 pn;
  527. id = vpx3220_read(client, 0x00);
  528. if (id != 0xec) {
  529. dprintk(1,
  530. KERN_INFO
  531. "vpx3220_attach: Wrong manufacturer ID (0x%02x)\n",
  532. id);
  533. kfree(client);
  534. return 0;
  535. }
  536. pn = (vpx3220_read(client, 0x02) << 8) +
  537. vpx3220_read(client, 0x01);
  538. switch (pn) {
  539. case 0x4680:
  540. strlcpy(I2C_NAME(client), "vpx3220a",
  541. sizeof(I2C_NAME(client)));
  542. break;
  543. case 0x4260:
  544. strlcpy(I2C_NAME(client), "vpx3216b",
  545. sizeof(I2C_NAME(client)));
  546. break;
  547. case 0x4280:
  548. strlcpy(I2C_NAME(client), "vpx3214c",
  549. sizeof(I2C_NAME(client)));
  550. break;
  551. default:
  552. dprintk(1,
  553. KERN_INFO
  554. "%s: Wrong part number (0x%04x)\n",
  555. __func__, pn);
  556. kfree(client);
  557. return 0;
  558. }
  559. } else {
  560. strlcpy(I2C_NAME(client), "forced vpx32xx",
  561. sizeof(I2C_NAME(client)));
  562. }
  563. decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL);
  564. if (decoder == NULL) {
  565. kfree(client);
  566. return -ENOMEM;
  567. }
  568. decoder->norm = VIDEO_MODE_PAL;
  569. decoder->input = 0;
  570. decoder->enable = 1;
  571. decoder->bright = 32768;
  572. decoder->contrast = 32768;
  573. decoder->hue = 32768;
  574. decoder->sat = 32768;
  575. i2c_set_clientdata(client, decoder);
  576. err = i2c_attach_client(client);
  577. if (err) {
  578. kfree(client);
  579. kfree(decoder);
  580. return err;
  581. }
  582. dprintk(1, KERN_INFO "%s: vpx32xx client found at address 0x%02x\n",
  583. I2C_NAME(client), client->addr << 1);
  584. vpx3220_init_client(client);
  585. return 0;
  586. }
  587. static int
  588. vpx3220_attach_adapter (struct i2c_adapter *adapter)
  589. {
  590. int ret;
  591. ret = i2c_probe(adapter, &addr_data, &vpx3220_detect_client);
  592. dprintk(1, VPX3220_DEBUG "%s: i2c_probe returned %d\n",
  593. __func__, ret);
  594. return ret;
  595. }
  596. /* -----------------------------------------------------------------------
  597. * Driver initialization and cleanup code
  598. */
  599. static struct i2c_driver vpx3220_i2c_driver = {
  600. .driver = {
  601. .name = "vpx3220",
  602. },
  603. .id = I2C_DRIVERID_VPX3220,
  604. .attach_adapter = vpx3220_attach_adapter,
  605. .detach_client = vpx3220_detach_client,
  606. .command = vpx3220_command,
  607. };
  608. static int __init
  609. vpx3220_init (void)
  610. {
  611. return i2c_add_driver(&vpx3220_i2c_driver);
  612. }
  613. static void __exit
  614. vpx3220_cleanup (void)
  615. {
  616. i2c_del_driver(&vpx3220_i2c_driver);
  617. }
  618. module_init(vpx3220_init);
  619. module_exit(vpx3220_cleanup);
  620. MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video encoder driver");
  621. MODULE_AUTHOR("Laurent Pinchart");
  622. MODULE_LICENSE("GPL");