tvp514x.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. /*
  2. * drivers/media/i2c/tvp514x.c
  3. *
  4. * TI TVP5146/47 decoder driver
  5. *
  6. * Copyright (C) 2008 Texas Instruments Inc
  7. * Author: Vaibhav Hiremath <hvaibhav@ti.com>
  8. *
  9. * Contributors:
  10. * Sivaraj R <sivaraj@ti.com>
  11. * Brijesh R Jadav <brijesh.j@ti.com>
  12. * Hardik Shah <hardik.shah@ti.com>
  13. * Manjunath Hadli <mrh@ti.com>
  14. * Karicheri Muralidharan <m-karicheri2@ti.com>
  15. *
  16. * This package is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License version 2 as
  18. * published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  28. *
  29. */
  30. #include <linux/i2c.h>
  31. #include <linux/slab.h>
  32. #include <linux/delay.h>
  33. #include <linux/videodev2.h>
  34. #include <linux/module.h>
  35. #include <media/v4l2-device.h>
  36. #include <media/v4l2-common.h>
  37. #include <media/v4l2-mediabus.h>
  38. #include <media/v4l2-chip-ident.h>
  39. #include <media/v4l2-ctrls.h>
  40. #include <media/tvp514x.h>
  41. #include "tvp514x_regs.h"
  42. /* Module Name */
  43. #define TVP514X_MODULE_NAME "tvp514x"
  44. /* Private macros for TVP */
  45. #define I2C_RETRY_COUNT (5)
  46. #define LOCK_RETRY_COUNT (5)
  47. #define LOCK_RETRY_DELAY (200)
  48. /* Debug functions */
  49. static bool debug;
  50. module_param(debug, bool, 0644);
  51. MODULE_PARM_DESC(debug, "Debug level (0-1)");
  52. MODULE_AUTHOR("Texas Instruments");
  53. MODULE_DESCRIPTION("TVP514X linux decoder driver");
  54. MODULE_LICENSE("GPL");
  55. /* enum tvp514x_std - enum for supported standards */
  56. enum tvp514x_std {
  57. STD_NTSC_MJ = 0,
  58. STD_PAL_BDGHIN,
  59. STD_INVALID
  60. };
  61. /**
  62. * struct tvp514x_std_info - Structure to store standard informations
  63. * @width: Line width in pixels
  64. * @height:Number of active lines
  65. * @video_std: Value to write in REG_VIDEO_STD register
  66. * @standard: v4l2 standard structure information
  67. */
  68. struct tvp514x_std_info {
  69. unsigned long width;
  70. unsigned long height;
  71. u8 video_std;
  72. struct v4l2_standard standard;
  73. };
  74. static struct tvp514x_reg tvp514x_reg_list_default[0x40];
  75. static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable);
  76. /**
  77. * struct tvp514x_decoder - TVP5146/47 decoder object
  78. * @sd: Subdevice Slave handle
  79. * @tvp514x_regs: copy of hw's regs with preset values.
  80. * @pdata: Board specific
  81. * @ver: Chip version
  82. * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
  83. * @current_std: Current standard
  84. * @num_stds: Number of standards
  85. * @std_list: Standards list
  86. * @input: Input routing at chip level
  87. * @output: Output routing at chip level
  88. */
  89. struct tvp514x_decoder {
  90. struct v4l2_subdev sd;
  91. struct v4l2_ctrl_handler hdl;
  92. struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)];
  93. const struct tvp514x_platform_data *pdata;
  94. int ver;
  95. int streaming;
  96. enum tvp514x_std current_std;
  97. int num_stds;
  98. const struct tvp514x_std_info *std_list;
  99. /* Input and Output Routing parameters */
  100. u32 input;
  101. u32 output;
  102. };
  103. /* TVP514x default register values */
  104. static struct tvp514x_reg tvp514x_reg_list_default[] = {
  105. /* Composite selected */
  106. {TOK_WRITE, REG_INPUT_SEL, 0x05},
  107. {TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
  108. /* Auto mode */
  109. {TOK_WRITE, REG_VIDEO_STD, 0x00},
  110. {TOK_WRITE, REG_OPERATION_MODE, 0x00},
  111. {TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
  112. {TOK_WRITE, REG_COLOR_KILLER, 0x10},
  113. {TOK_WRITE, REG_LUMA_CONTROL1, 0x00},
  114. {TOK_WRITE, REG_LUMA_CONTROL2, 0x00},
  115. {TOK_WRITE, REG_LUMA_CONTROL3, 0x02},
  116. {TOK_WRITE, REG_BRIGHTNESS, 0x80},
  117. {TOK_WRITE, REG_CONTRAST, 0x80},
  118. {TOK_WRITE, REG_SATURATION, 0x80},
  119. {TOK_WRITE, REG_HUE, 0x00},
  120. {TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
  121. {TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
  122. /* Reserved */
  123. {TOK_SKIP, 0x0F, 0x00},
  124. {TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
  125. {TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
  126. {TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
  127. /* Reserved */
  128. {TOK_SKIP, 0x13, 0x00},
  129. {TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
  130. /* Reserved */
  131. {TOK_SKIP, 0x15, 0x00},
  132. /* NTSC timing */
  133. {TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},
  134. {TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
  135. {TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
  136. {TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
  137. /* NTSC timing */
  138. {TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},
  139. {TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
  140. {TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
  141. {TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
  142. /* NTSC timing */
  143. {TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},
  144. {TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
  145. {TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
  146. {TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
  147. /* NTSC timing */
  148. {TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},
  149. {TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
  150. {TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
  151. {TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
  152. /* Reserved */
  153. {TOK_SKIP, 0x26, 0x00},
  154. /* Reserved */
  155. {TOK_SKIP, 0x27, 0x00},
  156. {TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
  157. /* Reserved */
  158. {TOK_SKIP, 0x29, 0x00},
  159. {TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
  160. /* Reserved */
  161. {TOK_SKIP, 0x2B, 0x00},
  162. {TOK_SKIP, REG_SCART_DELAY, 0x00},
  163. {TOK_SKIP, REG_CTI_DELAY, 0x00},
  164. {TOK_SKIP, REG_CTI_CONTROL, 0x00},
  165. /* Reserved */
  166. {TOK_SKIP, 0x2F, 0x00},
  167. /* Reserved */
  168. {TOK_SKIP, 0x30, 0x00},
  169. /* Reserved */
  170. {TOK_SKIP, 0x31, 0x00},
  171. /* HS, VS active high */
  172. {TOK_WRITE, REG_SYNC_CONTROL, 0x00},
  173. /* 10-bit BT.656 */
  174. {TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00},
  175. /* Enable clk & data */
  176. {TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11},
  177. /* Enable AVID & FLD */
  178. {TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE},
  179. /* Enable VS & HS */
  180. {TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},
  181. {TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
  182. {TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
  183. /* Clear status */
  184. {TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01},
  185. {TOK_TERM, 0, 0},
  186. };
  187. /**
  188. * Supported standards -
  189. *
  190. * Currently supports two standards only, need to add support for rest of the
  191. * modes, like SECAM, etc...
  192. */
  193. static const struct tvp514x_std_info tvp514x_std_list[] = {
  194. /* Standard: STD_NTSC_MJ */
  195. [STD_NTSC_MJ] = {
  196. .width = NTSC_NUM_ACTIVE_PIXELS,
  197. .height = NTSC_NUM_ACTIVE_LINES,
  198. .video_std = VIDEO_STD_NTSC_MJ_BIT,
  199. .standard = {
  200. .index = 0,
  201. .id = V4L2_STD_NTSC,
  202. .name = "NTSC",
  203. .frameperiod = {1001, 30000},
  204. .framelines = 525
  205. },
  206. /* Standard: STD_PAL_BDGHIN */
  207. },
  208. [STD_PAL_BDGHIN] = {
  209. .width = PAL_NUM_ACTIVE_PIXELS,
  210. .height = PAL_NUM_ACTIVE_LINES,
  211. .video_std = VIDEO_STD_PAL_BDGHIN_BIT,
  212. .standard = {
  213. .index = 1,
  214. .id = V4L2_STD_PAL,
  215. .name = "PAL",
  216. .frameperiod = {1, 25},
  217. .framelines = 625
  218. },
  219. },
  220. /* Standard: need to add for additional standard */
  221. };
  222. static inline struct tvp514x_decoder *to_decoder(struct v4l2_subdev *sd)
  223. {
  224. return container_of(sd, struct tvp514x_decoder, sd);
  225. }
  226. static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
  227. {
  228. return &container_of(ctrl->handler, struct tvp514x_decoder, hdl)->sd;
  229. }
  230. /**
  231. * tvp514x_read_reg() - Read a value from a register in an TVP5146/47.
  232. * @sd: ptr to v4l2_subdev struct
  233. * @reg: TVP5146/47 register address
  234. *
  235. * Returns value read if successful, or non-zero (-1) otherwise.
  236. */
  237. static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg)
  238. {
  239. int err, retry = 0;
  240. struct i2c_client *client = v4l2_get_subdevdata(sd);
  241. read_again:
  242. err = i2c_smbus_read_byte_data(client, reg);
  243. if (err < 0) {
  244. if (retry <= I2C_RETRY_COUNT) {
  245. v4l2_warn(sd, "Read: retry ... %d\n", retry);
  246. retry++;
  247. msleep_interruptible(10);
  248. goto read_again;
  249. }
  250. }
  251. return err;
  252. }
  253. /**
  254. * dump_reg() - dump the register content of TVP5146/47.
  255. * @sd: ptr to v4l2_subdev struct
  256. * @reg: TVP5146/47 register address
  257. */
  258. static void dump_reg(struct v4l2_subdev *sd, u8 reg)
  259. {
  260. u32 val;
  261. val = tvp514x_read_reg(sd, reg);
  262. v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val);
  263. }
  264. /**
  265. * tvp514x_write_reg() - Write a value to a register in TVP5146/47
  266. * @sd: ptr to v4l2_subdev struct
  267. * @reg: TVP5146/47 register address
  268. * @val: value to be written to the register
  269. *
  270. * Write a value to a register in an TVP5146/47 decoder device.
  271. * Returns zero if successful, or non-zero otherwise.
  272. */
  273. static int tvp514x_write_reg(struct v4l2_subdev *sd, u8 reg, u8 val)
  274. {
  275. int err, retry = 0;
  276. struct i2c_client *client = v4l2_get_subdevdata(sd);
  277. write_again:
  278. err = i2c_smbus_write_byte_data(client, reg, val);
  279. if (err) {
  280. if (retry <= I2C_RETRY_COUNT) {
  281. v4l2_warn(sd, "Write: retry ... %d\n", retry);
  282. retry++;
  283. msleep_interruptible(10);
  284. goto write_again;
  285. }
  286. }
  287. return err;
  288. }
  289. /**
  290. * tvp514x_write_regs() : Initializes a list of TVP5146/47 registers
  291. * @sd: ptr to v4l2_subdev struct
  292. * @reglist: list of TVP5146/47 registers and values
  293. *
  294. * Initializes a list of TVP5146/47 registers:-
  295. * if token is TOK_TERM, then entire write operation terminates
  296. * if token is TOK_DELAY, then a delay of 'val' msec is introduced
  297. * if token is TOK_SKIP, then the register write is skipped
  298. * if token is TOK_WRITE, then the register write is performed
  299. * Returns zero if successful, or non-zero otherwise.
  300. */
  301. static int tvp514x_write_regs(struct v4l2_subdev *sd,
  302. const struct tvp514x_reg reglist[])
  303. {
  304. int err;
  305. const struct tvp514x_reg *next = reglist;
  306. for (; next->token != TOK_TERM; next++) {
  307. if (next->token == TOK_DELAY) {
  308. msleep(next->val);
  309. continue;
  310. }
  311. if (next->token == TOK_SKIP)
  312. continue;
  313. err = tvp514x_write_reg(sd, next->reg, (u8) next->val);
  314. if (err) {
  315. v4l2_err(sd, "Write failed. Err[%d]\n", err);
  316. return err;
  317. }
  318. }
  319. return 0;
  320. }
  321. /**
  322. * tvp514x_query_current_std() : Query the current standard detected by TVP5146/47
  323. * @sd: ptr to v4l2_subdev struct
  324. *
  325. * Returns the current standard detected by TVP5146/47, STD_INVALID if there is no
  326. * standard detected.
  327. */
  328. static enum tvp514x_std tvp514x_query_current_std(struct v4l2_subdev *sd)
  329. {
  330. u8 std, std_status;
  331. std = tvp514x_read_reg(sd, REG_VIDEO_STD);
  332. if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT)
  333. /* use the standard status register */
  334. std_status = tvp514x_read_reg(sd, REG_VIDEO_STD_STATUS);
  335. else
  336. /* use the standard register itself */
  337. std_status = std;
  338. switch (std_status & VIDEO_STD_MASK) {
  339. case VIDEO_STD_NTSC_MJ_BIT:
  340. return STD_NTSC_MJ;
  341. case VIDEO_STD_PAL_BDGHIN_BIT:
  342. return STD_PAL_BDGHIN;
  343. default:
  344. return STD_INVALID;
  345. }
  346. return STD_INVALID;
  347. }
  348. /* TVP5146/47 register dump function */
  349. static void tvp514x_reg_dump(struct v4l2_subdev *sd)
  350. {
  351. dump_reg(sd, REG_INPUT_SEL);
  352. dump_reg(sd, REG_AFE_GAIN_CTRL);
  353. dump_reg(sd, REG_VIDEO_STD);
  354. dump_reg(sd, REG_OPERATION_MODE);
  355. dump_reg(sd, REG_COLOR_KILLER);
  356. dump_reg(sd, REG_LUMA_CONTROL1);
  357. dump_reg(sd, REG_LUMA_CONTROL2);
  358. dump_reg(sd, REG_LUMA_CONTROL3);
  359. dump_reg(sd, REG_BRIGHTNESS);
  360. dump_reg(sd, REG_CONTRAST);
  361. dump_reg(sd, REG_SATURATION);
  362. dump_reg(sd, REG_HUE);
  363. dump_reg(sd, REG_CHROMA_CONTROL1);
  364. dump_reg(sd, REG_CHROMA_CONTROL2);
  365. dump_reg(sd, REG_COMP_PR_SATURATION);
  366. dump_reg(sd, REG_COMP_Y_CONTRAST);
  367. dump_reg(sd, REG_COMP_PB_SATURATION);
  368. dump_reg(sd, REG_COMP_Y_BRIGHTNESS);
  369. dump_reg(sd, REG_AVID_START_PIXEL_LSB);
  370. dump_reg(sd, REG_AVID_START_PIXEL_MSB);
  371. dump_reg(sd, REG_AVID_STOP_PIXEL_LSB);
  372. dump_reg(sd, REG_AVID_STOP_PIXEL_MSB);
  373. dump_reg(sd, REG_HSYNC_START_PIXEL_LSB);
  374. dump_reg(sd, REG_HSYNC_START_PIXEL_MSB);
  375. dump_reg(sd, REG_HSYNC_STOP_PIXEL_LSB);
  376. dump_reg(sd, REG_HSYNC_STOP_PIXEL_MSB);
  377. dump_reg(sd, REG_VSYNC_START_LINE_LSB);
  378. dump_reg(sd, REG_VSYNC_START_LINE_MSB);
  379. dump_reg(sd, REG_VSYNC_STOP_LINE_LSB);
  380. dump_reg(sd, REG_VSYNC_STOP_LINE_MSB);
  381. dump_reg(sd, REG_VBLK_START_LINE_LSB);
  382. dump_reg(sd, REG_VBLK_START_LINE_MSB);
  383. dump_reg(sd, REG_VBLK_STOP_LINE_LSB);
  384. dump_reg(sd, REG_VBLK_STOP_LINE_MSB);
  385. dump_reg(sd, REG_SYNC_CONTROL);
  386. dump_reg(sd, REG_OUTPUT_FORMATTER1);
  387. dump_reg(sd, REG_OUTPUT_FORMATTER2);
  388. dump_reg(sd, REG_OUTPUT_FORMATTER3);
  389. dump_reg(sd, REG_OUTPUT_FORMATTER4);
  390. dump_reg(sd, REG_OUTPUT_FORMATTER5);
  391. dump_reg(sd, REG_OUTPUT_FORMATTER6);
  392. dump_reg(sd, REG_CLEAR_LOST_LOCK);
  393. }
  394. /**
  395. * tvp514x_configure() - Configure the TVP5146/47 registers
  396. * @sd: ptr to v4l2_subdev struct
  397. * @decoder: ptr to tvp514x_decoder structure
  398. *
  399. * Returns zero if successful, or non-zero otherwise.
  400. */
  401. static int tvp514x_configure(struct v4l2_subdev *sd,
  402. struct tvp514x_decoder *decoder)
  403. {
  404. int err;
  405. /* common register initialization */
  406. err =
  407. tvp514x_write_regs(sd, decoder->tvp514x_regs);
  408. if (err)
  409. return err;
  410. if (debug)
  411. tvp514x_reg_dump(sd);
  412. return 0;
  413. }
  414. /**
  415. * tvp514x_detect() - Detect if an tvp514x is present, and if so which revision.
  416. * @sd: pointer to standard V4L2 sub-device structure
  417. * @decoder: pointer to tvp514x_decoder structure
  418. *
  419. * A device is considered to be detected if the chip ID (LSB and MSB)
  420. * registers match the expected values.
  421. * Any value of the rom version register is accepted.
  422. * Returns ENODEV error number if no device is detected, or zero
  423. * if a device is detected.
  424. */
  425. static int tvp514x_detect(struct v4l2_subdev *sd,
  426. struct tvp514x_decoder *decoder)
  427. {
  428. u8 chip_id_msb, chip_id_lsb, rom_ver;
  429. struct i2c_client *client = v4l2_get_subdevdata(sd);
  430. chip_id_msb = tvp514x_read_reg(sd, REG_CHIP_ID_MSB);
  431. chip_id_lsb = tvp514x_read_reg(sd, REG_CHIP_ID_LSB);
  432. rom_ver = tvp514x_read_reg(sd, REG_ROM_VERSION);
  433. v4l2_dbg(1, debug, sd,
  434. "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
  435. chip_id_msb, chip_id_lsb, rom_ver);
  436. if ((chip_id_msb != TVP514X_CHIP_ID_MSB)
  437. || ((chip_id_lsb != TVP5146_CHIP_ID_LSB)
  438. && (chip_id_lsb != TVP5147_CHIP_ID_LSB))) {
  439. /* We didn't read the values we expected, so this must not be
  440. * an TVP5146/47.
  441. */
  442. v4l2_err(sd, "chip id mismatch msb:0x%x lsb:0x%x\n",
  443. chip_id_msb, chip_id_lsb);
  444. return -ENODEV;
  445. }
  446. decoder->ver = rom_ver;
  447. v4l2_info(sd, "%s (Version - 0x%.2x) found at 0x%x (%s)\n",
  448. client->name, decoder->ver,
  449. client->addr << 1, client->adapter->name);
  450. return 0;
  451. }
  452. /**
  453. * tvp514x_querystd() - V4L2 decoder interface handler for querystd
  454. * @sd: pointer to standard V4L2 sub-device structure
  455. * @std_id: standard V4L2 std_id ioctl enum
  456. *
  457. * Returns the current standard detected by TVP5146/47. If no active input is
  458. * detected then *std_id is set to 0 and the function returns 0.
  459. */
  460. static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
  461. {
  462. struct tvp514x_decoder *decoder = to_decoder(sd);
  463. enum tvp514x_std current_std;
  464. enum tvp514x_input input_sel;
  465. u8 sync_lock_status, lock_mask;
  466. if (std_id == NULL)
  467. return -EINVAL;
  468. *std_id = V4L2_STD_UNKNOWN;
  469. /* To query the standard the TVP514x must power on the ADCs. */
  470. if (!decoder->streaming) {
  471. tvp514x_s_stream(sd, 1);
  472. msleep(LOCK_RETRY_DELAY);
  473. }
  474. /* query the current standard */
  475. current_std = tvp514x_query_current_std(sd);
  476. if (current_std == STD_INVALID)
  477. return 0;
  478. input_sel = decoder->input;
  479. switch (input_sel) {
  480. case INPUT_CVBS_VI1A:
  481. case INPUT_CVBS_VI1B:
  482. case INPUT_CVBS_VI1C:
  483. case INPUT_CVBS_VI2A:
  484. case INPUT_CVBS_VI2B:
  485. case INPUT_CVBS_VI2C:
  486. case INPUT_CVBS_VI3A:
  487. case INPUT_CVBS_VI3B:
  488. case INPUT_CVBS_VI3C:
  489. case INPUT_CVBS_VI4A:
  490. lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
  491. STATUS_HORZ_SYNC_LOCK_BIT |
  492. STATUS_VIRT_SYNC_LOCK_BIT;
  493. break;
  494. case INPUT_SVIDEO_VI2A_VI1A:
  495. case INPUT_SVIDEO_VI2B_VI1B:
  496. case INPUT_SVIDEO_VI2C_VI1C:
  497. case INPUT_SVIDEO_VI2A_VI3A:
  498. case INPUT_SVIDEO_VI2B_VI3B:
  499. case INPUT_SVIDEO_VI2C_VI3C:
  500. case INPUT_SVIDEO_VI4A_VI1A:
  501. case INPUT_SVIDEO_VI4A_VI1B:
  502. case INPUT_SVIDEO_VI4A_VI1C:
  503. case INPUT_SVIDEO_VI4A_VI3A:
  504. case INPUT_SVIDEO_VI4A_VI3B:
  505. case INPUT_SVIDEO_VI4A_VI3C:
  506. lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
  507. STATUS_VIRT_SYNC_LOCK_BIT;
  508. break;
  509. /*Need to add other interfaces*/
  510. default:
  511. return -EINVAL;
  512. }
  513. /* check whether signal is locked */
  514. sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1);
  515. if (lock_mask != (sync_lock_status & lock_mask))
  516. return 0; /* No input detected */
  517. *std_id = decoder->std_list[current_std].standard.id;
  518. v4l2_dbg(1, debug, sd, "Current STD: %s\n",
  519. decoder->std_list[current_std].standard.name);
  520. return 0;
  521. }
  522. /**
  523. * tvp514x_s_std() - V4L2 decoder interface handler for s_std
  524. * @sd: pointer to standard V4L2 sub-device structure
  525. * @std_id: standard V4L2 v4l2_std_id ioctl enum
  526. *
  527. * If std_id is supported, sets the requested standard. Otherwise, returns
  528. * -EINVAL
  529. */
  530. static int tvp514x_s_std(struct v4l2_subdev *sd, v4l2_std_id std_id)
  531. {
  532. struct tvp514x_decoder *decoder = to_decoder(sd);
  533. int err, i;
  534. for (i = 0; i < decoder->num_stds; i++)
  535. if (std_id & decoder->std_list[i].standard.id)
  536. break;
  537. if ((i == decoder->num_stds) || (i == STD_INVALID))
  538. return -EINVAL;
  539. err = tvp514x_write_reg(sd, REG_VIDEO_STD,
  540. decoder->std_list[i].video_std);
  541. if (err)
  542. return err;
  543. decoder->current_std = i;
  544. decoder->tvp514x_regs[REG_VIDEO_STD].val =
  545. decoder->std_list[i].video_std;
  546. v4l2_dbg(1, debug, sd, "Standard set to: %s\n",
  547. decoder->std_list[i].standard.name);
  548. return 0;
  549. }
  550. /**
  551. * tvp514x_s_routing() - V4L2 decoder interface handler for s_routing
  552. * @sd: pointer to standard V4L2 sub-device structure
  553. * @input: input selector for routing the signal
  554. * @output: output selector for routing the signal
  555. * @config: config value. Not used
  556. *
  557. * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
  558. * the input is not supported or there is no active signal present in the
  559. * selected input.
  560. */
  561. static int tvp514x_s_routing(struct v4l2_subdev *sd,
  562. u32 input, u32 output, u32 config)
  563. {
  564. struct tvp514x_decoder *decoder = to_decoder(sd);
  565. int err;
  566. enum tvp514x_input input_sel;
  567. enum tvp514x_output output_sel;
  568. if ((input >= INPUT_INVALID) ||
  569. (output >= OUTPUT_INVALID))
  570. /* Index out of bound */
  571. return -EINVAL;
  572. input_sel = input;
  573. output_sel = output;
  574. err = tvp514x_write_reg(sd, REG_INPUT_SEL, input_sel);
  575. if (err)
  576. return err;
  577. output_sel |= tvp514x_read_reg(sd,
  578. REG_OUTPUT_FORMATTER1) & 0x7;
  579. err = tvp514x_write_reg(sd, REG_OUTPUT_FORMATTER1,
  580. output_sel);
  581. if (err)
  582. return err;
  583. decoder->tvp514x_regs[REG_INPUT_SEL].val = input_sel;
  584. decoder->tvp514x_regs[REG_OUTPUT_FORMATTER1].val = output_sel;
  585. decoder->input = input;
  586. decoder->output = output;
  587. v4l2_dbg(1, debug, sd, "Input set to: %d\n", input_sel);
  588. return 0;
  589. }
  590. /**
  591. * tvp514x_s_ctrl() - V4L2 decoder interface handler for s_ctrl
  592. * @ctrl: pointer to v4l2_ctrl structure
  593. *
  594. * If the requested control is supported, sets the control's current
  595. * value in HW. Otherwise, returns -EINVAL if the control is not supported.
  596. */
  597. static int tvp514x_s_ctrl(struct v4l2_ctrl *ctrl)
  598. {
  599. struct v4l2_subdev *sd = to_sd(ctrl);
  600. struct tvp514x_decoder *decoder = to_decoder(sd);
  601. int err = -EINVAL, value;
  602. value = ctrl->val;
  603. switch (ctrl->id) {
  604. case V4L2_CID_BRIGHTNESS:
  605. err = tvp514x_write_reg(sd, REG_BRIGHTNESS, value);
  606. if (!err)
  607. decoder->tvp514x_regs[REG_BRIGHTNESS].val = value;
  608. break;
  609. case V4L2_CID_CONTRAST:
  610. err = tvp514x_write_reg(sd, REG_CONTRAST, value);
  611. if (!err)
  612. decoder->tvp514x_regs[REG_CONTRAST].val = value;
  613. break;
  614. case V4L2_CID_SATURATION:
  615. err = tvp514x_write_reg(sd, REG_SATURATION, value);
  616. if (!err)
  617. decoder->tvp514x_regs[REG_SATURATION].val = value;
  618. break;
  619. case V4L2_CID_HUE:
  620. if (value == 180)
  621. value = 0x7F;
  622. else if (value == -180)
  623. value = 0x80;
  624. err = tvp514x_write_reg(sd, REG_HUE, value);
  625. if (!err)
  626. decoder->tvp514x_regs[REG_HUE].val = value;
  627. break;
  628. case V4L2_CID_AUTOGAIN:
  629. err = tvp514x_write_reg(sd, REG_AFE_GAIN_CTRL, value ? 0x0f : 0x0c);
  630. if (!err)
  631. decoder->tvp514x_regs[REG_AFE_GAIN_CTRL].val = value;
  632. break;
  633. }
  634. v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d\n",
  635. ctrl->id, ctrl->val);
  636. return err;
  637. }
  638. /**
  639. * tvp514x_enum_mbus_fmt() - V4L2 decoder interface handler for enum_mbus_fmt
  640. * @sd: pointer to standard V4L2 sub-device structure
  641. * @index: index of pixelcode to retrieve
  642. * @code: receives the pixelcode
  643. *
  644. * Enumerates supported mediabus formats
  645. */
  646. static int
  647. tvp514x_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
  648. enum v4l2_mbus_pixelcode *code)
  649. {
  650. if (index)
  651. return -EINVAL;
  652. *code = V4L2_MBUS_FMT_YUYV10_2X10;
  653. return 0;
  654. }
  655. /**
  656. * tvp514x_mbus_fmt_cap() - V4L2 decoder interface handler for try/s/g_mbus_fmt
  657. * @sd: pointer to standard V4L2 sub-device structure
  658. * @f: pointer to the mediabus format structure
  659. *
  660. * Negotiates the image capture size and mediabus format.
  661. */
  662. static int
  663. tvp514x_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f)
  664. {
  665. struct tvp514x_decoder *decoder = to_decoder(sd);
  666. enum tvp514x_std current_std;
  667. if (f == NULL)
  668. return -EINVAL;
  669. /* Calculate height and width based on current standard */
  670. current_std = decoder->current_std;
  671. f->code = V4L2_MBUS_FMT_YUYV10_2X10;
  672. f->width = decoder->std_list[current_std].width;
  673. f->height = decoder->std_list[current_std].height;
  674. f->field = V4L2_FIELD_INTERLACED;
  675. f->colorspace = V4L2_COLORSPACE_SMPTE170M;
  676. v4l2_dbg(1, debug, sd, "MBUS_FMT: Width - %d, Height - %d\n",
  677. f->width, f->height);
  678. return 0;
  679. }
  680. /**
  681. * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm
  682. * @sd: pointer to standard V4L2 sub-device structure
  683. * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
  684. *
  685. * Returns the decoder's video CAPTURE parameters.
  686. */
  687. static int
  688. tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
  689. {
  690. struct tvp514x_decoder *decoder = to_decoder(sd);
  691. struct v4l2_captureparm *cparm;
  692. enum tvp514x_std current_std;
  693. if (a == NULL)
  694. return -EINVAL;
  695. if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  696. /* only capture is supported */
  697. return -EINVAL;
  698. /* get the current standard */
  699. current_std = decoder->current_std;
  700. cparm = &a->parm.capture;
  701. cparm->capability = V4L2_CAP_TIMEPERFRAME;
  702. cparm->timeperframe =
  703. decoder->std_list[current_std].standard.frameperiod;
  704. return 0;
  705. }
  706. /**
  707. * tvp514x_s_parm() - V4L2 decoder interface handler for s_parm
  708. * @sd: pointer to standard V4L2 sub-device structure
  709. * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
  710. *
  711. * Configures the decoder to use the input parameters, if possible. If
  712. * not possible, returns the appropriate error code.
  713. */
  714. static int
  715. tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
  716. {
  717. struct tvp514x_decoder *decoder = to_decoder(sd);
  718. struct v4l2_fract *timeperframe;
  719. enum tvp514x_std current_std;
  720. if (a == NULL)
  721. return -EINVAL;
  722. if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  723. /* only capture is supported */
  724. return -EINVAL;
  725. timeperframe = &a->parm.capture.timeperframe;
  726. /* get the current standard */
  727. current_std = decoder->current_std;
  728. *timeperframe =
  729. decoder->std_list[current_std].standard.frameperiod;
  730. return 0;
  731. }
  732. /**
  733. * tvp514x_s_stream() - V4L2 decoder i/f handler for s_stream
  734. * @sd: pointer to standard V4L2 sub-device structure
  735. * @enable: streaming enable or disable
  736. *
  737. * Sets streaming to enable or disable, if possible.
  738. */
  739. static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable)
  740. {
  741. int err = 0;
  742. struct i2c_client *client = v4l2_get_subdevdata(sd);
  743. struct tvp514x_decoder *decoder = to_decoder(sd);
  744. if (decoder->streaming == enable)
  745. return 0;
  746. switch (enable) {
  747. case 0:
  748. {
  749. /* Power Down Sequence */
  750. err = tvp514x_write_reg(sd, REG_OPERATION_MODE, 0x01);
  751. if (err) {
  752. v4l2_err(sd, "Unable to turn off decoder\n");
  753. return err;
  754. }
  755. decoder->streaming = enable;
  756. break;
  757. }
  758. case 1:
  759. {
  760. struct tvp514x_reg *int_seq = (struct tvp514x_reg *)
  761. client->driver->id_table->driver_data;
  762. /* Power Up Sequence */
  763. err = tvp514x_write_regs(sd, int_seq);
  764. if (err) {
  765. v4l2_err(sd, "Unable to turn on decoder\n");
  766. return err;
  767. }
  768. /* Detect if not already detected */
  769. err = tvp514x_detect(sd, decoder);
  770. if (err) {
  771. v4l2_err(sd, "Unable to detect decoder\n");
  772. return err;
  773. }
  774. err = tvp514x_configure(sd, decoder);
  775. if (err) {
  776. v4l2_err(sd, "Unable to configure decoder\n");
  777. return err;
  778. }
  779. decoder->streaming = enable;
  780. break;
  781. }
  782. default:
  783. err = -ENODEV;
  784. break;
  785. }
  786. return err;
  787. }
  788. static const struct v4l2_ctrl_ops tvp514x_ctrl_ops = {
  789. .s_ctrl = tvp514x_s_ctrl,
  790. };
  791. static const struct v4l2_subdev_core_ops tvp514x_core_ops = {
  792. .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
  793. .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
  794. .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
  795. .g_ctrl = v4l2_subdev_g_ctrl,
  796. .s_ctrl = v4l2_subdev_s_ctrl,
  797. .queryctrl = v4l2_subdev_queryctrl,
  798. .querymenu = v4l2_subdev_querymenu,
  799. .s_std = tvp514x_s_std,
  800. };
  801. static const struct v4l2_subdev_video_ops tvp514x_video_ops = {
  802. .s_routing = tvp514x_s_routing,
  803. .querystd = tvp514x_querystd,
  804. .enum_mbus_fmt = tvp514x_enum_mbus_fmt,
  805. .g_mbus_fmt = tvp514x_mbus_fmt,
  806. .try_mbus_fmt = tvp514x_mbus_fmt,
  807. .s_mbus_fmt = tvp514x_mbus_fmt,
  808. .g_parm = tvp514x_g_parm,
  809. .s_parm = tvp514x_s_parm,
  810. .s_stream = tvp514x_s_stream,
  811. };
  812. static const struct v4l2_subdev_ops tvp514x_ops = {
  813. .core = &tvp514x_core_ops,
  814. .video = &tvp514x_video_ops,
  815. };
  816. static struct tvp514x_decoder tvp514x_dev = {
  817. .streaming = 0,
  818. .current_std = STD_NTSC_MJ,
  819. .std_list = tvp514x_std_list,
  820. .num_stds = ARRAY_SIZE(tvp514x_std_list),
  821. };
  822. /**
  823. * tvp514x_probe() - decoder driver i2c probe handler
  824. * @client: i2c driver client device structure
  825. * @id: i2c driver id table
  826. *
  827. * Register decoder as an i2c client device and V4L2
  828. * device.
  829. */
  830. static int
  831. tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
  832. {
  833. struct tvp514x_decoder *decoder;
  834. struct v4l2_subdev *sd;
  835. /* Check if the adapter supports the needed features */
  836. if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
  837. return -EIO;
  838. if (!client->dev.platform_data) {
  839. v4l2_err(client, "No platform data!!\n");
  840. return -ENODEV;
  841. }
  842. decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL);
  843. if (!decoder)
  844. return -ENOMEM;
  845. /* Initialize the tvp514x_decoder with default configuration */
  846. *decoder = tvp514x_dev;
  847. /* Copy default register configuration */
  848. memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default,
  849. sizeof(tvp514x_reg_list_default));
  850. /* Copy board specific information here */
  851. decoder->pdata = client->dev.platform_data;
  852. /**
  853. * Fetch platform specific data, and configure the
  854. * tvp514x_reg_list[] accordingly. Since this is one
  855. * time configuration, no need to preserve.
  856. */
  857. decoder->tvp514x_regs[REG_OUTPUT_FORMATTER2].val |=
  858. (decoder->pdata->clk_polarity << 1);
  859. decoder->tvp514x_regs[REG_SYNC_CONTROL].val |=
  860. ((decoder->pdata->hs_polarity << 2) |
  861. (decoder->pdata->vs_polarity << 3));
  862. /* Set default standard to auto */
  863. decoder->tvp514x_regs[REG_VIDEO_STD].val =
  864. VIDEO_STD_AUTO_SWITCH_BIT;
  865. /* Register with V4L2 layer as slave device */
  866. sd = &decoder->sd;
  867. v4l2_i2c_subdev_init(sd, client, &tvp514x_ops);
  868. v4l2_ctrl_handler_init(&decoder->hdl, 5);
  869. v4l2_ctrl_new_std(&decoder->hdl, &tvp514x_ctrl_ops,
  870. V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
  871. v4l2_ctrl_new_std(&decoder->hdl, &tvp514x_ctrl_ops,
  872. V4L2_CID_CONTRAST, 0, 255, 1, 128);
  873. v4l2_ctrl_new_std(&decoder->hdl, &tvp514x_ctrl_ops,
  874. V4L2_CID_SATURATION, 0, 255, 1, 128);
  875. v4l2_ctrl_new_std(&decoder->hdl, &tvp514x_ctrl_ops,
  876. V4L2_CID_HUE, -180, 180, 180, 0);
  877. v4l2_ctrl_new_std(&decoder->hdl, &tvp514x_ctrl_ops,
  878. V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
  879. sd->ctrl_handler = &decoder->hdl;
  880. if (decoder->hdl.error) {
  881. int err = decoder->hdl.error;
  882. v4l2_ctrl_handler_free(&decoder->hdl);
  883. return err;
  884. }
  885. v4l2_ctrl_handler_setup(&decoder->hdl);
  886. v4l2_info(sd, "%s decoder driver registered !!\n", sd->name);
  887. return 0;
  888. }
  889. /**
  890. * tvp514x_remove() - decoder driver i2c remove handler
  891. * @client: i2c driver client device structure
  892. *
  893. * Unregister decoder as an i2c client device and V4L2
  894. * device. Complement of tvp514x_probe().
  895. */
  896. static int tvp514x_remove(struct i2c_client *client)
  897. {
  898. struct v4l2_subdev *sd = i2c_get_clientdata(client);
  899. struct tvp514x_decoder *decoder = to_decoder(sd);
  900. v4l2_device_unregister_subdev(sd);
  901. v4l2_ctrl_handler_free(&decoder->hdl);
  902. return 0;
  903. }
  904. /* TVP5146 Init/Power on Sequence */
  905. static const struct tvp514x_reg tvp5146_init_reg_seq[] = {
  906. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
  907. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
  908. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
  909. {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
  910. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
  911. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
  912. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
  913. {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
  914. {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
  915. {TOK_WRITE, REG_OPERATION_MODE, 0x01},
  916. {TOK_WRITE, REG_OPERATION_MODE, 0x00},
  917. {TOK_TERM, 0, 0},
  918. };
  919. /* TVP5147 Init/Power on Sequence */
  920. static const struct tvp514x_reg tvp5147_init_reg_seq[] = {
  921. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
  922. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
  923. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80},
  924. {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
  925. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
  926. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
  927. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
  928. {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01},
  929. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x16},
  930. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
  931. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xA0},
  932. {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x16},
  933. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60},
  934. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
  935. {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0},
  936. {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
  937. {TOK_WRITE, REG_OPERATION_MODE, 0x01},
  938. {TOK_WRITE, REG_OPERATION_MODE, 0x00},
  939. {TOK_TERM, 0, 0},
  940. };
  941. /* TVP5146M2/TVP5147M1 Init/Power on Sequence */
  942. static const struct tvp514x_reg tvp514xm_init_reg_seq[] = {
  943. {TOK_WRITE, REG_OPERATION_MODE, 0x01},
  944. {TOK_WRITE, REG_OPERATION_MODE, 0x00},
  945. {TOK_TERM, 0, 0},
  946. };
  947. /**
  948. * I2C Device Table -
  949. *
  950. * name - Name of the actual device/chip.
  951. * driver_data - Driver data
  952. */
  953. static const struct i2c_device_id tvp514x_id[] = {
  954. {"tvp5146", (unsigned long)tvp5146_init_reg_seq},
  955. {"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq},
  956. {"tvp5147", (unsigned long)tvp5147_init_reg_seq},
  957. {"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq},
  958. {},
  959. };
  960. MODULE_DEVICE_TABLE(i2c, tvp514x_id);
  961. static struct i2c_driver tvp514x_driver = {
  962. .driver = {
  963. .owner = THIS_MODULE,
  964. .name = TVP514X_MODULE_NAME,
  965. },
  966. .probe = tvp514x_probe,
  967. .remove = tvp514x_remove,
  968. .id_table = tvp514x_id,
  969. };
  970. module_i2c_driver(tvp514x_driver);