tvp5150.c 28 KB

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