tvp5150.c 29 KB

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