vpx3220.c 17 KB

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