tvp5150.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  1. /*
  2. * tvp5150 - Texas Instruments TVP5150A/AM1 video decoder driver
  3. *
  4. * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org)
  5. * This code is placed under the terms of the GNU General Public License v2
  6. */
  7. #include <linux/i2c.h>
  8. #include <linux/slab.h>
  9. #include <linux/videodev2.h>
  10. #include <linux/delay.h>
  11. #include <linux/module.h>
  12. #include <media/v4l2-device.h>
  13. #include <media/tvp5150.h>
  14. #include <media/v4l2-chip-ident.h>
  15. #include <media/v4l2-ctrls.h>
  16. #include "tvp5150_reg.h"
  17. MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver");
  18. MODULE_AUTHOR("Mauro Carvalho Chehab");
  19. MODULE_LICENSE("GPL");
  20. static int debug;
  21. module_param(debug, int, 0);
  22. MODULE_PARM_DESC(debug, "Debug level (0-2)");
  23. struct tvp5150 {
  24. struct v4l2_subdev sd;
  25. struct v4l2_ctrl_handler hdl;
  26. v4l2_std_id norm; /* Current set standard */
  27. u32 input;
  28. u32 output;
  29. int enable;
  30. };
  31. static inline struct tvp5150 *to_tvp5150(struct v4l2_subdev *sd)
  32. {
  33. return container_of(sd, struct tvp5150, sd);
  34. }
  35. static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
  36. {
  37. return &container_of(ctrl->handler, struct tvp5150, hdl)->sd;
  38. }
  39. static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr)
  40. {
  41. struct i2c_client *c = v4l2_get_subdevdata(sd);
  42. unsigned char buffer[1];
  43. int rc;
  44. buffer[0] = addr;
  45. if (1 != (rc = i2c_master_send(c, buffer, 1)))
  46. v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 1)\n", rc);
  47. msleep(10);
  48. if (1 != (rc = i2c_master_recv(c, buffer, 1)))
  49. v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 1)\n", rc);
  50. v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]);
  51. return (buffer[0]);
  52. }
  53. static inline void tvp5150_write(struct v4l2_subdev *sd, unsigned char addr,
  54. unsigned char value)
  55. {
  56. struct i2c_client *c = v4l2_get_subdevdata(sd);
  57. unsigned char buffer[2];
  58. int rc;
  59. buffer[0] = addr;
  60. buffer[1] = value;
  61. v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", buffer[0], buffer[1]);
  62. if (2 != (rc = i2c_master_send(c, buffer, 2)))
  63. v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 2)\n", rc);
  64. }
  65. static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init,
  66. const u8 end, int max_line)
  67. {
  68. int i = 0;
  69. while (init != (u8)(end + 1)) {
  70. if ((i % max_line) == 0) {
  71. if (i > 0)
  72. printk("\n");
  73. printk("tvp5150: %s reg 0x%02x = ", s, init);
  74. }
  75. printk("%02x ", tvp5150_read(sd, init));
  76. init++;
  77. i++;
  78. }
  79. printk("\n");
  80. }
  81. static int tvp5150_log_status(struct v4l2_subdev *sd)
  82. {
  83. printk("tvp5150: Video input source selection #1 = 0x%02x\n",
  84. tvp5150_read(sd, TVP5150_VD_IN_SRC_SEL_1));
  85. printk("tvp5150: Analog channel controls = 0x%02x\n",
  86. tvp5150_read(sd, TVP5150_ANAL_CHL_CTL));
  87. printk("tvp5150: Operation mode controls = 0x%02x\n",
  88. tvp5150_read(sd, TVP5150_OP_MODE_CTL));
  89. printk("tvp5150: Miscellaneous controls = 0x%02x\n",
  90. tvp5150_read(sd, TVP5150_MISC_CTL));
  91. printk("tvp5150: Autoswitch mask= 0x%02x\n",
  92. tvp5150_read(sd, TVP5150_AUTOSW_MSK));
  93. printk("tvp5150: Color killer threshold control = 0x%02x\n",
  94. tvp5150_read(sd, TVP5150_COLOR_KIL_THSH_CTL));
  95. printk("tvp5150: Luminance processing controls #1 #2 and #3 = %02x %02x %02x\n",
  96. tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_1),
  97. tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_2),
  98. tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_3));
  99. printk("tvp5150: Brightness control = 0x%02x\n",
  100. tvp5150_read(sd, TVP5150_BRIGHT_CTL));
  101. printk("tvp5150: Color saturation control = 0x%02x\n",
  102. tvp5150_read(sd, TVP5150_SATURATION_CTL));
  103. printk("tvp5150: Hue control = 0x%02x\n",
  104. tvp5150_read(sd, TVP5150_HUE_CTL));
  105. printk("tvp5150: Contrast control = 0x%02x\n",
  106. tvp5150_read(sd, TVP5150_CONTRAST_CTL));
  107. printk("tvp5150: Outputs and data rates select = 0x%02x\n",
  108. tvp5150_read(sd, TVP5150_DATA_RATE_SEL));
  109. printk("tvp5150: Configuration shared pins = 0x%02x\n",
  110. tvp5150_read(sd, TVP5150_CONF_SHARED_PIN));
  111. printk("tvp5150: Active video cropping start = 0x%02x%02x\n",
  112. tvp5150_read(sd, TVP5150_ACT_VD_CROP_ST_MSB),
  113. tvp5150_read(sd, TVP5150_ACT_VD_CROP_ST_LSB));
  114. printk("tvp5150: Active video cropping stop = 0x%02x%02x\n",
  115. tvp5150_read(sd, TVP5150_ACT_VD_CROP_STP_MSB),
  116. tvp5150_read(sd, TVP5150_ACT_VD_CROP_STP_LSB));
  117. printk("tvp5150: Genlock/RTC = 0x%02x\n",
  118. tvp5150_read(sd, TVP5150_GENLOCK));
  119. printk("tvp5150: Horizontal sync start = 0x%02x\n",
  120. tvp5150_read(sd, TVP5150_HORIZ_SYNC_START));
  121. printk("tvp5150: Vertical blanking start = 0x%02x\n",
  122. tvp5150_read(sd, TVP5150_VERT_BLANKING_START));
  123. printk("tvp5150: Vertical blanking stop = 0x%02x\n",
  124. tvp5150_read(sd, TVP5150_VERT_BLANKING_STOP));
  125. printk("tvp5150: Chrominance processing control #1 and #2 = %02x %02x\n",
  126. tvp5150_read(sd, TVP5150_CHROMA_PROC_CTL_1),
  127. tvp5150_read(sd, TVP5150_CHROMA_PROC_CTL_2));
  128. printk("tvp5150: Interrupt reset register B = 0x%02x\n",
  129. tvp5150_read(sd, TVP5150_INT_RESET_REG_B));
  130. printk("tvp5150: Interrupt enable register B = 0x%02x\n",
  131. tvp5150_read(sd, TVP5150_INT_ENABLE_REG_B));
  132. printk("tvp5150: Interrupt configuration register B = 0x%02x\n",
  133. tvp5150_read(sd, TVP5150_INTT_CONFIG_REG_B));
  134. printk("tvp5150: Video standard = 0x%02x\n",
  135. tvp5150_read(sd, TVP5150_VIDEO_STD));
  136. printk("tvp5150: Chroma gain factor: Cb=0x%02x Cr=0x%02x\n",
  137. tvp5150_read(sd, TVP5150_CB_GAIN_FACT),
  138. tvp5150_read(sd, TVP5150_CR_GAIN_FACTOR));
  139. printk("tvp5150: Macrovision on counter = 0x%02x\n",
  140. tvp5150_read(sd, TVP5150_MACROVISION_ON_CTR));
  141. printk("tvp5150: Macrovision off counter = 0x%02x\n",
  142. tvp5150_read(sd, TVP5150_MACROVISION_OFF_CTR));
  143. printk("tvp5150: ITU-R BT.656.%d timing(TVP5150AM1 only)\n",
  144. (tvp5150_read(sd, TVP5150_REV_SELECT) & 1) ? 3 : 4);
  145. printk("tvp5150: Device ID = %02x%02x\n",
  146. tvp5150_read(sd, TVP5150_MSB_DEV_ID),
  147. tvp5150_read(sd, TVP5150_LSB_DEV_ID));
  148. printk("tvp5150: ROM version = (hex) %02x.%02x\n",
  149. tvp5150_read(sd, TVP5150_ROM_MAJOR_VER),
  150. tvp5150_read(sd, TVP5150_ROM_MINOR_VER));
  151. printk("tvp5150: Vertical line count = 0x%02x%02x\n",
  152. tvp5150_read(sd, TVP5150_VERT_LN_COUNT_MSB),
  153. tvp5150_read(sd, TVP5150_VERT_LN_COUNT_LSB));
  154. printk("tvp5150: Interrupt status register B = 0x%02x\n",
  155. tvp5150_read(sd, TVP5150_INT_STATUS_REG_B));
  156. printk("tvp5150: Interrupt active register B = 0x%02x\n",
  157. tvp5150_read(sd, TVP5150_INT_ACTIVE_REG_B));
  158. printk("tvp5150: Status regs #1 to #5 = %02x %02x %02x %02x %02x\n",
  159. tvp5150_read(sd, TVP5150_STATUS_REG_1),
  160. tvp5150_read(sd, TVP5150_STATUS_REG_2),
  161. tvp5150_read(sd, TVP5150_STATUS_REG_3),
  162. tvp5150_read(sd, TVP5150_STATUS_REG_4),
  163. tvp5150_read(sd, TVP5150_STATUS_REG_5));
  164. dump_reg_range(sd, "Teletext filter 1", TVP5150_TELETEXT_FIL1_INI,
  165. TVP5150_TELETEXT_FIL1_END, 8);
  166. dump_reg_range(sd, "Teletext filter 2", TVP5150_TELETEXT_FIL2_INI,
  167. TVP5150_TELETEXT_FIL2_END, 8);
  168. printk("tvp5150: Teletext filter enable = 0x%02x\n",
  169. tvp5150_read(sd, TVP5150_TELETEXT_FIL_ENA));
  170. printk("tvp5150: Interrupt status register A = 0x%02x\n",
  171. tvp5150_read(sd, TVP5150_INT_STATUS_REG_A));
  172. printk("tvp5150: Interrupt enable register A = 0x%02x\n",
  173. tvp5150_read(sd, TVP5150_INT_ENABLE_REG_A));
  174. printk("tvp5150: Interrupt configuration = 0x%02x\n",
  175. tvp5150_read(sd, TVP5150_INT_CONF));
  176. printk("tvp5150: VDP status register = 0x%02x\n",
  177. tvp5150_read(sd, TVP5150_VDP_STATUS_REG));
  178. printk("tvp5150: FIFO word count = 0x%02x\n",
  179. tvp5150_read(sd, TVP5150_FIFO_WORD_COUNT));
  180. printk("tvp5150: FIFO interrupt threshold = 0x%02x\n",
  181. tvp5150_read(sd, TVP5150_FIFO_INT_THRESHOLD));
  182. printk("tvp5150: FIFO reset = 0x%02x\n",
  183. tvp5150_read(sd, TVP5150_FIFO_RESET));
  184. printk("tvp5150: Line number interrupt = 0x%02x\n",
  185. tvp5150_read(sd, TVP5150_LINE_NUMBER_INT));
  186. printk("tvp5150: Pixel alignment register = 0x%02x%02x\n",
  187. tvp5150_read(sd, TVP5150_PIX_ALIGN_REG_HIGH),
  188. tvp5150_read(sd, TVP5150_PIX_ALIGN_REG_LOW));
  189. printk("tvp5150: FIFO output control = 0x%02x\n",
  190. tvp5150_read(sd, TVP5150_FIFO_OUT_CTRL));
  191. printk("tvp5150: Full field enable = 0x%02x\n",
  192. tvp5150_read(sd, TVP5150_FULL_FIELD_ENA));
  193. printk("tvp5150: Full field mode register = 0x%02x\n",
  194. tvp5150_read(sd, TVP5150_FULL_FIELD_MODE_REG));
  195. dump_reg_range(sd, "CC data", TVP5150_CC_DATA_INI,
  196. TVP5150_CC_DATA_END, 8);
  197. dump_reg_range(sd, "WSS data", TVP5150_WSS_DATA_INI,
  198. TVP5150_WSS_DATA_END, 8);
  199. dump_reg_range(sd, "VPS data", TVP5150_VPS_DATA_INI,
  200. TVP5150_VPS_DATA_END, 8);
  201. dump_reg_range(sd, "VITC data", TVP5150_VITC_DATA_INI,
  202. TVP5150_VITC_DATA_END, 10);
  203. dump_reg_range(sd, "Line mode", TVP5150_LINE_MODE_INI,
  204. TVP5150_LINE_MODE_END, 8);
  205. return 0;
  206. }
  207. /****************************************************************************
  208. Basic functions
  209. ****************************************************************************/
  210. static inline void tvp5150_selmux(struct v4l2_subdev *sd)
  211. {
  212. int opmode = 0;
  213. struct tvp5150 *decoder = to_tvp5150(sd);
  214. int input = 0;
  215. unsigned char val;
  216. if ((decoder->output & TVP5150_BLACK_SCREEN) || !decoder->enable)
  217. input = 8;
  218. switch (decoder->input) {
  219. case TVP5150_COMPOSITE1:
  220. input |= 2;
  221. /* fall through */
  222. case TVP5150_COMPOSITE0:
  223. break;
  224. case TVP5150_SVIDEO:
  225. default:
  226. input |= 1;
  227. break;
  228. }
  229. v4l2_dbg(1, debug, sd, "Selecting video route: route input=%i, output=%i "
  230. "=> tvp5150 input=%i, opmode=%i\n",
  231. decoder->input, decoder->output,
  232. input, opmode);
  233. tvp5150_write(sd, TVP5150_OP_MODE_CTL, opmode);
  234. tvp5150_write(sd, TVP5150_VD_IN_SRC_SEL_1, input);
  235. /* Svideo should enable YCrCb output and disable GPCL output
  236. * For Composite and TV, it should be the reverse
  237. */
  238. val = tvp5150_read(sd, TVP5150_MISC_CTL);
  239. if (decoder->input == TVP5150_SVIDEO)
  240. val = (val & ~0x40) | 0x10;
  241. else
  242. val = (val & ~0x10) | 0x40;
  243. tvp5150_write(sd, TVP5150_MISC_CTL, val);
  244. };
  245. struct i2c_reg_value {
  246. unsigned char reg;
  247. unsigned char value;
  248. };
  249. /* Default values as sugested at TVP5150AM1 datasheet */
  250. static const struct i2c_reg_value tvp5150_init_default[] = {
  251. { /* 0x00 */
  252. TVP5150_VD_IN_SRC_SEL_1,0x00
  253. },
  254. { /* 0x01 */
  255. TVP5150_ANAL_CHL_CTL,0x15
  256. },
  257. { /* 0x02 */
  258. TVP5150_OP_MODE_CTL,0x00
  259. },
  260. { /* 0x03 */
  261. TVP5150_MISC_CTL,0x01
  262. },
  263. { /* 0x06 */
  264. TVP5150_COLOR_KIL_THSH_CTL,0x10
  265. },
  266. { /* 0x07 */
  267. TVP5150_LUMA_PROC_CTL_1,0x60
  268. },
  269. { /* 0x08 */
  270. TVP5150_LUMA_PROC_CTL_2,0x00
  271. },
  272. { /* 0x09 */
  273. TVP5150_BRIGHT_CTL,0x80
  274. },
  275. { /* 0x0a */
  276. TVP5150_SATURATION_CTL,0x80
  277. },
  278. { /* 0x0b */
  279. TVP5150_HUE_CTL,0x00
  280. },
  281. { /* 0x0c */
  282. TVP5150_CONTRAST_CTL,0x80
  283. },
  284. { /* 0x0d */
  285. TVP5150_DATA_RATE_SEL,0x47
  286. },
  287. { /* 0x0e */
  288. TVP5150_LUMA_PROC_CTL_3,0x00
  289. },
  290. { /* 0x0f */
  291. TVP5150_CONF_SHARED_PIN,0x08
  292. },
  293. { /* 0x11 */
  294. TVP5150_ACT_VD_CROP_ST_MSB,0x00
  295. },
  296. { /* 0x12 */
  297. TVP5150_ACT_VD_CROP_ST_LSB,0x00
  298. },
  299. { /* 0x13 */
  300. TVP5150_ACT_VD_CROP_STP_MSB,0x00
  301. },
  302. { /* 0x14 */
  303. TVP5150_ACT_VD_CROP_STP_LSB,0x00
  304. },
  305. { /* 0x15 */
  306. TVP5150_GENLOCK,0x01
  307. },
  308. { /* 0x16 */
  309. TVP5150_HORIZ_SYNC_START,0x80
  310. },
  311. { /* 0x18 */
  312. TVP5150_VERT_BLANKING_START,0x00
  313. },
  314. { /* 0x19 */
  315. TVP5150_VERT_BLANKING_STOP,0x00
  316. },
  317. { /* 0x1a */
  318. TVP5150_CHROMA_PROC_CTL_1,0x0c
  319. },
  320. { /* 0x1b */
  321. TVP5150_CHROMA_PROC_CTL_2,0x14
  322. },
  323. { /* 0x1c */
  324. TVP5150_INT_RESET_REG_B,0x00
  325. },
  326. { /* 0x1d */
  327. TVP5150_INT_ENABLE_REG_B,0x00
  328. },
  329. { /* 0x1e */
  330. TVP5150_INTT_CONFIG_REG_B,0x00
  331. },
  332. { /* 0x28 */
  333. TVP5150_VIDEO_STD,0x00
  334. },
  335. { /* 0x2e */
  336. TVP5150_MACROVISION_ON_CTR,0x0f
  337. },
  338. { /* 0x2f */
  339. TVP5150_MACROVISION_OFF_CTR,0x01
  340. },
  341. { /* 0xbb */
  342. TVP5150_TELETEXT_FIL_ENA,0x00
  343. },
  344. { /* 0xc0 */
  345. TVP5150_INT_STATUS_REG_A,0x00
  346. },
  347. { /* 0xc1 */
  348. TVP5150_INT_ENABLE_REG_A,0x00
  349. },
  350. { /* 0xc2 */
  351. TVP5150_INT_CONF,0x04
  352. },
  353. { /* 0xc8 */
  354. TVP5150_FIFO_INT_THRESHOLD,0x80
  355. },
  356. { /* 0xc9 */
  357. TVP5150_FIFO_RESET,0x00
  358. },
  359. { /* 0xca */
  360. TVP5150_LINE_NUMBER_INT,0x00
  361. },
  362. { /* 0xcb */
  363. TVP5150_PIX_ALIGN_REG_LOW,0x4e
  364. },
  365. { /* 0xcc */
  366. TVP5150_PIX_ALIGN_REG_HIGH,0x00
  367. },
  368. { /* 0xcd */
  369. TVP5150_FIFO_OUT_CTRL,0x01
  370. },
  371. { /* 0xcf */
  372. TVP5150_FULL_FIELD_ENA,0x00
  373. },
  374. { /* 0xd0 */
  375. TVP5150_LINE_MODE_INI,0x00
  376. },
  377. { /* 0xfc */
  378. TVP5150_FULL_FIELD_MODE_REG,0x7f
  379. },
  380. { /* end of data */
  381. 0xff,0xff
  382. }
  383. };
  384. /* Default values as sugested at TVP5150AM1 datasheet */
  385. static const struct i2c_reg_value tvp5150_init_enable[] = {
  386. {
  387. TVP5150_CONF_SHARED_PIN, 2
  388. },{ /* Automatic offset and AGC enabled */
  389. TVP5150_ANAL_CHL_CTL, 0x15
  390. },{ /* Activate YCrCb output 0x9 or 0xd ? */
  391. TVP5150_MISC_CTL, 0x6f
  392. },{ /* Activates video std autodetection for all standards */
  393. TVP5150_AUTOSW_MSK, 0x0
  394. },{ /* Default format: 0x47. For 4:2:2: 0x40 */
  395. TVP5150_DATA_RATE_SEL, 0x47
  396. },{
  397. TVP5150_CHROMA_PROC_CTL_1, 0x0c
  398. },{
  399. TVP5150_CHROMA_PROC_CTL_2, 0x54
  400. },{ /* Non documented, but initialized on WinTV USB2 */
  401. 0x27, 0x20
  402. },{
  403. 0xff,0xff
  404. }
  405. };
  406. struct tvp5150_vbi_type {
  407. unsigned int vbi_type;
  408. unsigned int ini_line;
  409. unsigned int end_line;
  410. unsigned int by_field :1;
  411. };
  412. struct i2c_vbi_ram_value {
  413. u16 reg;
  414. struct tvp5150_vbi_type type;
  415. unsigned char values[16];
  416. };
  417. /* This struct have the values for each supported VBI Standard
  418. * by
  419. tvp5150_vbi_types should follow the same order as vbi_ram_default
  420. * value 0 means rom position 0x10, value 1 means rom position 0x30
  421. * and so on. There are 16 possible locations from 0 to 15.
  422. */
  423. static struct i2c_vbi_ram_value vbi_ram_default[] =
  424. {
  425. /* FIXME: Current api doesn't handle all VBI types, those not
  426. yet supported are placed under #if 0 */
  427. #if 0
  428. {0x010, /* Teletext, SECAM, WST System A */
  429. {V4L2_SLICED_TELETEXT_SECAM,6,23,1},
  430. { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x26,
  431. 0xe6, 0xb4, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00 }
  432. },
  433. #endif
  434. {0x030, /* Teletext, PAL, WST System B */
  435. {V4L2_SLICED_TELETEXT_B,6,22,1},
  436. { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x2b,
  437. 0xa6, 0x72, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00 }
  438. },
  439. #if 0
  440. {0x050, /* Teletext, PAL, WST System C */
  441. {V4L2_SLICED_TELETEXT_PAL_C,6,22,1},
  442. { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
  443. 0xa6, 0x98, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
  444. },
  445. {0x070, /* Teletext, NTSC, WST System B */
  446. {V4L2_SLICED_TELETEXT_NTSC_B,10,21,1},
  447. { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x23,
  448. 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
  449. },
  450. {0x090, /* Tetetext, NTSC NABTS System C */
  451. {V4L2_SLICED_TELETEXT_NTSC_C,10,21,1},
  452. { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
  453. 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x15, 0x00 }
  454. },
  455. {0x0b0, /* Teletext, NTSC-J, NABTS System D */
  456. {V4L2_SLICED_TELETEXT_NTSC_D,10,21,1},
  457. { 0xaa, 0xaa, 0xff, 0xff, 0xa7, 0x2e, 0x20, 0x23,
  458. 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
  459. },
  460. {0x0d0, /* Closed Caption, PAL/SECAM */
  461. {V4L2_SLICED_CAPTION_625,22,22,1},
  462. { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
  463. 0xa6, 0x7b, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
  464. },
  465. #endif
  466. {0x0f0, /* Closed Caption, NTSC */
  467. {V4L2_SLICED_CAPTION_525,21,21,1},
  468. { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
  469. 0x69, 0x8c, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
  470. },
  471. {0x110, /* Wide Screen Signal, PAL/SECAM */
  472. {V4L2_SLICED_WSS_625,23,23,1},
  473. { 0x5b, 0x55, 0xc5, 0xff, 0x00, 0x71, 0x6e, 0x42,
  474. 0xa6, 0xcd, 0x0f, 0x00, 0x00, 0x00, 0x3a, 0x00 }
  475. },
  476. #if 0
  477. {0x130, /* Wide Screen Signal, NTSC C */
  478. {V4L2_SLICED_WSS_525,20,20,1},
  479. { 0x38, 0x00, 0x3f, 0x00, 0x00, 0x71, 0x6e, 0x43,
  480. 0x69, 0x7c, 0x08, 0x00, 0x00, 0x00, 0x39, 0x00 }
  481. },
  482. {0x150, /* Vertical Interval Timecode (VITC), PAL/SECAM */
  483. {V4l2_SLICED_VITC_625,6,22,0},
  484. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
  485. 0xa6, 0x85, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
  486. },
  487. {0x170, /* Vertical Interval Timecode (VITC), NTSC */
  488. {V4l2_SLICED_VITC_525,10,20,0},
  489. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
  490. 0x69, 0x94, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
  491. },
  492. #endif
  493. {0x190, /* Video Program System (VPS), PAL */
  494. {V4L2_SLICED_VPS,16,16,0},
  495. { 0xaa, 0xaa, 0xff, 0xff, 0xba, 0xce, 0x2b, 0x0d,
  496. 0xa6, 0xda, 0x0b, 0x00, 0x00, 0x00, 0x60, 0x00 }
  497. },
  498. /* 0x1d0 User programmable */
  499. /* End of struct */
  500. { (u16)-1 }
  501. };
  502. static int tvp5150_write_inittab(struct v4l2_subdev *sd,
  503. const struct i2c_reg_value *regs)
  504. {
  505. while (regs->reg != 0xff) {
  506. tvp5150_write(sd, regs->reg, regs->value);
  507. regs++;
  508. }
  509. return 0;
  510. }
  511. static int tvp5150_vdp_init(struct v4l2_subdev *sd,
  512. const struct i2c_vbi_ram_value *regs)
  513. {
  514. unsigned int i;
  515. /* Disable Full Field */
  516. tvp5150_write(sd, TVP5150_FULL_FIELD_ENA, 0);
  517. /* Before programming, Line mode should be at 0xff */
  518. for (i = TVP5150_LINE_MODE_INI; i <= TVP5150_LINE_MODE_END; i++)
  519. tvp5150_write(sd, i, 0xff);
  520. /* Load Ram Table */
  521. while (regs->reg != (u16)-1) {
  522. tvp5150_write(sd, TVP5150_CONF_RAM_ADDR_HIGH, regs->reg >> 8);
  523. tvp5150_write(sd, TVP5150_CONF_RAM_ADDR_LOW, regs->reg);
  524. for (i = 0; i < 16; i++)
  525. tvp5150_write(sd, TVP5150_VDP_CONF_RAM_DATA, regs->values[i]);
  526. regs++;
  527. }
  528. return 0;
  529. }
  530. /* Fills VBI capabilities based on i2c_vbi_ram_value struct */
  531. static int tvp5150_g_sliced_vbi_cap(struct v4l2_subdev *sd,
  532. struct v4l2_sliced_vbi_cap *cap)
  533. {
  534. const struct i2c_vbi_ram_value *regs = vbi_ram_default;
  535. int line;
  536. v4l2_dbg(1, debug, sd, "g_sliced_vbi_cap\n");
  537. memset(cap, 0, sizeof *cap);
  538. while (regs->reg != (u16)-1 ) {
  539. for (line=regs->type.ini_line;line<=regs->type.end_line;line++) {
  540. cap->service_lines[0][line] |= regs->type.vbi_type;
  541. }
  542. cap->service_set |= regs->type.vbi_type;
  543. regs++;
  544. }
  545. return 0;
  546. }
  547. /* Set vbi processing
  548. * type - one of tvp5150_vbi_types
  549. * line - line to gather data
  550. * fields: bit 0 field1, bit 1, field2
  551. * flags (default=0xf0) is a bitmask, were set means:
  552. * bit 7: enable filtering null bytes on CC
  553. * bit 6: send data also to FIFO
  554. * bit 5: don't allow data with errors on FIFO
  555. * bit 4: enable ECC when possible
  556. * pix_align = pix alignment:
  557. * LSB = field1
  558. * MSB = field2
  559. */
  560. static int tvp5150_set_vbi(struct v4l2_subdev *sd,
  561. const struct i2c_vbi_ram_value *regs,
  562. unsigned int type,u8 flags, int line,
  563. const int fields)
  564. {
  565. struct tvp5150 *decoder = to_tvp5150(sd);
  566. v4l2_std_id std = decoder->norm;
  567. u8 reg;
  568. int pos=0;
  569. if (std == V4L2_STD_ALL) {
  570. v4l2_err(sd, "VBI can't be configured without knowing number of lines\n");
  571. return 0;
  572. } else if (std & V4L2_STD_625_50) {
  573. /* Don't follow NTSC Line number convension */
  574. line += 3;
  575. }
  576. if (line<6||line>27)
  577. return 0;
  578. while (regs->reg != (u16)-1 ) {
  579. if ((type & regs->type.vbi_type) &&
  580. (line>=regs->type.ini_line) &&
  581. (line<=regs->type.end_line)) {
  582. type=regs->type.vbi_type;
  583. break;
  584. }
  585. regs++;
  586. pos++;
  587. }
  588. if (regs->reg == (u16)-1)
  589. return 0;
  590. type=pos | (flags & 0xf0);
  591. reg=((line-6)<<1)+TVP5150_LINE_MODE_INI;
  592. if (fields&1) {
  593. tvp5150_write(sd, reg, type);
  594. }
  595. if (fields&2) {
  596. tvp5150_write(sd, reg+1, type);
  597. }
  598. return type;
  599. }
  600. static int tvp5150_get_vbi(struct v4l2_subdev *sd,
  601. const struct i2c_vbi_ram_value *regs, int line)
  602. {
  603. struct tvp5150 *decoder = to_tvp5150(sd);
  604. v4l2_std_id std = decoder->norm;
  605. u8 reg;
  606. int pos, type = 0;
  607. if (std == V4L2_STD_ALL) {
  608. v4l2_err(sd, "VBI can't be configured without knowing number of lines\n");
  609. return 0;
  610. } else if (std & V4L2_STD_625_50) {
  611. /* Don't follow NTSC Line number convension */
  612. line += 3;
  613. }
  614. if (line < 6 || line > 27)
  615. return 0;
  616. reg = ((line - 6) << 1) + TVP5150_LINE_MODE_INI;
  617. pos = tvp5150_read(sd, reg) & 0x0f;
  618. if (pos < 0x0f)
  619. type = regs[pos].type.vbi_type;
  620. pos = tvp5150_read(sd, reg + 1) & 0x0f;
  621. if (pos < 0x0f)
  622. type |= regs[pos].type.vbi_type;
  623. return type;
  624. }
  625. static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std)
  626. {
  627. struct tvp5150 *decoder = to_tvp5150(sd);
  628. int fmt = 0;
  629. decoder->norm = std;
  630. /* First tests should be against specific std */
  631. if (std == V4L2_STD_ALL) {
  632. fmt = 0; /* Autodetect mode */
  633. } else if (std & V4L2_STD_NTSC_443) {
  634. fmt = 0xa;
  635. } else if (std & V4L2_STD_PAL_M) {
  636. fmt = 0x6;
  637. } else if (std & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)) {
  638. fmt = 0x8;
  639. } else {
  640. /* Then, test against generic ones */
  641. if (std & V4L2_STD_NTSC)
  642. fmt = 0x2;
  643. else if (std & V4L2_STD_PAL)
  644. fmt = 0x4;
  645. else if (std & V4L2_STD_SECAM)
  646. fmt = 0xc;
  647. }
  648. v4l2_dbg(1, debug, sd, "Set video std register to %d.\n", fmt);
  649. tvp5150_write(sd, TVP5150_VIDEO_STD, fmt);
  650. return 0;
  651. }
  652. static int tvp5150_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
  653. {
  654. struct tvp5150 *decoder = to_tvp5150(sd);
  655. if (decoder->norm == std)
  656. return 0;
  657. return tvp5150_set_std(sd, std);
  658. }
  659. static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
  660. {
  661. struct tvp5150 *decoder = to_tvp5150(sd);
  662. /* Initializes TVP5150 to its default values */
  663. tvp5150_write_inittab(sd, tvp5150_init_default);
  664. /* Initializes VDP registers */
  665. tvp5150_vdp_init(sd, vbi_ram_default);
  666. /* Selects decoder input */
  667. tvp5150_selmux(sd);
  668. /* Initializes TVP5150 to stream enabled values */
  669. tvp5150_write_inittab(sd, tvp5150_init_enable);
  670. /* Initialize image preferences */
  671. v4l2_ctrl_handler_setup(&decoder->hdl);
  672. tvp5150_set_std(sd, decoder->norm);
  673. return 0;
  674. };
  675. static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
  676. {
  677. struct v4l2_subdev *sd = to_sd(ctrl);
  678. switch (ctrl->id) {
  679. case V4L2_CID_BRIGHTNESS:
  680. tvp5150_write(sd, TVP5150_BRIGHT_CTL, ctrl->val);
  681. return 0;
  682. case V4L2_CID_CONTRAST:
  683. tvp5150_write(sd, TVP5150_CONTRAST_CTL, ctrl->val);
  684. return 0;
  685. case V4L2_CID_SATURATION:
  686. tvp5150_write(sd, TVP5150_SATURATION_CTL, ctrl->val);
  687. return 0;
  688. case V4L2_CID_HUE:
  689. tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val);
  690. return 0;
  691. }
  692. return -EINVAL;
  693. }
  694. /****************************************************************************
  695. I2C Command
  696. ****************************************************************************/
  697. static int tvp5150_s_routing(struct v4l2_subdev *sd,
  698. u32 input, u32 output, u32 config)
  699. {
  700. struct tvp5150 *decoder = to_tvp5150(sd);
  701. decoder->input = input;
  702. decoder->output = output;
  703. tvp5150_selmux(sd);
  704. return 0;
  705. }
  706. static int tvp5150_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt)
  707. {
  708. /* this is for capturing 36 raw vbi lines
  709. if there's a way to cut off the beginning 2 vbi lines
  710. with the tvp5150 then the vbi line count could be lowered
  711. to 17 lines/field again, although I couldn't find a register
  712. which could do that cropping */
  713. if (fmt->sample_format == V4L2_PIX_FMT_GREY)
  714. tvp5150_write(sd, TVP5150_LUMA_PROC_CTL_1, 0x70);
  715. if (fmt->count[0] == 18 && fmt->count[1] == 18) {
  716. tvp5150_write(sd, TVP5150_VERT_BLANKING_START, 0x00);
  717. tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP, 0x01);
  718. }
  719. return 0;
  720. }
  721. static int tvp5150_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *svbi)
  722. {
  723. int i;
  724. if (svbi->service_set != 0) {
  725. for (i = 0; i <= 23; i++) {
  726. svbi->service_lines[1][i] = 0;
  727. svbi->service_lines[0][i] =
  728. tvp5150_set_vbi(sd, vbi_ram_default,
  729. svbi->service_lines[0][i], 0xf0, i, 3);
  730. }
  731. /* Enables FIFO */
  732. tvp5150_write(sd, TVP5150_FIFO_OUT_CTRL, 1);
  733. } else {
  734. /* Disables FIFO*/
  735. tvp5150_write(sd, TVP5150_FIFO_OUT_CTRL, 0);
  736. /* Disable Full Field */
  737. tvp5150_write(sd, TVP5150_FULL_FIELD_ENA, 0);
  738. /* Disable Line modes */
  739. for (i = TVP5150_LINE_MODE_INI; i <= TVP5150_LINE_MODE_END; i++)
  740. tvp5150_write(sd, i, 0xff);
  741. }
  742. return 0;
  743. }
  744. static int tvp5150_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *svbi)
  745. {
  746. int i, mask = 0;
  747. memset(svbi, 0, sizeof(*svbi));
  748. for (i = 0; i <= 23; i++) {
  749. svbi->service_lines[0][i] =
  750. tvp5150_get_vbi(sd, vbi_ram_default, i);
  751. mask |= svbi->service_lines[0][i];
  752. }
  753. svbi->service_set = mask;
  754. return 0;
  755. }
  756. static int tvp5150_g_chip_ident(struct v4l2_subdev *sd,
  757. struct v4l2_dbg_chip_ident *chip)
  758. {
  759. int rev;
  760. struct i2c_client *client = v4l2_get_subdevdata(sd);
  761. rev = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER) << 8 |
  762. tvp5150_read(sd, TVP5150_ROM_MINOR_VER);
  763. return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TVP5150,
  764. rev);
  765. }
  766. #ifdef CONFIG_VIDEO_ADV_DEBUG
  767. static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
  768. {
  769. struct i2c_client *client = v4l2_get_subdevdata(sd);
  770. if (!v4l2_chip_match_i2c_client(client, &reg->match))
  771. return -EINVAL;
  772. if (!capable(CAP_SYS_ADMIN))
  773. return -EPERM;
  774. reg->val = tvp5150_read(sd, reg->reg & 0xff);
  775. reg->size = 1;
  776. return 0;
  777. }
  778. static int tvp5150_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
  779. {
  780. struct i2c_client *client = v4l2_get_subdevdata(sd);
  781. if (!v4l2_chip_match_i2c_client(client, &reg->match))
  782. return -EINVAL;
  783. if (!capable(CAP_SYS_ADMIN))
  784. return -EPERM;
  785. tvp5150_write(sd, reg->reg & 0xff, reg->val & 0xff);
  786. return 0;
  787. }
  788. #endif
  789. static int tvp5150_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
  790. {
  791. int status = tvp5150_read(sd, 0x88);
  792. vt->signal = ((status & 0x04) && (status & 0x02)) ? 0xffff : 0x0;
  793. return 0;
  794. }
  795. /* ----------------------------------------------------------------------- */
  796. static const struct v4l2_ctrl_ops tvp5150_ctrl_ops = {
  797. .s_ctrl = tvp5150_s_ctrl,
  798. };
  799. static const struct v4l2_subdev_core_ops tvp5150_core_ops = {
  800. .log_status = tvp5150_log_status,
  801. .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
  802. .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
  803. .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
  804. .g_ctrl = v4l2_subdev_g_ctrl,
  805. .s_ctrl = v4l2_subdev_s_ctrl,
  806. .queryctrl = v4l2_subdev_queryctrl,
  807. .querymenu = v4l2_subdev_querymenu,
  808. .s_std = tvp5150_s_std,
  809. .reset = tvp5150_reset,
  810. .g_chip_ident = tvp5150_g_chip_ident,
  811. #ifdef CONFIG_VIDEO_ADV_DEBUG
  812. .g_register = tvp5150_g_register,
  813. .s_register = tvp5150_s_register,
  814. #endif
  815. };
  816. static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
  817. .g_tuner = tvp5150_g_tuner,
  818. };
  819. static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
  820. .s_routing = tvp5150_s_routing,
  821. };
  822. static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
  823. .g_sliced_vbi_cap = tvp5150_g_sliced_vbi_cap,
  824. .g_sliced_fmt = tvp5150_g_sliced_fmt,
  825. .s_sliced_fmt = tvp5150_s_sliced_fmt,
  826. .s_raw_fmt = tvp5150_s_raw_fmt,
  827. };
  828. static const struct v4l2_subdev_ops tvp5150_ops = {
  829. .core = &tvp5150_core_ops,
  830. .tuner = &tvp5150_tuner_ops,
  831. .video = &tvp5150_video_ops,
  832. .vbi = &tvp5150_vbi_ops,
  833. };
  834. /****************************************************************************
  835. I2C Client & Driver
  836. ****************************************************************************/
  837. static int tvp5150_probe(struct i2c_client *c,
  838. const struct i2c_device_id *id)
  839. {
  840. struct tvp5150 *core;
  841. struct v4l2_subdev *sd;
  842. u8 msb_id, lsb_id, msb_rom, lsb_rom;
  843. /* Check if the adapter supports the needed features */
  844. if (!i2c_check_functionality(c->adapter,
  845. I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
  846. return -EIO;
  847. core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL);
  848. if (!core) {
  849. return -ENOMEM;
  850. }
  851. sd = &core->sd;
  852. v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
  853. v4l_info(c, "chip found @ 0x%02x (%s)\n",
  854. c->addr << 1, c->adapter->name);
  855. msb_id = tvp5150_read(sd, TVP5150_MSB_DEV_ID);
  856. lsb_id = tvp5150_read(sd, TVP5150_LSB_DEV_ID);
  857. msb_rom = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER);
  858. lsb_rom = tvp5150_read(sd, TVP5150_ROM_MINOR_VER);
  859. if (msb_rom == 4 && lsb_rom == 0) { /* Is TVP5150AM1 */
  860. v4l2_info(sd, "tvp%02x%02xam1 detected.\n", msb_id, lsb_id);
  861. /* ITU-T BT.656.4 timing */
  862. tvp5150_write(sd, TVP5150_REV_SELECT, 0);
  863. } else {
  864. if (msb_rom == 3 || lsb_rom == 0x21) { /* Is TVP5150A */
  865. v4l2_info(sd, "tvp%02x%02xa detected.\n", msb_id, lsb_id);
  866. } else {
  867. v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n",
  868. msb_id, lsb_id);
  869. v4l2_info(sd, "*** Rom ver is %d.%d\n", msb_rom, lsb_rom);
  870. }
  871. }
  872. core->norm = V4L2_STD_ALL; /* Default is autodetect */
  873. core->input = TVP5150_COMPOSITE1;
  874. core->enable = 1;
  875. v4l2_ctrl_handler_init(&core->hdl, 4);
  876. v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
  877. V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
  878. v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
  879. V4L2_CID_CONTRAST, 0, 255, 1, 128);
  880. v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
  881. V4L2_CID_SATURATION, 0, 255, 1, 128);
  882. v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
  883. V4L2_CID_HUE, -128, 127, 1, 0);
  884. sd->ctrl_handler = &core->hdl;
  885. if (core->hdl.error) {
  886. int err = core->hdl.error;
  887. v4l2_ctrl_handler_free(&core->hdl);
  888. kfree(core);
  889. return err;
  890. }
  891. v4l2_ctrl_handler_setup(&core->hdl);
  892. if (debug > 1)
  893. tvp5150_log_status(sd);
  894. return 0;
  895. }
  896. static int tvp5150_remove(struct i2c_client *c)
  897. {
  898. struct v4l2_subdev *sd = i2c_get_clientdata(c);
  899. struct tvp5150 *decoder = to_tvp5150(sd);
  900. v4l2_dbg(1, debug, sd,
  901. "tvp5150.c: removing tvp5150 adapter on address 0x%x\n",
  902. c->addr << 1);
  903. v4l2_device_unregister_subdev(sd);
  904. v4l2_ctrl_handler_free(&decoder->hdl);
  905. kfree(to_tvp5150(sd));
  906. return 0;
  907. }
  908. /* ----------------------------------------------------------------------- */
  909. static const struct i2c_device_id tvp5150_id[] = {
  910. { "tvp5150", 0 },
  911. { }
  912. };
  913. MODULE_DEVICE_TABLE(i2c, tvp5150_id);
  914. static struct i2c_driver tvp5150_driver = {
  915. .driver = {
  916. .owner = THIS_MODULE,
  917. .name = "tvp5150",
  918. },
  919. .probe = tvp5150_probe,
  920. .remove = tvp5150_remove,
  921. .id_table = tvp5150_id,
  922. };
  923. static __init int init_tvp5150(void)
  924. {
  925. return i2c_add_driver(&tvp5150_driver);
  926. }
  927. static __exit void exit_tvp5150(void)
  928. {
  929. i2c_del_driver(&tvp5150_driver);
  930. }
  931. module_init(init_tvp5150);
  932. module_exit(exit_tvp5150);