vpx3220.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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. #include <linux/i2c-dev.h>
  30. #define I2C_NAME(x) (x)->name
  31. #include <linux/videodev.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, 0x173, /* 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 + 16, /* Vertical lines in (16 lines
  175. * skipped by the VFE) */
  176. 0x8a, 288 + 16, /* 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, 0x177, /* 13.5 MHz transport, Forced
  184. * mode, latch windows */
  185. 0xf2, 0x3d1, /* PAL B,G,H,I, composite input */
  186. 0xe7, 0x261, /* PAL/SECAM set to 288 + 16 lines
  187. * change to 0x241 for 288 lines */
  188. };
  189. static const unsigned short init_secam[] = {
  190. 0x88, 23 - 16, /* Window 1 vertical begin */
  191. 0x89, 288 + 16, /* Vertical lines in (16 lines
  192. * skipped by the VFE) */
  193. 0x8a, 288 + 16, /* Vertical lines out (16 lines
  194. * skipped by the VFE) */
  195. 0x8b, 16, /* Horizontal begin */
  196. 0x8c, 768, /* Horizontal length */
  197. 0x8d, 784, /* Number of pixels
  198. * Must be >= Horizontal begin + Horizontal length */
  199. 0x8f, 0xc00, /* Disable window 2 */
  200. 0xf0, 0x177, /* 13.5 MHz transport, Forced
  201. * mode, latch windows */
  202. 0xf2, 0x3d5, /* SECAM, composite input */
  203. 0xe7, 0x261, /* PAL/SECAM set to 288 + 16 lines
  204. * change to 0x241 for 288 lines */
  205. };
  206. static const unsigned char init_common[] = {
  207. 0xf2, 0x00, /* Disable all outputs */
  208. 0x33, 0x0d, /* Luma : VIN2, Chroma : CIN
  209. * (clamp off) */
  210. 0xd8, 0xa8, /* HREF/VREF active high, VREF
  211. * pulse = 2, Odd/Even flag */
  212. 0x20, 0x03, /* IF compensation 0dB/oct */
  213. 0xe0, 0xff, /* Open up all comparators */
  214. 0xe1, 0x00,
  215. 0xe2, 0x7f,
  216. 0xe3, 0x80,
  217. 0xe4, 0x7f,
  218. 0xe5, 0x80,
  219. 0xe6, 0x00, /* Brightness set to 0 */
  220. 0xe7, 0xe0, /* Contrast to 1.0, noise shaping
  221. * 10 to 8 2-bit error diffusion */
  222. 0xe8, 0xf8, /* YUV422, CbCr binary offset,
  223. * ... (p.32) */
  224. 0xea, 0x18, /* LLC2 connected, output FIFO
  225. * reset with VACTintern */
  226. 0xf0, 0x8a, /* Half full level to 10, bus
  227. * shuffler [7:0, 23:16, 15:8] */
  228. 0xf1, 0x18, /* Single clock, sync mode, no
  229. * FE delay, no HLEN counter */
  230. 0xf8, 0x12, /* Port A, PIXCLK, HF# & FE#
  231. * strength to 2 */
  232. 0xf9, 0x24, /* Port B, HREF, VREF, PREF &
  233. * ALPHA strength to 4 */
  234. };
  235. static const unsigned short init_fp[] = {
  236. 0x59, 0,
  237. 0xa0, 2070, /* ACC reference */
  238. 0xa3, 0,
  239. 0xa4, 0,
  240. 0xa8, 30,
  241. 0xb2, 768,
  242. 0xbe, 27,
  243. 0x58, 0,
  244. 0x26, 0,
  245. 0x4b, 0x298, /* PLL gain */
  246. };
  247. static void
  248. vpx3220_dump_i2c (struct i2c_client *client)
  249. {
  250. int len = sizeof(init_common);
  251. const unsigned char *data = init_common;
  252. while (len > 1) {
  253. dprintk(1,
  254. KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n",
  255. *data, vpx3220_read(client, *data));
  256. data += 2;
  257. len -= 2;
  258. }
  259. }
  260. static int
  261. vpx3220_command (struct i2c_client *client,
  262. unsigned int cmd,
  263. void *arg)
  264. {
  265. struct vpx3220 *decoder = i2c_get_clientdata(client);
  266. switch (cmd) {
  267. case 0:
  268. {
  269. vpx3220_write_block(client, init_common,
  270. sizeof(init_common));
  271. vpx3220_write_fp_block(client, init_fp,
  272. sizeof(init_fp) >> 1);
  273. switch (decoder->norm) {
  274. case VIDEO_MODE_NTSC:
  275. vpx3220_write_fp_block(client, init_ntsc,
  276. sizeof(init_ntsc) >> 1);
  277. break;
  278. case VIDEO_MODE_PAL:
  279. vpx3220_write_fp_block(client, init_pal,
  280. sizeof(init_pal) >> 1);
  281. break;
  282. case VIDEO_MODE_SECAM:
  283. vpx3220_write_fp_block(client, init_secam,
  284. sizeof(init_secam) >> 1);
  285. break;
  286. default:
  287. vpx3220_write_fp_block(client, init_pal,
  288. sizeof(init_pal) >> 1);
  289. break;
  290. }
  291. }
  292. break;
  293. case DECODER_DUMP:
  294. {
  295. vpx3220_dump_i2c(client);
  296. }
  297. break;
  298. case DECODER_GET_CAPABILITIES:
  299. {
  300. struct video_decoder_capability *cap = arg;
  301. dprintk(1, KERN_DEBUG "%s: DECODER_GET_CAPABILITIES\n",
  302. I2C_NAME(client));
  303. cap->flags = VIDEO_DECODER_PAL |
  304. VIDEO_DECODER_NTSC |
  305. VIDEO_DECODER_SECAM |
  306. VIDEO_DECODER_AUTO |
  307. VIDEO_DECODER_CCIR;
  308. cap->inputs = 3;
  309. cap->outputs = 1;
  310. }
  311. break;
  312. case DECODER_GET_STATUS:
  313. {
  314. int res = 0, status;
  315. dprintk(1, KERN_INFO "%s: DECODER_GET_STATUS\n",
  316. I2C_NAME(client));
  317. status = vpx3220_fp_read(client, 0x0f3);
  318. dprintk(1, KERN_INFO "%s: status: 0x%04x\n", I2C_NAME(client),
  319. status);
  320. if (status < 0)
  321. return status;
  322. if ((status & 0x20) == 0) {
  323. res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR;
  324. switch (status & 0x18) {
  325. case 0x00:
  326. case 0x10:
  327. case 0x14:
  328. case 0x18:
  329. res |= DECODER_STATUS_PAL;
  330. break;
  331. case 0x08:
  332. res |= DECODER_STATUS_SECAM;
  333. break;
  334. case 0x04:
  335. case 0x0c:
  336. case 0x1c:
  337. res |= DECODER_STATUS_NTSC;
  338. break;
  339. }
  340. }
  341. *(int *) arg = res;
  342. }
  343. break;
  344. case DECODER_SET_NORM:
  345. {
  346. int *iarg = arg, data;
  347. dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n",
  348. I2C_NAME(client), *iarg);
  349. switch (*iarg) {
  350. case VIDEO_MODE_NTSC:
  351. vpx3220_write_fp_block(client, init_ntsc,
  352. sizeof(init_ntsc) >> 1);
  353. dprintk(1, KERN_INFO "%s: norm switched to NTSC\n",
  354. I2C_NAME(client));
  355. break;
  356. case VIDEO_MODE_PAL:
  357. vpx3220_write_fp_block(client, init_pal,
  358. sizeof(init_pal) >> 1);
  359. dprintk(1, KERN_INFO "%s: norm switched to PAL\n",
  360. I2C_NAME(client));
  361. break;
  362. case VIDEO_MODE_SECAM:
  363. vpx3220_write_fp_block(client, init_secam,
  364. sizeof(init_secam) >> 1);
  365. dprintk(1, KERN_INFO "%s: norm switched to SECAM\n",
  366. I2C_NAME(client));
  367. break;
  368. case VIDEO_MODE_AUTO:
  369. /* FIXME This is only preliminary support */
  370. data = vpx3220_fp_read(client, 0xf2) & 0x20;
  371. vpx3220_fp_write(client, 0xf2, 0x00c0 | data);
  372. dprintk(1, KERN_INFO "%s: norm switched to Auto\n",
  373. I2C_NAME(client));
  374. break;
  375. default:
  376. return -EINVAL;
  377. }
  378. decoder->norm = *iarg;
  379. }
  380. break;
  381. case DECODER_SET_INPUT:
  382. {
  383. int *iarg = arg, data;
  384. /* RJ: *iarg = 0: ST8 (PCTV) input
  385. *iarg = 1: COMPOSITE input
  386. *iarg = 2: SVHS input */
  387. const int input[3][2] = {
  388. {0x0c, 0},
  389. {0x0d, 0},
  390. {0x0e, 1}
  391. };
  392. if (*iarg < 0 || *iarg > 2)
  393. return -EINVAL;
  394. dprintk(1, KERN_INFO "%s: input switched to %s\n",
  395. I2C_NAME(client), inputs[*iarg]);
  396. vpx3220_write(client, 0x33, input[*iarg][0]);
  397. data = vpx3220_fp_read(client, 0xf2) & ~(0x0020);
  398. if (data < 0)
  399. return data;
  400. /* 0x0010 is required to latch the setting */
  401. vpx3220_fp_write(client, 0xf2,
  402. data | (input[*iarg][1] << 5) | 0x0010);
  403. udelay(10);
  404. }
  405. break;
  406. case DECODER_SET_OUTPUT:
  407. {
  408. int *iarg = arg;
  409. /* not much choice of outputs */
  410. if (*iarg != 0) {
  411. return -EINVAL;
  412. }
  413. }
  414. break;
  415. case DECODER_ENABLE_OUTPUT:
  416. {
  417. int *iarg = arg;
  418. dprintk(1, KERN_DEBUG "%s: DECODER_ENABLE_OUTPUT %d\n",
  419. I2C_NAME(client), *iarg);
  420. vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00));
  421. }
  422. break;
  423. case DECODER_SET_PICTURE:
  424. {
  425. struct video_picture *pic = arg;
  426. if (decoder->bright != pic->brightness) {
  427. /* We want -128 to 128 we get 0-65535 */
  428. decoder->bright = pic->brightness;
  429. vpx3220_write(client, 0xe6,
  430. (decoder->bright - 32768) >> 8);
  431. }
  432. if (decoder->contrast != pic->contrast) {
  433. /* We want 0 to 64 we get 0-65535 */
  434. /* Bit 7 and 8 is for noise shaping */
  435. decoder->contrast = pic->contrast;
  436. vpx3220_write(client, 0xe7,
  437. (decoder->contrast >> 10) + 192);
  438. }
  439. if (decoder->sat != pic->colour) {
  440. /* We want 0 to 4096 we get 0-65535 */
  441. decoder->sat = pic->colour;
  442. vpx3220_fp_write(client, 0xa0,
  443. decoder->sat >> 4);
  444. }
  445. if (decoder->hue != pic->hue) {
  446. /* We want -512 to 512 we get 0-65535 */
  447. decoder->hue = pic->hue;
  448. vpx3220_fp_write(client, 0x1c,
  449. ((decoder->hue - 32768) >> 6) & 0xFFF);
  450. }
  451. }
  452. break;
  453. default:
  454. return -EINVAL;
  455. }
  456. return 0;
  457. }
  458. static int
  459. vpx3220_init_client (struct i2c_client *client)
  460. {
  461. vpx3220_write_block(client, init_common, sizeof(init_common));
  462. vpx3220_write_fp_block(client, init_fp, sizeof(init_fp) >> 1);
  463. /* Default to PAL */
  464. vpx3220_write_fp_block(client, init_pal, sizeof(init_pal) >> 1);
  465. return 0;
  466. }
  467. /* -----------------------------------------------------------------------
  468. * Client managment code
  469. */
  470. /*
  471. * Generic i2c probe
  472. * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
  473. */
  474. static unsigned short normal_i2c[] =
  475. { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4,
  476. I2C_CLIENT_END
  477. };
  478. static unsigned short ignore = I2C_CLIENT_END;
  479. static struct i2c_client_address_data addr_data = {
  480. .normal_i2c = normal_i2c,
  481. .probe = &ignore,
  482. .ignore = &ignore,
  483. };
  484. static struct i2c_driver vpx3220_i2c_driver;
  485. static int
  486. vpx3220_detach_client (struct i2c_client *client)
  487. {
  488. struct vpx3220 *decoder = i2c_get_clientdata(client);
  489. int err;
  490. err = i2c_detach_client(client);
  491. if (err) {
  492. return err;
  493. }
  494. kfree(decoder);
  495. kfree(client);
  496. return 0;
  497. }
  498. static int
  499. vpx3220_detect_client (struct i2c_adapter *adapter,
  500. int address,
  501. int kind)
  502. {
  503. int err;
  504. struct i2c_client *client;
  505. struct vpx3220 *decoder;
  506. dprintk(1, VPX3220_DEBUG "%s\n", __func__);
  507. /* Check if the adapter supports the needed features */
  508. if (!i2c_check_functionality
  509. (adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
  510. return 0;
  511. client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
  512. if (client == NULL) {
  513. return -ENOMEM;
  514. }
  515. memset(client, 0, sizeof(struct i2c_client));
  516. client->addr = address;
  517. client->adapter = adapter;
  518. client->driver = &vpx3220_i2c_driver;
  519. client->flags = I2C_CLIENT_ALLOW_USE;
  520. /* Check for manufacture ID and part number */
  521. if (kind < 0) {
  522. u8 id;
  523. u16 pn;
  524. id = vpx3220_read(client, 0x00);
  525. if (id != 0xec) {
  526. dprintk(1,
  527. KERN_INFO
  528. "vpx3220_attach: Wrong manufacturer ID (0x%02x)\n",
  529. id);
  530. kfree(client);
  531. return 0;
  532. }
  533. pn = (vpx3220_read(client, 0x02) << 8) +
  534. vpx3220_read(client, 0x01);
  535. switch (pn) {
  536. case 0x4680:
  537. strlcpy(I2C_NAME(client), "vpx3220a",
  538. sizeof(I2C_NAME(client)));
  539. break;
  540. case 0x4260:
  541. strlcpy(I2C_NAME(client), "vpx3216b",
  542. sizeof(I2C_NAME(client)));
  543. break;
  544. case 0x4280:
  545. strlcpy(I2C_NAME(client), "vpx3214c",
  546. sizeof(I2C_NAME(client)));
  547. break;
  548. default:
  549. dprintk(1,
  550. KERN_INFO
  551. "%s: Wrong part number (0x%04x)\n",
  552. __func__, pn);
  553. kfree(client);
  554. return 0;
  555. }
  556. } else {
  557. strlcpy(I2C_NAME(client), "forced vpx32xx",
  558. sizeof(I2C_NAME(client)));
  559. }
  560. decoder = kmalloc(sizeof(struct vpx3220), GFP_KERNEL);
  561. if (decoder == NULL) {
  562. kfree(client);
  563. return -ENOMEM;
  564. }
  565. memset(decoder, 0, sizeof(struct vpx3220));
  566. decoder->norm = VIDEO_MODE_PAL;
  567. decoder->input = 0;
  568. decoder->enable = 1;
  569. decoder->bright = 32768;
  570. decoder->contrast = 32768;
  571. decoder->hue = 32768;
  572. decoder->sat = 32768;
  573. i2c_set_clientdata(client, decoder);
  574. err = i2c_attach_client(client);
  575. if (err) {
  576. kfree(client);
  577. kfree(decoder);
  578. return err;
  579. }
  580. dprintk(1, KERN_INFO "%s: vpx32xx client found at address 0x%02x\n",
  581. I2C_NAME(client), client->addr << 1);
  582. vpx3220_init_client(client);
  583. return 0;
  584. }
  585. static int
  586. vpx3220_attach_adapter (struct i2c_adapter *adapter)
  587. {
  588. int ret;
  589. ret = i2c_probe(adapter, &addr_data, &vpx3220_detect_client);
  590. dprintk(1, VPX3220_DEBUG "%s: i2c_probe returned %d\n",
  591. __func__, ret);
  592. return ret;
  593. }
  594. /* -----------------------------------------------------------------------
  595. * Driver initialization and cleanup code
  596. */
  597. static struct i2c_driver vpx3220_i2c_driver = {
  598. .owner = THIS_MODULE,
  599. .name = "vpx3220",
  600. .id = I2C_DRIVERID_VPX3220,
  601. .flags = I2C_DF_NOTIFY,
  602. .attach_adapter = vpx3220_attach_adapter,
  603. .detach_client = vpx3220_detach_client,
  604. .command = vpx3220_command,
  605. };
  606. static int __init
  607. vpx3220_init (void)
  608. {
  609. return i2c_add_driver(&vpx3220_i2c_driver);
  610. }
  611. static void __exit
  612. vpx3220_cleanup (void)
  613. {
  614. i2c_del_driver(&vpx3220_i2c_driver);
  615. }
  616. module_init(vpx3220_init);
  617. module_exit(vpx3220_cleanup);
  618. MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video encoder driver");
  619. MODULE_AUTHOR("Laurent Pinchart");
  620. MODULE_LICENSE("GPL");