ths8200.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /*
  2. * ths8200 - Texas Instruments THS8200 video encoder driver
  3. *
  4. * Copyright 2013 Cisco Systems, Inc. and/or its affiliates.
  5. *
  6. * This program is free software; you may redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation version 2.
  13. *
  14. * This program is distributed .as is. WITHOUT ANY WARRANTY of any
  15. * kind, whether express or implied; without even the implied warranty
  16. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. */
  19. #include <linux/i2c.h>
  20. #include <linux/module.h>
  21. #include <linux/v4l2-dv-timings.h>
  22. #include <media/v4l2-async.h>
  23. #include <media/v4l2-device.h>
  24. #include "ths8200_regs.h"
  25. static int debug;
  26. module_param(debug, int, 0644);
  27. MODULE_PARM_DESC(debug, "debug level (0-2)");
  28. MODULE_DESCRIPTION("Texas Instruments THS8200 video encoder driver");
  29. MODULE_AUTHOR("Mats Randgaard <mats.randgaard@cisco.com>");
  30. MODULE_AUTHOR("Martin Bugge <martin.bugge@cisco.com>");
  31. MODULE_LICENSE("GPL v2");
  32. struct ths8200_state {
  33. struct v4l2_subdev sd;
  34. uint8_t chip_version;
  35. /* Is the ths8200 powered on? */
  36. bool power_on;
  37. struct v4l2_dv_timings dv_timings;
  38. };
  39. static const struct v4l2_dv_timings ths8200_timings[] = {
  40. V4L2_DV_BT_CEA_720X480P59_94,
  41. V4L2_DV_BT_CEA_1280X720P24,
  42. V4L2_DV_BT_CEA_1280X720P25,
  43. V4L2_DV_BT_CEA_1280X720P30,
  44. V4L2_DV_BT_CEA_1280X720P50,
  45. V4L2_DV_BT_CEA_1280X720P60,
  46. V4L2_DV_BT_CEA_1920X1080P24,
  47. V4L2_DV_BT_CEA_1920X1080P25,
  48. V4L2_DV_BT_CEA_1920X1080P30,
  49. V4L2_DV_BT_CEA_1920X1080P50,
  50. V4L2_DV_BT_CEA_1920X1080P60,
  51. };
  52. static inline struct ths8200_state *to_state(struct v4l2_subdev *sd)
  53. {
  54. return container_of(sd, struct ths8200_state, sd);
  55. }
  56. static inline unsigned hblanking(const struct v4l2_bt_timings *t)
  57. {
  58. return t->hfrontporch + t->hsync + t->hbackporch;
  59. }
  60. static inline unsigned htotal(const struct v4l2_bt_timings *t)
  61. {
  62. return t->width + t->hfrontporch + t->hsync + t->hbackporch;
  63. }
  64. static inline unsigned vblanking(const struct v4l2_bt_timings *t)
  65. {
  66. return t->vfrontporch + t->vsync + t->vbackporch;
  67. }
  68. static inline unsigned vtotal(const struct v4l2_bt_timings *t)
  69. {
  70. return t->height + t->vfrontporch + t->vsync + t->vbackporch;
  71. }
  72. static int ths8200_read(struct v4l2_subdev *sd, u8 reg)
  73. {
  74. struct i2c_client *client = v4l2_get_subdevdata(sd);
  75. return i2c_smbus_read_byte_data(client, reg);
  76. }
  77. static int ths8200_write(struct v4l2_subdev *sd, u8 reg, u8 val)
  78. {
  79. struct i2c_client *client = v4l2_get_subdevdata(sd);
  80. int ret;
  81. int i;
  82. for (i = 0; i < 3; i++) {
  83. ret = i2c_smbus_write_byte_data(client, reg, val);
  84. if (ret == 0)
  85. return 0;
  86. }
  87. v4l2_err(sd, "I2C Write Problem\n");
  88. return ret;
  89. }
  90. /* To set specific bits in the register, a clear-mask is given (to be AND-ed),
  91. * and then the value-mask (to be OR-ed).
  92. */
  93. static inline void
  94. ths8200_write_and_or(struct v4l2_subdev *sd, u8 reg,
  95. uint8_t clr_mask, uint8_t val_mask)
  96. {
  97. ths8200_write(sd, reg, (ths8200_read(sd, reg) & clr_mask) | val_mask);
  98. }
  99. #ifdef CONFIG_VIDEO_ADV_DEBUG
  100. static int ths8200_g_register(struct v4l2_subdev *sd,
  101. struct v4l2_dbg_register *reg)
  102. {
  103. reg->val = ths8200_read(sd, reg->reg & 0xff);
  104. reg->size = 1;
  105. return 0;
  106. }
  107. static int ths8200_s_register(struct v4l2_subdev *sd,
  108. const struct v4l2_dbg_register *reg)
  109. {
  110. ths8200_write(sd, reg->reg & 0xff, reg->val & 0xff);
  111. return 0;
  112. }
  113. #endif
  114. static void ths8200_print_timings(struct v4l2_subdev *sd,
  115. struct v4l2_dv_timings *timings,
  116. const char *txt, bool detailed)
  117. {
  118. struct v4l2_bt_timings *bt = &timings->bt;
  119. u32 htot, vtot;
  120. if (timings->type != V4L2_DV_BT_656_1120)
  121. return;
  122. htot = htotal(bt);
  123. vtot = vtotal(bt);
  124. v4l2_info(sd, "%s %dx%d%s%d (%dx%d)",
  125. txt, bt->width, bt->height, bt->interlaced ? "i" : "p",
  126. (htot * vtot) > 0 ? ((u32)bt->pixelclock / (htot * vtot)) : 0,
  127. htot, vtot);
  128. if (detailed) {
  129. v4l2_info(sd, " horizontal: fp = %d, %ssync = %d, bp = %d\n",
  130. bt->hfrontporch,
  131. (bt->polarities & V4L2_DV_HSYNC_POS_POL) ? "+" : "-",
  132. bt->hsync, bt->hbackporch);
  133. v4l2_info(sd, " vertical: fp = %d, %ssync = %d, bp = %d\n",
  134. bt->vfrontporch,
  135. (bt->polarities & V4L2_DV_VSYNC_POS_POL) ? "+" : "-",
  136. bt->vsync, bt->vbackporch);
  137. v4l2_info(sd,
  138. " pixelclock: %lld, flags: 0x%x, standards: 0x%x\n",
  139. bt->pixelclock, bt->flags, bt->standards);
  140. }
  141. }
  142. static int ths8200_log_status(struct v4l2_subdev *sd)
  143. {
  144. struct ths8200_state *state = to_state(sd);
  145. uint8_t reg_03 = ths8200_read(sd, THS8200_CHIP_CTL);
  146. v4l2_info(sd, "----- Chip status -----\n");
  147. v4l2_info(sd, "version: %u\n", state->chip_version);
  148. v4l2_info(sd, "power: %s\n", (reg_03 & 0x0c) ? "off" : "on");
  149. v4l2_info(sd, "reset: %s\n", (reg_03 & 0x01) ? "off" : "on");
  150. v4l2_info(sd, "test pattern: %s\n",
  151. (reg_03 & 0x20) ? "enabled" : "disabled");
  152. v4l2_info(sd, "format: %ux%u\n",
  153. ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_MSB) * 256 +
  154. ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_LSB),
  155. (ths8200_read(sd, THS8200_DTG2_LINE_CNT_MSB) & 0x07) * 256 +
  156. ths8200_read(sd, THS8200_DTG2_LINE_CNT_LSB));
  157. ths8200_print_timings(sd, &state->dv_timings,
  158. "Configured format:", true);
  159. return 0;
  160. }
  161. /* Power up/down ths8200 */
  162. static int ths8200_s_power(struct v4l2_subdev *sd, int on)
  163. {
  164. struct ths8200_state *state = to_state(sd);
  165. v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, on ? "on" : "off");
  166. state->power_on = on;
  167. /* Power up/down - leave in reset state until input video is present */
  168. ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0xf2, (on ? 0x00 : 0x0c));
  169. return 0;
  170. }
  171. static const struct v4l2_subdev_core_ops ths8200_core_ops = {
  172. .log_status = ths8200_log_status,
  173. .s_power = ths8200_s_power,
  174. #ifdef CONFIG_VIDEO_ADV_DEBUG
  175. .g_register = ths8200_g_register,
  176. .s_register = ths8200_s_register,
  177. #endif
  178. };
  179. /* -----------------------------------------------------------------------------
  180. * V4L2 subdev video operations
  181. */
  182. static int ths8200_s_stream(struct v4l2_subdev *sd, int enable)
  183. {
  184. struct ths8200_state *state = to_state(sd);
  185. if (enable && !state->power_on)
  186. ths8200_s_power(sd, true);
  187. ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0xfe,
  188. (enable ? 0x01 : 0x00));
  189. v4l2_dbg(1, debug, sd, "%s: %sable\n",
  190. __func__, (enable ? "en" : "dis"));
  191. return 0;
  192. }
  193. static void ths8200_core_init(struct v4l2_subdev *sd)
  194. {
  195. /* setup clocks */
  196. ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0x3f, 0xc0);
  197. /**** Data path control (DATA) ****/
  198. /* Set FSADJ 700 mV,
  199. * bypass 422-444 interpolation,
  200. * input format 30 bit RGB444
  201. */
  202. ths8200_write(sd, THS8200_DATA_CNTL, 0x70);
  203. /* DTG Mode (Video blocked during blanking
  204. * VESA slave
  205. */
  206. ths8200_write(sd, THS8200_DTG1_MODE, 0x87);
  207. /**** Display Timing Generator Control, Part 1 (DTG1). ****/
  208. /* Disable embedded syncs on the output by setting
  209. * the amplitude to zero for all channels.
  210. */
  211. ths8200_write(sd, THS8200_DTG1_Y_SYNC_MSB, 0x2a);
  212. ths8200_write(sd, THS8200_DTG1_CBCR_SYNC_MSB, 0x2a);
  213. }
  214. static void ths8200_setup(struct v4l2_subdev *sd, struct v4l2_bt_timings *bt)
  215. {
  216. uint8_t polarity = 0;
  217. uint16_t line_start_active_video = (bt->vsync + bt->vbackporch);
  218. uint16_t line_start_front_porch = (vtotal(bt) - bt->vfrontporch);
  219. /*** System ****/
  220. /* Set chip in reset while it is configured */
  221. ths8200_s_stream(sd, false);
  222. /* configure video output timings */
  223. ths8200_write(sd, THS8200_DTG1_SPEC_A, bt->hsync);
  224. ths8200_write(sd, THS8200_DTG1_SPEC_B, bt->hfrontporch);
  225. /* Zero for progressive scan formats.*/
  226. if (!bt->interlaced)
  227. ths8200_write(sd, THS8200_DTG1_SPEC_C, 0x00);
  228. /* Distance from leading edge of h sync to start of active video.
  229. * MSB in 0x2b
  230. */
  231. ths8200_write(sd, THS8200_DTG1_SPEC_D_LSB,
  232. (bt->hbackporch + bt->hsync) & 0xff);
  233. /* Zero for SDTV-mode. MSB in 0x2b */
  234. ths8200_write(sd, THS8200_DTG1_SPEC_E_LSB, 0x00);
  235. /*
  236. * MSB for dtg1_spec(d/e/h). See comment for
  237. * corresponding LSB registers.
  238. */
  239. ths8200_write(sd, THS8200_DTG1_SPEC_DEH_MSB,
  240. ((bt->hbackporch + bt->hsync) & 0x100) >> 1);
  241. /* h front porch */
  242. ths8200_write(sd, THS8200_DTG1_SPEC_K_LSB, (bt->hfrontporch) & 0xff);
  243. ths8200_write(sd, THS8200_DTG1_SPEC_K_MSB,
  244. ((bt->hfrontporch) & 0x700) >> 8);
  245. /* Half the line length. Used to calculate SDTV line types. */
  246. ths8200_write(sd, THS8200_DTG1_SPEC_G_LSB, (htotal(bt)/2) & 0xff);
  247. ths8200_write(sd, THS8200_DTG1_SPEC_G_MSB,
  248. ((htotal(bt)/2) >> 8) & 0x0f);
  249. /* Total pixels per line (ex. 720p: 1650) */
  250. ths8200_write(sd, THS8200_DTG1_TOT_PIXELS_MSB, htotal(bt) >> 8);
  251. ths8200_write(sd, THS8200_DTG1_TOT_PIXELS_LSB, htotal(bt) & 0xff);
  252. /* Frame height and field height */
  253. /* Field height should be programmed higher than frame_size for
  254. * progressive scan formats
  255. */
  256. ths8200_write(sd, THS8200_DTG1_FRAME_FIELD_SZ_MSB,
  257. ((vtotal(bt) >> 4) & 0xf0) + 0x7);
  258. ths8200_write(sd, THS8200_DTG1_FRAME_SZ_LSB, vtotal(bt) & 0xff);
  259. /* Should be programmed higher than frame_size
  260. * for progressive formats
  261. */
  262. if (!bt->interlaced)
  263. ths8200_write(sd, THS8200_DTG1_FIELD_SZ_LSB, 0xff);
  264. /**** Display Timing Generator Control, Part 2 (DTG2). ****/
  265. /* Set breakpoint line numbers and types
  266. * THS8200 generates line types with different properties. A line type
  267. * that sets all the RGB-outputs to zero is used in the blanking areas,
  268. * while a line type that enable the RGB-outputs is used in active video
  269. * area. The line numbers for start of active video, start of front
  270. * porch and after the last line in the frame must be set with the
  271. * corresponding line types.
  272. *
  273. * Line types:
  274. * 0x9 - Full normal sync pulse: Blocks data when dtg1_pass is off.
  275. * Used in blanking area.
  276. * 0x0 - Active video: Video data is always passed. Used in active
  277. * video area.
  278. */
  279. ths8200_write_and_or(sd, THS8200_DTG2_BP1_2_MSB, 0x88,
  280. ((line_start_active_video >> 4) & 0x70) +
  281. ((line_start_front_porch >> 8) & 0x07));
  282. ths8200_write(sd, THS8200_DTG2_BP3_4_MSB, ((vtotal(bt)) >> 4) & 0x70);
  283. ths8200_write(sd, THS8200_DTG2_BP1_LSB, line_start_active_video & 0xff);
  284. ths8200_write(sd, THS8200_DTG2_BP2_LSB, line_start_front_porch & 0xff);
  285. ths8200_write(sd, THS8200_DTG2_BP3_LSB, (vtotal(bt)) & 0xff);
  286. /* line types */
  287. ths8200_write(sd, THS8200_DTG2_LINETYPE1, 0x90);
  288. ths8200_write(sd, THS8200_DTG2_LINETYPE2, 0x90);
  289. /* h sync width transmitted */
  290. ths8200_write(sd, THS8200_DTG2_HLENGTH_LSB, bt->hsync & 0xff);
  291. ths8200_write_and_or(sd, THS8200_DTG2_HLENGTH_LSB_HDLY_MSB, 0x3f,
  292. (bt->hsync >> 2) & 0xc0);
  293. /* The pixel value h sync is asserted on */
  294. ths8200_write_and_or(sd, THS8200_DTG2_HLENGTH_LSB_HDLY_MSB, 0xe0,
  295. (htotal(bt) >> 8) & 0x1f);
  296. ths8200_write(sd, THS8200_DTG2_HLENGTH_HDLY_LSB, htotal(bt));
  297. /* v sync width transmitted */
  298. ths8200_write(sd, THS8200_DTG2_VLENGTH1_LSB, (bt->vsync) & 0xff);
  299. ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0x3f,
  300. ((bt->vsync) >> 2) & 0xc0);
  301. /* The pixel value v sync is asserted on */
  302. ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0xf8,
  303. (vtotal(bt)>>8) & 0x7);
  304. ths8200_write(sd, THS8200_DTG2_VDLY1_LSB, vtotal(bt));
  305. /* For progressive video vlength2 must be set to all 0 and vdly2 must
  306. * be set to all 1.
  307. */
  308. ths8200_write(sd, THS8200_DTG2_VLENGTH2_LSB, 0x00);
  309. ths8200_write(sd, THS8200_DTG2_VLENGTH2_MSB_VDLY2_MSB, 0x07);
  310. ths8200_write(sd, THS8200_DTG2_VDLY2_LSB, 0xff);
  311. /* Internal delay factors to synchronize the sync pulses and the data */
  312. /* Experimental values delays (hor 4, ver 1) */
  313. ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_MSB, (htotal(bt)>>8) & 0x1f);
  314. ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_LSB, (htotal(bt) - 4) & 0xff);
  315. ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_MSB, 0);
  316. ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_LSB, 1);
  317. /* Polarity of received and transmitted sync signals */
  318. if (bt->polarities & V4L2_DV_HSYNC_POS_POL) {
  319. polarity |= 0x01; /* HS_IN */
  320. polarity |= 0x08; /* HS_OUT */
  321. }
  322. if (bt->polarities & V4L2_DV_VSYNC_POS_POL) {
  323. polarity |= 0x02; /* VS_IN */
  324. polarity |= 0x10; /* VS_OUT */
  325. }
  326. /* RGB mode, no embedded timings */
  327. /* Timing of video input bus is derived from HS, VS, and FID dedicated
  328. * inputs
  329. */
  330. ths8200_write(sd, THS8200_DTG2_CNTL, 0x47 | polarity);
  331. /* leave reset */
  332. ths8200_s_stream(sd, true);
  333. v4l2_dbg(1, debug, sd, "%s: frame %dx%d, polarity %d\n"
  334. "horizontal: front porch %d, back porch %d, sync %d\n"
  335. "vertical: sync %d\n", __func__, htotal(bt), vtotal(bt),
  336. polarity, bt->hfrontporch, bt->hbackporch,
  337. bt->hsync, bt->vsync);
  338. }
  339. static int ths8200_s_dv_timings(struct v4l2_subdev *sd,
  340. struct v4l2_dv_timings *timings)
  341. {
  342. struct ths8200_state *state = to_state(sd);
  343. int i;
  344. v4l2_dbg(1, debug, sd, "%s:\n", __func__);
  345. if (timings->type != V4L2_DV_BT_656_1120)
  346. return -EINVAL;
  347. /* TODO Support interlaced formats */
  348. if (timings->bt.interlaced) {
  349. v4l2_dbg(1, debug, sd, "TODO Support interlaced formats\n");
  350. return -EINVAL;
  351. }
  352. for (i = 0; i < ARRAY_SIZE(ths8200_timings); i++) {
  353. if (v4l_match_dv_timings(&ths8200_timings[i], timings, 10))
  354. break;
  355. }
  356. if (i == ARRAY_SIZE(ths8200_timings)) {
  357. v4l2_dbg(1, debug, sd, "Unsupported format\n");
  358. return -EINVAL;
  359. }
  360. timings->bt.flags &= ~V4L2_DV_FL_REDUCED_FPS;
  361. /* save timings */
  362. state->dv_timings = *timings;
  363. ths8200_setup(sd, &timings->bt);
  364. return 0;
  365. }
  366. static int ths8200_g_dv_timings(struct v4l2_subdev *sd,
  367. struct v4l2_dv_timings *timings)
  368. {
  369. struct ths8200_state *state = to_state(sd);
  370. v4l2_dbg(1, debug, sd, "%s:\n", __func__);
  371. *timings = state->dv_timings;
  372. return 0;
  373. }
  374. static int ths8200_enum_dv_timings(struct v4l2_subdev *sd,
  375. struct v4l2_enum_dv_timings *timings)
  376. {
  377. /* Check requested format index is within range */
  378. if (timings->index >= ARRAY_SIZE(ths8200_timings))
  379. return -EINVAL;
  380. timings->timings = ths8200_timings[timings->index];
  381. return 0;
  382. }
  383. static int ths8200_dv_timings_cap(struct v4l2_subdev *sd,
  384. struct v4l2_dv_timings_cap *cap)
  385. {
  386. cap->type = V4L2_DV_BT_656_1120;
  387. cap->bt.max_width = 1920;
  388. cap->bt.max_height = 1080;
  389. cap->bt.min_pixelclock = 27000000;
  390. cap->bt.max_pixelclock = 148500000;
  391. cap->bt.standards = V4L2_DV_BT_STD_CEA861;
  392. cap->bt.capabilities = V4L2_DV_BT_CAP_PROGRESSIVE;
  393. return 0;
  394. }
  395. /* Specific video subsystem operation handlers */
  396. static const struct v4l2_subdev_video_ops ths8200_video_ops = {
  397. .s_stream = ths8200_s_stream,
  398. .s_dv_timings = ths8200_s_dv_timings,
  399. .g_dv_timings = ths8200_g_dv_timings,
  400. .enum_dv_timings = ths8200_enum_dv_timings,
  401. .dv_timings_cap = ths8200_dv_timings_cap,
  402. };
  403. /* V4L2 top level operation handlers */
  404. static const struct v4l2_subdev_ops ths8200_ops = {
  405. .core = &ths8200_core_ops,
  406. .video = &ths8200_video_ops,
  407. };
  408. static int ths8200_probe(struct i2c_client *client,
  409. const struct i2c_device_id *id)
  410. {
  411. struct ths8200_state *state;
  412. struct v4l2_subdev *sd;
  413. int error;
  414. /* Check if the adapter supports the needed features */
  415. if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
  416. return -EIO;
  417. state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
  418. if (!state)
  419. return -ENOMEM;
  420. sd = &state->sd;
  421. v4l2_i2c_subdev_init(sd, client, &ths8200_ops);
  422. state->chip_version = ths8200_read(sd, THS8200_VERSION);
  423. v4l2_dbg(1, debug, sd, "chip version 0x%x\n", state->chip_version);
  424. ths8200_core_init(sd);
  425. error = v4l2_async_register_subdev(&state->sd);
  426. if (error)
  427. return error;
  428. v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
  429. client->addr << 1, client->adapter->name);
  430. return 0;
  431. }
  432. static int ths8200_remove(struct i2c_client *client)
  433. {
  434. struct v4l2_subdev *sd = i2c_get_clientdata(client);
  435. struct ths8200_state *decoder = to_state(sd);
  436. v4l2_dbg(1, debug, sd, "%s removed @ 0x%x (%s)\n", client->name,
  437. client->addr << 1, client->adapter->name);
  438. ths8200_s_power(sd, false);
  439. v4l2_async_unregister_subdev(&decoder->sd);
  440. v4l2_device_unregister_subdev(sd);
  441. return 0;
  442. }
  443. static struct i2c_device_id ths8200_id[] = {
  444. { "ths8200", 0 },
  445. {},
  446. };
  447. MODULE_DEVICE_TABLE(i2c, ths8200_id);
  448. #if IS_ENABLED(CONFIG_OF)
  449. static const struct of_device_id ths8200_of_match[] = {
  450. { .compatible = "ti,ths8200", },
  451. { /* sentinel */ },
  452. };
  453. MODULE_DEVICE_TABLE(of, ths8200_of_match);
  454. #endif
  455. static struct i2c_driver ths8200_driver = {
  456. .driver = {
  457. .owner = THIS_MODULE,
  458. .name = "ths8200",
  459. .of_match_table = of_match_ptr(ths8200_of_match),
  460. },
  461. .probe = ths8200_probe,
  462. .remove = ths8200_remove,
  463. .id_table = ths8200_id,
  464. };
  465. module_i2c_driver(ths8200_driver);