ov13858.c 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (c) 2017 Intel Corporation.
  3. #include <linux/acpi.h>
  4. #include <linux/i2c.h>
  5. #include <linux/module.h>
  6. #include <linux/pm_runtime.h>
  7. #include <media/v4l2-ctrls.h>
  8. #include <media/v4l2-device.h>
  9. #include <media/v4l2-event.h>
  10. #include <media/v4l2-fwnode.h>
  11. #define OV13858_REG_VALUE_08BIT 1
  12. #define OV13858_REG_VALUE_16BIT 2
  13. #define OV13858_REG_VALUE_24BIT 3
  14. #define OV13858_REG_MODE_SELECT 0x0100
  15. #define OV13858_MODE_STANDBY 0x00
  16. #define OV13858_MODE_STREAMING 0x01
  17. #define OV13858_REG_SOFTWARE_RST 0x0103
  18. #define OV13858_SOFTWARE_RST 0x01
  19. /* PLL1 generates PCLK and MIPI_PHY_CLK */
  20. #define OV13858_REG_PLL1_CTRL_0 0x0300
  21. #define OV13858_REG_PLL1_CTRL_1 0x0301
  22. #define OV13858_REG_PLL1_CTRL_2 0x0302
  23. #define OV13858_REG_PLL1_CTRL_3 0x0303
  24. #define OV13858_REG_PLL1_CTRL_4 0x0304
  25. #define OV13858_REG_PLL1_CTRL_5 0x0305
  26. /* PLL2 generates DAC_CLK, SCLK and SRAM_CLK */
  27. #define OV13858_REG_PLL2_CTRL_B 0x030b
  28. #define OV13858_REG_PLL2_CTRL_C 0x030c
  29. #define OV13858_REG_PLL2_CTRL_D 0x030d
  30. #define OV13858_REG_PLL2_CTRL_E 0x030e
  31. #define OV13858_REG_PLL2_CTRL_F 0x030f
  32. #define OV13858_REG_PLL2_CTRL_12 0x0312
  33. #define OV13858_REG_MIPI_SC_CTRL0 0x3016
  34. #define OV13858_REG_MIPI_SC_CTRL1 0x3022
  35. /* Chip ID */
  36. #define OV13858_REG_CHIP_ID 0x300a
  37. #define OV13858_CHIP_ID 0x00d855
  38. /* V_TIMING internal */
  39. #define OV13858_REG_VTS 0x380e
  40. #define OV13858_VTS_30FPS 0x0c8e /* 30 fps */
  41. #define OV13858_VTS_60FPS 0x0648 /* 60 fps */
  42. #define OV13858_VTS_MAX 0x7fff
  43. /* HBLANK control - read only */
  44. #define OV13858_PPL_270MHZ 2244
  45. #define OV13858_PPL_540MHZ 4488
  46. /* Exposure control */
  47. #define OV13858_REG_EXPOSURE 0x3500
  48. #define OV13858_EXPOSURE_MIN 4
  49. #define OV13858_EXPOSURE_STEP 1
  50. #define OV13858_EXPOSURE_DEFAULT 0x640
  51. /* Analog gain control */
  52. #define OV13858_REG_ANALOG_GAIN 0x3508
  53. #define OV13858_ANA_GAIN_MIN 0
  54. #define OV13858_ANA_GAIN_MAX 0x1fff
  55. #define OV13858_ANA_GAIN_STEP 1
  56. #define OV13858_ANA_GAIN_DEFAULT 0x80
  57. /* Digital gain control */
  58. #define OV13858_REG_B_MWB_GAIN 0x5100
  59. #define OV13858_REG_G_MWB_GAIN 0x5102
  60. #define OV13858_REG_R_MWB_GAIN 0x5104
  61. #define OV13858_DGTL_GAIN_MIN 0
  62. #define OV13858_DGTL_GAIN_MAX 16384 /* Max = 16 X */
  63. #define OV13858_DGTL_GAIN_DEFAULT 1024 /* Default gain = 1 X */
  64. #define OV13858_DGTL_GAIN_STEP 1 /* Each step = 1/1024 */
  65. /* Test Pattern Control */
  66. #define OV13858_REG_TEST_PATTERN 0x4503
  67. #define OV13858_TEST_PATTERN_ENABLE BIT(7)
  68. #define OV13858_TEST_PATTERN_MASK 0xfc
  69. /* Number of frames to skip */
  70. #define OV13858_NUM_OF_SKIP_FRAMES 2
  71. struct ov13858_reg {
  72. u16 address;
  73. u8 val;
  74. };
  75. struct ov13858_reg_list {
  76. u32 num_of_regs;
  77. const struct ov13858_reg *regs;
  78. };
  79. /* Link frequency config */
  80. struct ov13858_link_freq_config {
  81. u32 pixels_per_line;
  82. /* PLL registers for this link frequency */
  83. struct ov13858_reg_list reg_list;
  84. };
  85. /* Mode : resolution and related config&values */
  86. struct ov13858_mode {
  87. /* Frame width */
  88. u32 width;
  89. /* Frame height */
  90. u32 height;
  91. /* V-timing */
  92. u32 vts_def;
  93. u32 vts_min;
  94. /* Index of Link frequency config to be used */
  95. u32 link_freq_index;
  96. /* Default register values */
  97. struct ov13858_reg_list reg_list;
  98. };
  99. /* 4224x3136 needs 1080Mbps/lane, 4 lanes */
  100. static const struct ov13858_reg mipi_data_rate_1080mbps[] = {
  101. /* PLL1 registers */
  102. {OV13858_REG_PLL1_CTRL_0, 0x07},
  103. {OV13858_REG_PLL1_CTRL_1, 0x01},
  104. {OV13858_REG_PLL1_CTRL_2, 0xc2},
  105. {OV13858_REG_PLL1_CTRL_3, 0x00},
  106. {OV13858_REG_PLL1_CTRL_4, 0x00},
  107. {OV13858_REG_PLL1_CTRL_5, 0x01},
  108. /* PLL2 registers */
  109. {OV13858_REG_PLL2_CTRL_B, 0x05},
  110. {OV13858_REG_PLL2_CTRL_C, 0x01},
  111. {OV13858_REG_PLL2_CTRL_D, 0x0e},
  112. {OV13858_REG_PLL2_CTRL_E, 0x05},
  113. {OV13858_REG_PLL2_CTRL_F, 0x01},
  114. {OV13858_REG_PLL2_CTRL_12, 0x01},
  115. {OV13858_REG_MIPI_SC_CTRL0, 0x72},
  116. {OV13858_REG_MIPI_SC_CTRL1, 0x01},
  117. };
  118. /*
  119. * 2112x1568, 2112x1188, 1056x784 need 540Mbps/lane,
  120. * 4 lanes
  121. */
  122. static const struct ov13858_reg mipi_data_rate_540mbps[] = {
  123. /* PLL1 registers */
  124. {OV13858_REG_PLL1_CTRL_0, 0x07},
  125. {OV13858_REG_PLL1_CTRL_1, 0x01},
  126. {OV13858_REG_PLL1_CTRL_2, 0xc2},
  127. {OV13858_REG_PLL1_CTRL_3, 0x01},
  128. {OV13858_REG_PLL1_CTRL_4, 0x00},
  129. {OV13858_REG_PLL1_CTRL_5, 0x01},
  130. /* PLL2 registers */
  131. {OV13858_REG_PLL2_CTRL_B, 0x05},
  132. {OV13858_REG_PLL2_CTRL_C, 0x01},
  133. {OV13858_REG_PLL2_CTRL_D, 0x0e},
  134. {OV13858_REG_PLL2_CTRL_E, 0x05},
  135. {OV13858_REG_PLL2_CTRL_F, 0x01},
  136. {OV13858_REG_PLL2_CTRL_12, 0x01},
  137. {OV13858_REG_MIPI_SC_CTRL0, 0x72},
  138. {OV13858_REG_MIPI_SC_CTRL1, 0x01},
  139. };
  140. static const struct ov13858_reg mode_4224x3136_regs[] = {
  141. {0x3013, 0x32},
  142. {0x301b, 0xf0},
  143. {0x301f, 0xd0},
  144. {0x3106, 0x15},
  145. {0x3107, 0x23},
  146. {0x350a, 0x00},
  147. {0x350e, 0x00},
  148. {0x3510, 0x00},
  149. {0x3511, 0x02},
  150. {0x3512, 0x00},
  151. {0x3600, 0x2b},
  152. {0x3601, 0x52},
  153. {0x3602, 0x60},
  154. {0x3612, 0x05},
  155. {0x3613, 0xa4},
  156. {0x3620, 0x80},
  157. {0x3621, 0x10},
  158. {0x3622, 0x30},
  159. {0x3624, 0x1c},
  160. {0x3640, 0x10},
  161. {0x3641, 0x70},
  162. {0x3660, 0x04},
  163. {0x3661, 0x80},
  164. {0x3662, 0x12},
  165. {0x3664, 0x73},
  166. {0x3665, 0xa7},
  167. {0x366e, 0xff},
  168. {0x366f, 0xf4},
  169. {0x3674, 0x00},
  170. {0x3679, 0x0c},
  171. {0x367f, 0x01},
  172. {0x3680, 0x0c},
  173. {0x3681, 0x50},
  174. {0x3682, 0x50},
  175. {0x3683, 0xa9},
  176. {0x3684, 0xa9},
  177. {0x3709, 0x5f},
  178. {0x3714, 0x24},
  179. {0x371a, 0x3e},
  180. {0x3737, 0x04},
  181. {0x3738, 0xcc},
  182. {0x3739, 0x12},
  183. {0x373d, 0x26},
  184. {0x3764, 0x20},
  185. {0x3765, 0x20},
  186. {0x37a1, 0x36},
  187. {0x37a8, 0x3b},
  188. {0x37ab, 0x31},
  189. {0x37c2, 0x04},
  190. {0x37c3, 0xf1},
  191. {0x37c5, 0x00},
  192. {0x37d8, 0x03},
  193. {0x37d9, 0x0c},
  194. {0x37da, 0xc2},
  195. {0x37dc, 0x02},
  196. {0x37e0, 0x00},
  197. {0x37e1, 0x0a},
  198. {0x37e2, 0x14},
  199. {0x37e3, 0x04},
  200. {0x37e4, 0x2a},
  201. {0x37e5, 0x03},
  202. {0x37e6, 0x04},
  203. {0x3800, 0x00},
  204. {0x3801, 0x00},
  205. {0x3802, 0x00},
  206. {0x3803, 0x08},
  207. {0x3804, 0x10},
  208. {0x3805, 0x9f},
  209. {0x3806, 0x0c},
  210. {0x3807, 0x57},
  211. {0x3808, 0x10},
  212. {0x3809, 0x80},
  213. {0x380a, 0x0c},
  214. {0x380b, 0x40},
  215. {0x380c, 0x04},
  216. {0x380d, 0x62},
  217. {0x380e, 0x0c},
  218. {0x380f, 0x8e},
  219. {0x3811, 0x04},
  220. {0x3813, 0x05},
  221. {0x3814, 0x01},
  222. {0x3815, 0x01},
  223. {0x3816, 0x01},
  224. {0x3817, 0x01},
  225. {0x3820, 0xa8},
  226. {0x3821, 0x00},
  227. {0x3822, 0xc2},
  228. {0x3823, 0x18},
  229. {0x3826, 0x11},
  230. {0x3827, 0x1c},
  231. {0x3829, 0x03},
  232. {0x3832, 0x00},
  233. {0x3c80, 0x00},
  234. {0x3c87, 0x01},
  235. {0x3c8c, 0x19},
  236. {0x3c8d, 0x1c},
  237. {0x3c90, 0x00},
  238. {0x3c91, 0x00},
  239. {0x3c92, 0x00},
  240. {0x3c93, 0x00},
  241. {0x3c94, 0x40},
  242. {0x3c95, 0x54},
  243. {0x3c96, 0x34},
  244. {0x3c97, 0x04},
  245. {0x3c98, 0x00},
  246. {0x3d8c, 0x73},
  247. {0x3d8d, 0xc0},
  248. {0x3f00, 0x0b},
  249. {0x3f03, 0x00},
  250. {0x4001, 0xe0},
  251. {0x4008, 0x00},
  252. {0x4009, 0x0f},
  253. {0x4011, 0xf0},
  254. {0x4017, 0x08},
  255. {0x4050, 0x04},
  256. {0x4051, 0x0b},
  257. {0x4052, 0x00},
  258. {0x4053, 0x80},
  259. {0x4054, 0x00},
  260. {0x4055, 0x80},
  261. {0x4056, 0x00},
  262. {0x4057, 0x80},
  263. {0x4058, 0x00},
  264. {0x4059, 0x80},
  265. {0x405e, 0x20},
  266. {0x4500, 0x07},
  267. {0x4503, 0x00},
  268. {0x450a, 0x04},
  269. {0x4809, 0x04},
  270. {0x480c, 0x12},
  271. {0x481f, 0x30},
  272. {0x4833, 0x10},
  273. {0x4837, 0x0e},
  274. {0x4902, 0x01},
  275. {0x4d00, 0x03},
  276. {0x4d01, 0xc9},
  277. {0x4d02, 0xbc},
  278. {0x4d03, 0xd7},
  279. {0x4d04, 0xf0},
  280. {0x4d05, 0xa2},
  281. {0x5000, 0xfd},
  282. {0x5001, 0x01},
  283. {0x5040, 0x39},
  284. {0x5041, 0x10},
  285. {0x5042, 0x10},
  286. {0x5043, 0x84},
  287. {0x5044, 0x62},
  288. {0x5180, 0x00},
  289. {0x5181, 0x10},
  290. {0x5182, 0x02},
  291. {0x5183, 0x0f},
  292. {0x5200, 0x1b},
  293. {0x520b, 0x07},
  294. {0x520c, 0x0f},
  295. {0x5300, 0x04},
  296. {0x5301, 0x0c},
  297. {0x5302, 0x0c},
  298. {0x5303, 0x0f},
  299. {0x5304, 0x00},
  300. {0x5305, 0x70},
  301. {0x5306, 0x00},
  302. {0x5307, 0x80},
  303. {0x5308, 0x00},
  304. {0x5309, 0xa5},
  305. {0x530a, 0x00},
  306. {0x530b, 0xd3},
  307. {0x530c, 0x00},
  308. {0x530d, 0xf0},
  309. {0x530e, 0x01},
  310. {0x530f, 0x10},
  311. {0x5310, 0x01},
  312. {0x5311, 0x20},
  313. {0x5312, 0x01},
  314. {0x5313, 0x20},
  315. {0x5314, 0x01},
  316. {0x5315, 0x20},
  317. {0x5316, 0x08},
  318. {0x5317, 0x08},
  319. {0x5318, 0x10},
  320. {0x5319, 0x88},
  321. {0x531a, 0x88},
  322. {0x531b, 0xa9},
  323. {0x531c, 0xaa},
  324. {0x531d, 0x0a},
  325. {0x5405, 0x02},
  326. {0x5406, 0x67},
  327. {0x5407, 0x01},
  328. {0x5408, 0x4a},
  329. };
  330. static const struct ov13858_reg mode_2112x1568_regs[] = {
  331. {0x3013, 0x32},
  332. {0x301b, 0xf0},
  333. {0x301f, 0xd0},
  334. {0x3106, 0x15},
  335. {0x3107, 0x23},
  336. {0x350a, 0x00},
  337. {0x350e, 0x00},
  338. {0x3510, 0x00},
  339. {0x3511, 0x02},
  340. {0x3512, 0x00},
  341. {0x3600, 0x2b},
  342. {0x3601, 0x52},
  343. {0x3602, 0x60},
  344. {0x3612, 0x05},
  345. {0x3613, 0xa4},
  346. {0x3620, 0x80},
  347. {0x3621, 0x10},
  348. {0x3622, 0x30},
  349. {0x3624, 0x1c},
  350. {0x3640, 0x10},
  351. {0x3641, 0x70},
  352. {0x3660, 0x04},
  353. {0x3661, 0x80},
  354. {0x3662, 0x10},
  355. {0x3664, 0x73},
  356. {0x3665, 0xa7},
  357. {0x366e, 0xff},
  358. {0x366f, 0xf4},
  359. {0x3674, 0x00},
  360. {0x3679, 0x0c},
  361. {0x367f, 0x01},
  362. {0x3680, 0x0c},
  363. {0x3681, 0x50},
  364. {0x3682, 0x50},
  365. {0x3683, 0xa9},
  366. {0x3684, 0xa9},
  367. {0x3709, 0x5f},
  368. {0x3714, 0x28},
  369. {0x371a, 0x3e},
  370. {0x3737, 0x08},
  371. {0x3738, 0xcc},
  372. {0x3739, 0x20},
  373. {0x373d, 0x26},
  374. {0x3764, 0x20},
  375. {0x3765, 0x20},
  376. {0x37a1, 0x36},
  377. {0x37a8, 0x3b},
  378. {0x37ab, 0x31},
  379. {0x37c2, 0x14},
  380. {0x37c3, 0xf1},
  381. {0x37c5, 0x00},
  382. {0x37d8, 0x03},
  383. {0x37d9, 0x0c},
  384. {0x37da, 0xc2},
  385. {0x37dc, 0x02},
  386. {0x37e0, 0x00},
  387. {0x37e1, 0x0a},
  388. {0x37e2, 0x14},
  389. {0x37e3, 0x08},
  390. {0x37e4, 0x38},
  391. {0x37e5, 0x03},
  392. {0x37e6, 0x08},
  393. {0x3800, 0x00},
  394. {0x3801, 0x00},
  395. {0x3802, 0x00},
  396. {0x3803, 0x00},
  397. {0x3804, 0x10},
  398. {0x3805, 0x9f},
  399. {0x3806, 0x0c},
  400. {0x3807, 0x5f},
  401. {0x3808, 0x08},
  402. {0x3809, 0x40},
  403. {0x380a, 0x06},
  404. {0x380b, 0x20},
  405. {0x380c, 0x04},
  406. {0x380d, 0x62},
  407. {0x380e, 0x0c},
  408. {0x380f, 0x8e},
  409. {0x3811, 0x04},
  410. {0x3813, 0x05},
  411. {0x3814, 0x03},
  412. {0x3815, 0x01},
  413. {0x3816, 0x03},
  414. {0x3817, 0x01},
  415. {0x3820, 0xab},
  416. {0x3821, 0x00},
  417. {0x3822, 0xc2},
  418. {0x3823, 0x18},
  419. {0x3826, 0x04},
  420. {0x3827, 0x90},
  421. {0x3829, 0x07},
  422. {0x3832, 0x00},
  423. {0x3c80, 0x00},
  424. {0x3c87, 0x01},
  425. {0x3c8c, 0x19},
  426. {0x3c8d, 0x1c},
  427. {0x3c90, 0x00},
  428. {0x3c91, 0x00},
  429. {0x3c92, 0x00},
  430. {0x3c93, 0x00},
  431. {0x3c94, 0x40},
  432. {0x3c95, 0x54},
  433. {0x3c96, 0x34},
  434. {0x3c97, 0x04},
  435. {0x3c98, 0x00},
  436. {0x3d8c, 0x73},
  437. {0x3d8d, 0xc0},
  438. {0x3f00, 0x0b},
  439. {0x3f03, 0x00},
  440. {0x4001, 0xe0},
  441. {0x4008, 0x00},
  442. {0x4009, 0x0d},
  443. {0x4011, 0xf0},
  444. {0x4017, 0x08},
  445. {0x4050, 0x04},
  446. {0x4051, 0x0b},
  447. {0x4052, 0x00},
  448. {0x4053, 0x80},
  449. {0x4054, 0x00},
  450. {0x4055, 0x80},
  451. {0x4056, 0x00},
  452. {0x4057, 0x80},
  453. {0x4058, 0x00},
  454. {0x4059, 0x80},
  455. {0x405e, 0x20},
  456. {0x4500, 0x07},
  457. {0x4503, 0x00},
  458. {0x450a, 0x04},
  459. {0x4809, 0x04},
  460. {0x480c, 0x12},
  461. {0x481f, 0x30},
  462. {0x4833, 0x10},
  463. {0x4837, 0x1c},
  464. {0x4902, 0x01},
  465. {0x4d00, 0x03},
  466. {0x4d01, 0xc9},
  467. {0x4d02, 0xbc},
  468. {0x4d03, 0xd7},
  469. {0x4d04, 0xf0},
  470. {0x4d05, 0xa2},
  471. {0x5000, 0xfd},
  472. {0x5001, 0x01},
  473. {0x5040, 0x39},
  474. {0x5041, 0x10},
  475. {0x5042, 0x10},
  476. {0x5043, 0x84},
  477. {0x5044, 0x62},
  478. {0x5180, 0x00},
  479. {0x5181, 0x10},
  480. {0x5182, 0x02},
  481. {0x5183, 0x0f},
  482. {0x5200, 0x1b},
  483. {0x520b, 0x07},
  484. {0x520c, 0x0f},
  485. {0x5300, 0x04},
  486. {0x5301, 0x0c},
  487. {0x5302, 0x0c},
  488. {0x5303, 0x0f},
  489. {0x5304, 0x00},
  490. {0x5305, 0x70},
  491. {0x5306, 0x00},
  492. {0x5307, 0x80},
  493. {0x5308, 0x00},
  494. {0x5309, 0xa5},
  495. {0x530a, 0x00},
  496. {0x530b, 0xd3},
  497. {0x530c, 0x00},
  498. {0x530d, 0xf0},
  499. {0x530e, 0x01},
  500. {0x530f, 0x10},
  501. {0x5310, 0x01},
  502. {0x5311, 0x20},
  503. {0x5312, 0x01},
  504. {0x5313, 0x20},
  505. {0x5314, 0x01},
  506. {0x5315, 0x20},
  507. {0x5316, 0x08},
  508. {0x5317, 0x08},
  509. {0x5318, 0x10},
  510. {0x5319, 0x88},
  511. {0x531a, 0x88},
  512. {0x531b, 0xa9},
  513. {0x531c, 0xaa},
  514. {0x531d, 0x0a},
  515. {0x5405, 0x02},
  516. {0x5406, 0x67},
  517. {0x5407, 0x01},
  518. {0x5408, 0x4a},
  519. };
  520. static const struct ov13858_reg mode_2112x1188_regs[] = {
  521. {0x3013, 0x32},
  522. {0x301b, 0xf0},
  523. {0x301f, 0xd0},
  524. {0x3106, 0x15},
  525. {0x3107, 0x23},
  526. {0x350a, 0x00},
  527. {0x350e, 0x00},
  528. {0x3510, 0x00},
  529. {0x3511, 0x02},
  530. {0x3512, 0x00},
  531. {0x3600, 0x2b},
  532. {0x3601, 0x52},
  533. {0x3602, 0x60},
  534. {0x3612, 0x05},
  535. {0x3613, 0xa4},
  536. {0x3620, 0x80},
  537. {0x3621, 0x10},
  538. {0x3622, 0x30},
  539. {0x3624, 0x1c},
  540. {0x3640, 0x10},
  541. {0x3641, 0x70},
  542. {0x3660, 0x04},
  543. {0x3661, 0x80},
  544. {0x3662, 0x10},
  545. {0x3664, 0x73},
  546. {0x3665, 0xa7},
  547. {0x366e, 0xff},
  548. {0x366f, 0xf4},
  549. {0x3674, 0x00},
  550. {0x3679, 0x0c},
  551. {0x367f, 0x01},
  552. {0x3680, 0x0c},
  553. {0x3681, 0x50},
  554. {0x3682, 0x50},
  555. {0x3683, 0xa9},
  556. {0x3684, 0xa9},
  557. {0x3709, 0x5f},
  558. {0x3714, 0x28},
  559. {0x371a, 0x3e},
  560. {0x3737, 0x08},
  561. {0x3738, 0xcc},
  562. {0x3739, 0x20},
  563. {0x373d, 0x26},
  564. {0x3764, 0x20},
  565. {0x3765, 0x20},
  566. {0x37a1, 0x36},
  567. {0x37a8, 0x3b},
  568. {0x37ab, 0x31},
  569. {0x37c2, 0x14},
  570. {0x37c3, 0xf1},
  571. {0x37c5, 0x00},
  572. {0x37d8, 0x03},
  573. {0x37d9, 0x0c},
  574. {0x37da, 0xc2},
  575. {0x37dc, 0x02},
  576. {0x37e0, 0x00},
  577. {0x37e1, 0x0a},
  578. {0x37e2, 0x14},
  579. {0x37e3, 0x08},
  580. {0x37e4, 0x38},
  581. {0x37e5, 0x03},
  582. {0x37e6, 0x08},
  583. {0x3800, 0x00},
  584. {0x3801, 0x00},
  585. {0x3802, 0x01},
  586. {0x3803, 0x84},
  587. {0x3804, 0x10},
  588. {0x3805, 0x9f},
  589. {0x3806, 0x0a},
  590. {0x3807, 0xd3},
  591. {0x3808, 0x08},
  592. {0x3809, 0x40},
  593. {0x380a, 0x04},
  594. {0x380b, 0xa4},
  595. {0x380c, 0x04},
  596. {0x380d, 0x62},
  597. {0x380e, 0x0c},
  598. {0x380f, 0x8e},
  599. {0x3811, 0x08},
  600. {0x3813, 0x03},
  601. {0x3814, 0x03},
  602. {0x3815, 0x01},
  603. {0x3816, 0x03},
  604. {0x3817, 0x01},
  605. {0x3820, 0xab},
  606. {0x3821, 0x00},
  607. {0x3822, 0xc2},
  608. {0x3823, 0x18},
  609. {0x3826, 0x04},
  610. {0x3827, 0x90},
  611. {0x3829, 0x07},
  612. {0x3832, 0x00},
  613. {0x3c80, 0x00},
  614. {0x3c87, 0x01},
  615. {0x3c8c, 0x19},
  616. {0x3c8d, 0x1c},
  617. {0x3c90, 0x00},
  618. {0x3c91, 0x00},
  619. {0x3c92, 0x00},
  620. {0x3c93, 0x00},
  621. {0x3c94, 0x40},
  622. {0x3c95, 0x54},
  623. {0x3c96, 0x34},
  624. {0x3c97, 0x04},
  625. {0x3c98, 0x00},
  626. {0x3d8c, 0x73},
  627. {0x3d8d, 0xc0},
  628. {0x3f00, 0x0b},
  629. {0x3f03, 0x00},
  630. {0x4001, 0xe0},
  631. {0x4008, 0x00},
  632. {0x4009, 0x0d},
  633. {0x4011, 0xf0},
  634. {0x4017, 0x08},
  635. {0x4050, 0x04},
  636. {0x4051, 0x0b},
  637. {0x4052, 0x00},
  638. {0x4053, 0x80},
  639. {0x4054, 0x00},
  640. {0x4055, 0x80},
  641. {0x4056, 0x00},
  642. {0x4057, 0x80},
  643. {0x4058, 0x00},
  644. {0x4059, 0x80},
  645. {0x405e, 0x20},
  646. {0x4500, 0x07},
  647. {0x4503, 0x00},
  648. {0x450a, 0x04},
  649. {0x4809, 0x04},
  650. {0x480c, 0x12},
  651. {0x481f, 0x30},
  652. {0x4833, 0x10},
  653. {0x4837, 0x1c},
  654. {0x4902, 0x01},
  655. {0x4d00, 0x03},
  656. {0x4d01, 0xc9},
  657. {0x4d02, 0xbc},
  658. {0x4d03, 0xd7},
  659. {0x4d04, 0xf0},
  660. {0x4d05, 0xa2},
  661. {0x5000, 0xfd},
  662. {0x5001, 0x01},
  663. {0x5040, 0x39},
  664. {0x5041, 0x10},
  665. {0x5042, 0x10},
  666. {0x5043, 0x84},
  667. {0x5044, 0x62},
  668. {0x5180, 0x00},
  669. {0x5181, 0x10},
  670. {0x5182, 0x02},
  671. {0x5183, 0x0f},
  672. {0x5200, 0x1b},
  673. {0x520b, 0x07},
  674. {0x520c, 0x0f},
  675. {0x5300, 0x04},
  676. {0x5301, 0x0c},
  677. {0x5302, 0x0c},
  678. {0x5303, 0x0f},
  679. {0x5304, 0x00},
  680. {0x5305, 0x70},
  681. {0x5306, 0x00},
  682. {0x5307, 0x80},
  683. {0x5308, 0x00},
  684. {0x5309, 0xa5},
  685. {0x530a, 0x00},
  686. {0x530b, 0xd3},
  687. {0x530c, 0x00},
  688. {0x530d, 0xf0},
  689. {0x530e, 0x01},
  690. {0x530f, 0x10},
  691. {0x5310, 0x01},
  692. {0x5311, 0x20},
  693. {0x5312, 0x01},
  694. {0x5313, 0x20},
  695. {0x5314, 0x01},
  696. {0x5315, 0x20},
  697. {0x5316, 0x08},
  698. {0x5317, 0x08},
  699. {0x5318, 0x10},
  700. {0x5319, 0x88},
  701. {0x531a, 0x88},
  702. {0x531b, 0xa9},
  703. {0x531c, 0xaa},
  704. {0x531d, 0x0a},
  705. {0x5405, 0x02},
  706. {0x5406, 0x67},
  707. {0x5407, 0x01},
  708. {0x5408, 0x4a},
  709. };
  710. static const struct ov13858_reg mode_1056x784_regs[] = {
  711. {0x3013, 0x32},
  712. {0x301b, 0xf0},
  713. {0x301f, 0xd0},
  714. {0x3106, 0x15},
  715. {0x3107, 0x23},
  716. {0x350a, 0x00},
  717. {0x350e, 0x00},
  718. {0x3510, 0x00},
  719. {0x3511, 0x02},
  720. {0x3512, 0x00},
  721. {0x3600, 0x2b},
  722. {0x3601, 0x52},
  723. {0x3602, 0x60},
  724. {0x3612, 0x05},
  725. {0x3613, 0xa4},
  726. {0x3620, 0x80},
  727. {0x3621, 0x10},
  728. {0x3622, 0x30},
  729. {0x3624, 0x1c},
  730. {0x3640, 0x10},
  731. {0x3641, 0x70},
  732. {0x3660, 0x04},
  733. {0x3661, 0x80},
  734. {0x3662, 0x08},
  735. {0x3664, 0x73},
  736. {0x3665, 0xa7},
  737. {0x366e, 0xff},
  738. {0x366f, 0xf4},
  739. {0x3674, 0x00},
  740. {0x3679, 0x0c},
  741. {0x367f, 0x01},
  742. {0x3680, 0x0c},
  743. {0x3681, 0x50},
  744. {0x3682, 0x50},
  745. {0x3683, 0xa9},
  746. {0x3684, 0xa9},
  747. {0x3709, 0x5f},
  748. {0x3714, 0x30},
  749. {0x371a, 0x3e},
  750. {0x3737, 0x08},
  751. {0x3738, 0xcc},
  752. {0x3739, 0x20},
  753. {0x373d, 0x26},
  754. {0x3764, 0x20},
  755. {0x3765, 0x20},
  756. {0x37a1, 0x36},
  757. {0x37a8, 0x3b},
  758. {0x37ab, 0x31},
  759. {0x37c2, 0x2c},
  760. {0x37c3, 0xf1},
  761. {0x37c5, 0x00},
  762. {0x37d8, 0x03},
  763. {0x37d9, 0x06},
  764. {0x37da, 0xc2},
  765. {0x37dc, 0x02},
  766. {0x37e0, 0x00},
  767. {0x37e1, 0x0a},
  768. {0x37e2, 0x14},
  769. {0x37e3, 0x08},
  770. {0x37e4, 0x36},
  771. {0x37e5, 0x03},
  772. {0x37e6, 0x08},
  773. {0x3800, 0x00},
  774. {0x3801, 0x00},
  775. {0x3802, 0x00},
  776. {0x3803, 0x00},
  777. {0x3804, 0x10},
  778. {0x3805, 0x9f},
  779. {0x3806, 0x0c},
  780. {0x3807, 0x5f},
  781. {0x3808, 0x04},
  782. {0x3809, 0x20},
  783. {0x380a, 0x03},
  784. {0x380b, 0x10},
  785. {0x380c, 0x04},
  786. {0x380d, 0x62},
  787. {0x380e, 0x0c},
  788. {0x380f, 0x8e},
  789. {0x3811, 0x04},
  790. {0x3813, 0x05},
  791. {0x3814, 0x07},
  792. {0x3815, 0x01},
  793. {0x3816, 0x07},
  794. {0x3817, 0x01},
  795. {0x3820, 0xac},
  796. {0x3821, 0x00},
  797. {0x3822, 0xc2},
  798. {0x3823, 0x18},
  799. {0x3826, 0x04},
  800. {0x3827, 0x48},
  801. {0x3829, 0x03},
  802. {0x3832, 0x00},
  803. {0x3c80, 0x00},
  804. {0x3c87, 0x01},
  805. {0x3c8c, 0x19},
  806. {0x3c8d, 0x1c},
  807. {0x3c90, 0x00},
  808. {0x3c91, 0x00},
  809. {0x3c92, 0x00},
  810. {0x3c93, 0x00},
  811. {0x3c94, 0x40},
  812. {0x3c95, 0x54},
  813. {0x3c96, 0x34},
  814. {0x3c97, 0x04},
  815. {0x3c98, 0x00},
  816. {0x3d8c, 0x73},
  817. {0x3d8d, 0xc0},
  818. {0x3f00, 0x0b},
  819. {0x3f03, 0x00},
  820. {0x4001, 0xe0},
  821. {0x4008, 0x00},
  822. {0x4009, 0x05},
  823. {0x4011, 0xf0},
  824. {0x4017, 0x08},
  825. {0x4050, 0x02},
  826. {0x4051, 0x05},
  827. {0x4052, 0x00},
  828. {0x4053, 0x80},
  829. {0x4054, 0x00},
  830. {0x4055, 0x80},
  831. {0x4056, 0x00},
  832. {0x4057, 0x80},
  833. {0x4058, 0x00},
  834. {0x4059, 0x80},
  835. {0x405e, 0x20},
  836. {0x4500, 0x07},
  837. {0x4503, 0x00},
  838. {0x450a, 0x04},
  839. {0x4809, 0x04},
  840. {0x480c, 0x12},
  841. {0x481f, 0x30},
  842. {0x4833, 0x10},
  843. {0x4837, 0x1e},
  844. {0x4902, 0x02},
  845. {0x4d00, 0x03},
  846. {0x4d01, 0xc9},
  847. {0x4d02, 0xbc},
  848. {0x4d03, 0xd7},
  849. {0x4d04, 0xf0},
  850. {0x4d05, 0xa2},
  851. {0x5000, 0xfd},
  852. {0x5001, 0x01},
  853. {0x5040, 0x39},
  854. {0x5041, 0x10},
  855. {0x5042, 0x10},
  856. {0x5043, 0x84},
  857. {0x5044, 0x62},
  858. {0x5180, 0x00},
  859. {0x5181, 0x10},
  860. {0x5182, 0x02},
  861. {0x5183, 0x0f},
  862. {0x5200, 0x1b},
  863. {0x520b, 0x07},
  864. {0x520c, 0x0f},
  865. {0x5300, 0x04},
  866. {0x5301, 0x0c},
  867. {0x5302, 0x0c},
  868. {0x5303, 0x0f},
  869. {0x5304, 0x00},
  870. {0x5305, 0x70},
  871. {0x5306, 0x00},
  872. {0x5307, 0x80},
  873. {0x5308, 0x00},
  874. {0x5309, 0xa5},
  875. {0x530a, 0x00},
  876. {0x530b, 0xd3},
  877. {0x530c, 0x00},
  878. {0x530d, 0xf0},
  879. {0x530e, 0x01},
  880. {0x530f, 0x10},
  881. {0x5310, 0x01},
  882. {0x5311, 0x20},
  883. {0x5312, 0x01},
  884. {0x5313, 0x20},
  885. {0x5314, 0x01},
  886. {0x5315, 0x20},
  887. {0x5316, 0x08},
  888. {0x5317, 0x08},
  889. {0x5318, 0x10},
  890. {0x5319, 0x88},
  891. {0x531a, 0x88},
  892. {0x531b, 0xa9},
  893. {0x531c, 0xaa},
  894. {0x531d, 0x0a},
  895. {0x5405, 0x02},
  896. {0x5406, 0x67},
  897. {0x5407, 0x01},
  898. {0x5408, 0x4a},
  899. };
  900. static const char * const ov13858_test_pattern_menu[] = {
  901. "Disabled",
  902. "Vertical Color Bar Type 1",
  903. "Vertical Color Bar Type 2",
  904. "Vertical Color Bar Type 3",
  905. "Vertical Color Bar Type 4"
  906. };
  907. /* Configurations for supported link frequencies */
  908. #define OV13858_NUM_OF_LINK_FREQS 2
  909. #define OV13858_LINK_FREQ_540MHZ 540000000ULL
  910. #define OV13858_LINK_FREQ_270MHZ 270000000ULL
  911. #define OV13858_LINK_FREQ_INDEX_0 0
  912. #define OV13858_LINK_FREQ_INDEX_1 1
  913. /*
  914. * pixel_rate = link_freq * data-rate * nr_of_lanes / bits_per_sample
  915. * data rate => double data rate; number of lanes => 4; bits per pixel => 10
  916. */
  917. static u64 link_freq_to_pixel_rate(u64 f)
  918. {
  919. f *= 2 * 4;
  920. do_div(f, 10);
  921. return f;
  922. }
  923. /* Menu items for LINK_FREQ V4L2 control */
  924. static const s64 link_freq_menu_items[OV13858_NUM_OF_LINK_FREQS] = {
  925. OV13858_LINK_FREQ_540MHZ,
  926. OV13858_LINK_FREQ_270MHZ
  927. };
  928. /* Link frequency configs */
  929. static const struct ov13858_link_freq_config
  930. link_freq_configs[OV13858_NUM_OF_LINK_FREQS] = {
  931. {
  932. .pixels_per_line = OV13858_PPL_540MHZ,
  933. .reg_list = {
  934. .num_of_regs = ARRAY_SIZE(mipi_data_rate_1080mbps),
  935. .regs = mipi_data_rate_1080mbps,
  936. }
  937. },
  938. {
  939. .pixels_per_line = OV13858_PPL_270MHZ,
  940. .reg_list = {
  941. .num_of_regs = ARRAY_SIZE(mipi_data_rate_540mbps),
  942. .regs = mipi_data_rate_540mbps,
  943. }
  944. }
  945. };
  946. /* Mode configs */
  947. static const struct ov13858_mode supported_modes[] = {
  948. {
  949. .width = 4224,
  950. .height = 3136,
  951. .vts_def = OV13858_VTS_30FPS,
  952. .vts_min = OV13858_VTS_30FPS,
  953. .reg_list = {
  954. .num_of_regs = ARRAY_SIZE(mode_4224x3136_regs),
  955. .regs = mode_4224x3136_regs,
  956. },
  957. .link_freq_index = OV13858_LINK_FREQ_INDEX_0,
  958. },
  959. {
  960. .width = 2112,
  961. .height = 1568,
  962. .vts_def = OV13858_VTS_30FPS,
  963. .vts_min = 1608,
  964. .reg_list = {
  965. .num_of_regs = ARRAY_SIZE(mode_2112x1568_regs),
  966. .regs = mode_2112x1568_regs,
  967. },
  968. .link_freq_index = OV13858_LINK_FREQ_INDEX_1,
  969. },
  970. {
  971. .width = 2112,
  972. .height = 1188,
  973. .vts_def = OV13858_VTS_30FPS,
  974. .vts_min = 1608,
  975. .reg_list = {
  976. .num_of_regs = ARRAY_SIZE(mode_2112x1188_regs),
  977. .regs = mode_2112x1188_regs,
  978. },
  979. .link_freq_index = OV13858_LINK_FREQ_INDEX_1,
  980. },
  981. {
  982. .width = 1056,
  983. .height = 784,
  984. .vts_def = OV13858_VTS_30FPS,
  985. .vts_min = 804,
  986. .reg_list = {
  987. .num_of_regs = ARRAY_SIZE(mode_1056x784_regs),
  988. .regs = mode_1056x784_regs,
  989. },
  990. .link_freq_index = OV13858_LINK_FREQ_INDEX_1,
  991. }
  992. };
  993. struct ov13858 {
  994. struct v4l2_subdev sd;
  995. struct media_pad pad;
  996. struct v4l2_ctrl_handler ctrl_handler;
  997. /* V4L2 Controls */
  998. struct v4l2_ctrl *link_freq;
  999. struct v4l2_ctrl *pixel_rate;
  1000. struct v4l2_ctrl *vblank;
  1001. struct v4l2_ctrl *hblank;
  1002. struct v4l2_ctrl *exposure;
  1003. /* Current mode */
  1004. const struct ov13858_mode *cur_mode;
  1005. /* Mutex for serialized access */
  1006. struct mutex mutex;
  1007. };
  1008. #define to_ov13858(_sd) container_of(_sd, struct ov13858, sd)
  1009. /* Read registers up to 4 at a time */
  1010. static int ov13858_read_reg(struct ov13858 *ov13858, u16 reg, u32 len,
  1011. u32 *val)
  1012. {
  1013. struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
  1014. struct i2c_msg msgs[2];
  1015. u8 *data_be_p;
  1016. int ret;
  1017. __be32 data_be = 0;
  1018. __be16 reg_addr_be = cpu_to_be16(reg);
  1019. if (len > 4)
  1020. return -EINVAL;
  1021. data_be_p = (u8 *)&data_be;
  1022. /* Write register address */
  1023. msgs[0].addr = client->addr;
  1024. msgs[0].flags = 0;
  1025. msgs[0].len = 2;
  1026. msgs[0].buf = (u8 *)&reg_addr_be;
  1027. /* Read data from register */
  1028. msgs[1].addr = client->addr;
  1029. msgs[1].flags = I2C_M_RD;
  1030. msgs[1].len = len;
  1031. msgs[1].buf = &data_be_p[4 - len];
  1032. ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
  1033. if (ret != ARRAY_SIZE(msgs))
  1034. return -EIO;
  1035. *val = be32_to_cpu(data_be);
  1036. return 0;
  1037. }
  1038. /* Write registers up to 4 at a time */
  1039. static int ov13858_write_reg(struct ov13858 *ov13858, u16 reg, u32 len,
  1040. u32 __val)
  1041. {
  1042. struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
  1043. int buf_i, val_i;
  1044. u8 buf[6], *val_p;
  1045. __be32 val;
  1046. if (len > 4)
  1047. return -EINVAL;
  1048. buf[0] = reg >> 8;
  1049. buf[1] = reg & 0xff;
  1050. val = cpu_to_be32(__val);
  1051. val_p = (u8 *)&val;
  1052. buf_i = 2;
  1053. val_i = 4 - len;
  1054. while (val_i < 4)
  1055. buf[buf_i++] = val_p[val_i++];
  1056. if (i2c_master_send(client, buf, len + 2) != len + 2)
  1057. return -EIO;
  1058. return 0;
  1059. }
  1060. /* Write a list of registers */
  1061. static int ov13858_write_regs(struct ov13858 *ov13858,
  1062. const struct ov13858_reg *regs, u32 len)
  1063. {
  1064. struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
  1065. int ret;
  1066. u32 i;
  1067. for (i = 0; i < len; i++) {
  1068. ret = ov13858_write_reg(ov13858, regs[i].address, 1,
  1069. regs[i].val);
  1070. if (ret) {
  1071. dev_err_ratelimited(
  1072. &client->dev,
  1073. "Failed to write reg 0x%4.4x. error = %d\n",
  1074. regs[i].address, ret);
  1075. return ret;
  1076. }
  1077. }
  1078. return 0;
  1079. }
  1080. static int ov13858_write_reg_list(struct ov13858 *ov13858,
  1081. const struct ov13858_reg_list *r_list)
  1082. {
  1083. return ov13858_write_regs(ov13858, r_list->regs, r_list->num_of_regs);
  1084. }
  1085. /* Open sub-device */
  1086. static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
  1087. {
  1088. struct ov13858 *ov13858 = to_ov13858(sd);
  1089. struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_state_get_format(fh->state,
  1090. 0);
  1091. mutex_lock(&ov13858->mutex);
  1092. /* Initialize try_fmt */
  1093. try_fmt->width = ov13858->cur_mode->width;
  1094. try_fmt->height = ov13858->cur_mode->height;
  1095. try_fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
  1096. try_fmt->field = V4L2_FIELD_NONE;
  1097. /* No crop or compose */
  1098. mutex_unlock(&ov13858->mutex);
  1099. return 0;
  1100. }
  1101. static int ov13858_update_digital_gain(struct ov13858 *ov13858, u32 d_gain)
  1102. {
  1103. int ret;
  1104. ret = ov13858_write_reg(ov13858, OV13858_REG_B_MWB_GAIN,
  1105. OV13858_REG_VALUE_16BIT, d_gain);
  1106. if (ret)
  1107. return ret;
  1108. ret = ov13858_write_reg(ov13858, OV13858_REG_G_MWB_GAIN,
  1109. OV13858_REG_VALUE_16BIT, d_gain);
  1110. if (ret)
  1111. return ret;
  1112. ret = ov13858_write_reg(ov13858, OV13858_REG_R_MWB_GAIN,
  1113. OV13858_REG_VALUE_16BIT, d_gain);
  1114. return ret;
  1115. }
  1116. static int ov13858_enable_test_pattern(struct ov13858 *ov13858, u32 pattern)
  1117. {
  1118. int ret;
  1119. u32 val;
  1120. ret = ov13858_read_reg(ov13858, OV13858_REG_TEST_PATTERN,
  1121. OV13858_REG_VALUE_08BIT, &val);
  1122. if (ret)
  1123. return ret;
  1124. if (pattern) {
  1125. val &= OV13858_TEST_PATTERN_MASK;
  1126. val |= (pattern - 1) | OV13858_TEST_PATTERN_ENABLE;
  1127. } else {
  1128. val &= ~OV13858_TEST_PATTERN_ENABLE;
  1129. }
  1130. return ov13858_write_reg(ov13858, OV13858_REG_TEST_PATTERN,
  1131. OV13858_REG_VALUE_08BIT, val);
  1132. }
  1133. static int ov13858_set_ctrl(struct v4l2_ctrl *ctrl)
  1134. {
  1135. struct ov13858 *ov13858 = container_of(ctrl->handler,
  1136. struct ov13858, ctrl_handler);
  1137. struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
  1138. s64 max;
  1139. int ret;
  1140. /* Propagate change of current control to all related controls */
  1141. switch (ctrl->id) {
  1142. case V4L2_CID_VBLANK:
  1143. /* Update max exposure while meeting expected vblanking */
  1144. max = ov13858->cur_mode->height + ctrl->val - 8;
  1145. __v4l2_ctrl_modify_range(ov13858->exposure,
  1146. ov13858->exposure->minimum,
  1147. max, ov13858->exposure->step, max);
  1148. break;
  1149. }
  1150. /*
  1151. * Applying V4L2 control value only happens
  1152. * when power is up for streaming
  1153. */
  1154. if (!pm_runtime_get_if_in_use(&client->dev))
  1155. return 0;
  1156. ret = 0;
  1157. switch (ctrl->id) {
  1158. case V4L2_CID_ANALOGUE_GAIN:
  1159. ret = ov13858_write_reg(ov13858, OV13858_REG_ANALOG_GAIN,
  1160. OV13858_REG_VALUE_16BIT, ctrl->val);
  1161. break;
  1162. case V4L2_CID_DIGITAL_GAIN:
  1163. ret = ov13858_update_digital_gain(ov13858, ctrl->val);
  1164. break;
  1165. case V4L2_CID_EXPOSURE:
  1166. ret = ov13858_write_reg(ov13858, OV13858_REG_EXPOSURE,
  1167. OV13858_REG_VALUE_24BIT,
  1168. ctrl->val << 4);
  1169. break;
  1170. case V4L2_CID_VBLANK:
  1171. /* Update VTS that meets expected vertical blanking */
  1172. ret = ov13858_write_reg(ov13858, OV13858_REG_VTS,
  1173. OV13858_REG_VALUE_16BIT,
  1174. ov13858->cur_mode->height
  1175. + ctrl->val);
  1176. break;
  1177. case V4L2_CID_TEST_PATTERN:
  1178. ret = ov13858_enable_test_pattern(ov13858, ctrl->val);
  1179. break;
  1180. default:
  1181. dev_info(&client->dev,
  1182. "ctrl(id:0x%x,val:0x%x) is not handled\n",
  1183. ctrl->id, ctrl->val);
  1184. break;
  1185. }
  1186. pm_runtime_put(&client->dev);
  1187. return ret;
  1188. }
  1189. static const struct v4l2_ctrl_ops ov13858_ctrl_ops = {
  1190. .s_ctrl = ov13858_set_ctrl,
  1191. };
  1192. static int ov13858_enum_mbus_code(struct v4l2_subdev *sd,
  1193. struct v4l2_subdev_state *sd_state,
  1194. struct v4l2_subdev_mbus_code_enum *code)
  1195. {
  1196. /* Only one bayer order(GRBG) is supported */
  1197. if (code->index > 0)
  1198. return -EINVAL;
  1199. code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
  1200. return 0;
  1201. }
  1202. static int ov13858_enum_frame_size(struct v4l2_subdev *sd,
  1203. struct v4l2_subdev_state *sd_state,
  1204. struct v4l2_subdev_frame_size_enum *fse)
  1205. {
  1206. if (fse->index >= ARRAY_SIZE(supported_modes))
  1207. return -EINVAL;
  1208. if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
  1209. return -EINVAL;
  1210. fse->min_width = supported_modes[fse->index].width;
  1211. fse->max_width = fse->min_width;
  1212. fse->min_height = supported_modes[fse->index].height;
  1213. fse->max_height = fse->min_height;
  1214. return 0;
  1215. }
  1216. static void ov13858_update_pad_format(const struct ov13858_mode *mode,
  1217. struct v4l2_subdev_format *fmt)
  1218. {
  1219. fmt->format.width = mode->width;
  1220. fmt->format.height = mode->height;
  1221. fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
  1222. fmt->format.field = V4L2_FIELD_NONE;
  1223. }
  1224. static int ov13858_do_get_pad_format(struct ov13858 *ov13858,
  1225. struct v4l2_subdev_state *sd_state,
  1226. struct v4l2_subdev_format *fmt)
  1227. {
  1228. struct v4l2_mbus_framefmt *framefmt;
  1229. if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
  1230. framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
  1231. fmt->format = *framefmt;
  1232. } else {
  1233. ov13858_update_pad_format(ov13858->cur_mode, fmt);
  1234. }
  1235. return 0;
  1236. }
  1237. static int ov13858_get_pad_format(struct v4l2_subdev *sd,
  1238. struct v4l2_subdev_state *sd_state,
  1239. struct v4l2_subdev_format *fmt)
  1240. {
  1241. struct ov13858 *ov13858 = to_ov13858(sd);
  1242. int ret;
  1243. mutex_lock(&ov13858->mutex);
  1244. ret = ov13858_do_get_pad_format(ov13858, sd_state, fmt);
  1245. mutex_unlock(&ov13858->mutex);
  1246. return ret;
  1247. }
  1248. static int
  1249. ov13858_set_pad_format(struct v4l2_subdev *sd,
  1250. struct v4l2_subdev_state *sd_state,
  1251. struct v4l2_subdev_format *fmt)
  1252. {
  1253. struct ov13858 *ov13858 = to_ov13858(sd);
  1254. const struct ov13858_mode *mode;
  1255. struct v4l2_mbus_framefmt *framefmt;
  1256. s32 vblank_def;
  1257. s32 vblank_min;
  1258. s64 h_blank;
  1259. s64 pixel_rate;
  1260. s64 link_freq;
  1261. mutex_lock(&ov13858->mutex);
  1262. /* Only one raw bayer(GRBG) order is supported */
  1263. if (fmt->format.code != MEDIA_BUS_FMT_SGRBG10_1X10)
  1264. fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
  1265. mode = v4l2_find_nearest_size(supported_modes,
  1266. ARRAY_SIZE(supported_modes),
  1267. width, height,
  1268. fmt->format.width, fmt->format.height);
  1269. ov13858_update_pad_format(mode, fmt);
  1270. if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
  1271. framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
  1272. *framefmt = fmt->format;
  1273. } else {
  1274. ov13858->cur_mode = mode;
  1275. __v4l2_ctrl_s_ctrl(ov13858->link_freq, mode->link_freq_index);
  1276. link_freq = link_freq_menu_items[mode->link_freq_index];
  1277. pixel_rate = link_freq_to_pixel_rate(link_freq);
  1278. __v4l2_ctrl_s_ctrl_int64(ov13858->pixel_rate, pixel_rate);
  1279. /* Update limits and set FPS to default */
  1280. vblank_def = ov13858->cur_mode->vts_def -
  1281. ov13858->cur_mode->height;
  1282. vblank_min = ov13858->cur_mode->vts_min -
  1283. ov13858->cur_mode->height;
  1284. __v4l2_ctrl_modify_range(
  1285. ov13858->vblank, vblank_min,
  1286. OV13858_VTS_MAX - ov13858->cur_mode->height, 1,
  1287. vblank_def);
  1288. __v4l2_ctrl_s_ctrl(ov13858->vblank, vblank_def);
  1289. h_blank =
  1290. link_freq_configs[mode->link_freq_index].pixels_per_line
  1291. - ov13858->cur_mode->width;
  1292. __v4l2_ctrl_modify_range(ov13858->hblank, h_blank,
  1293. h_blank, 1, h_blank);
  1294. }
  1295. mutex_unlock(&ov13858->mutex);
  1296. return 0;
  1297. }
  1298. static int ov13858_get_skip_frames(struct v4l2_subdev *sd, u32 *frames)
  1299. {
  1300. *frames = OV13858_NUM_OF_SKIP_FRAMES;
  1301. return 0;
  1302. }
  1303. /* Start streaming */
  1304. static int ov13858_start_streaming(struct ov13858 *ov13858)
  1305. {
  1306. struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
  1307. const struct ov13858_reg_list *reg_list;
  1308. int ret, link_freq_index;
  1309. /* Get out of from software reset */
  1310. ret = ov13858_write_reg(ov13858, OV13858_REG_SOFTWARE_RST,
  1311. OV13858_REG_VALUE_08BIT, OV13858_SOFTWARE_RST);
  1312. if (ret) {
  1313. dev_err(&client->dev, "%s failed to set powerup registers\n",
  1314. __func__);
  1315. return ret;
  1316. }
  1317. /* Setup PLL */
  1318. link_freq_index = ov13858->cur_mode->link_freq_index;
  1319. reg_list = &link_freq_configs[link_freq_index].reg_list;
  1320. ret = ov13858_write_reg_list(ov13858, reg_list);
  1321. if (ret) {
  1322. dev_err(&client->dev, "%s failed to set plls\n", __func__);
  1323. return ret;
  1324. }
  1325. /* Apply default values of current mode */
  1326. reg_list = &ov13858->cur_mode->reg_list;
  1327. ret = ov13858_write_reg_list(ov13858, reg_list);
  1328. if (ret) {
  1329. dev_err(&client->dev, "%s failed to set mode\n", __func__);
  1330. return ret;
  1331. }
  1332. /* Apply customized values from user */
  1333. ret = __v4l2_ctrl_handler_setup(ov13858->sd.ctrl_handler);
  1334. if (ret)
  1335. return ret;
  1336. return ov13858_write_reg(ov13858, OV13858_REG_MODE_SELECT,
  1337. OV13858_REG_VALUE_08BIT,
  1338. OV13858_MODE_STREAMING);
  1339. }
  1340. /* Stop streaming */
  1341. static int ov13858_stop_streaming(struct ov13858 *ov13858)
  1342. {
  1343. return ov13858_write_reg(ov13858, OV13858_REG_MODE_SELECT,
  1344. OV13858_REG_VALUE_08BIT, OV13858_MODE_STANDBY);
  1345. }
  1346. static int ov13858_set_stream(struct v4l2_subdev *sd, int enable)
  1347. {
  1348. struct ov13858 *ov13858 = to_ov13858(sd);
  1349. struct i2c_client *client = v4l2_get_subdevdata(sd);
  1350. int ret = 0;
  1351. mutex_lock(&ov13858->mutex);
  1352. if (enable) {
  1353. ret = pm_runtime_resume_and_get(&client->dev);
  1354. if (ret < 0)
  1355. goto err_unlock;
  1356. /*
  1357. * Apply default & customized values
  1358. * and then start streaming.
  1359. */
  1360. ret = ov13858_start_streaming(ov13858);
  1361. if (ret)
  1362. goto err_rpm_put;
  1363. } else {
  1364. ov13858_stop_streaming(ov13858);
  1365. pm_runtime_put(&client->dev);
  1366. }
  1367. mutex_unlock(&ov13858->mutex);
  1368. return ret;
  1369. err_rpm_put:
  1370. pm_runtime_put(&client->dev);
  1371. err_unlock:
  1372. mutex_unlock(&ov13858->mutex);
  1373. return ret;
  1374. }
  1375. /* Verify chip ID */
  1376. static int ov13858_identify_module(struct ov13858 *ov13858)
  1377. {
  1378. struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
  1379. int ret;
  1380. u32 val;
  1381. ret = ov13858_read_reg(ov13858, OV13858_REG_CHIP_ID,
  1382. OV13858_REG_VALUE_24BIT, &val);
  1383. if (ret)
  1384. return ret;
  1385. if (val != OV13858_CHIP_ID) {
  1386. dev_err(&client->dev, "chip id mismatch: %x!=%x\n",
  1387. OV13858_CHIP_ID, val);
  1388. return -EIO;
  1389. }
  1390. return 0;
  1391. }
  1392. static const struct v4l2_subdev_core_ops ov13858_core_ops = {
  1393. .log_status = v4l2_ctrl_subdev_log_status,
  1394. .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
  1395. .unsubscribe_event = v4l2_event_subdev_unsubscribe,
  1396. };
  1397. static const struct v4l2_subdev_video_ops ov13858_video_ops = {
  1398. .s_stream = ov13858_set_stream,
  1399. };
  1400. static const struct v4l2_subdev_pad_ops ov13858_pad_ops = {
  1401. .enum_mbus_code = ov13858_enum_mbus_code,
  1402. .get_fmt = ov13858_get_pad_format,
  1403. .set_fmt = ov13858_set_pad_format,
  1404. .enum_frame_size = ov13858_enum_frame_size,
  1405. };
  1406. static const struct v4l2_subdev_sensor_ops ov13858_sensor_ops = {
  1407. .g_skip_frames = ov13858_get_skip_frames,
  1408. };
  1409. static const struct v4l2_subdev_ops ov13858_subdev_ops = {
  1410. .core = &ov13858_core_ops,
  1411. .video = &ov13858_video_ops,
  1412. .pad = &ov13858_pad_ops,
  1413. .sensor = &ov13858_sensor_ops,
  1414. };
  1415. static const struct media_entity_operations ov13858_subdev_entity_ops = {
  1416. .link_validate = v4l2_subdev_link_validate,
  1417. };
  1418. static const struct v4l2_subdev_internal_ops ov13858_internal_ops = {
  1419. .open = ov13858_open,
  1420. };
  1421. /* Initialize control handlers */
  1422. static int ov13858_init_controls(struct ov13858 *ov13858)
  1423. {
  1424. struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
  1425. struct v4l2_fwnode_device_properties props;
  1426. struct v4l2_ctrl_handler *ctrl_hdlr;
  1427. s64 exposure_max;
  1428. s64 vblank_def;
  1429. s64 vblank_min;
  1430. s64 hblank;
  1431. s64 pixel_rate_min;
  1432. s64 pixel_rate_max;
  1433. const struct ov13858_mode *mode;
  1434. int ret;
  1435. ctrl_hdlr = &ov13858->ctrl_handler;
  1436. ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
  1437. if (ret)
  1438. return ret;
  1439. mutex_init(&ov13858->mutex);
  1440. ctrl_hdlr->lock = &ov13858->mutex;
  1441. ov13858->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
  1442. &ov13858_ctrl_ops,
  1443. V4L2_CID_LINK_FREQ,
  1444. OV13858_NUM_OF_LINK_FREQS - 1,
  1445. 0,
  1446. link_freq_menu_items);
  1447. if (ov13858->link_freq)
  1448. ov13858->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
  1449. pixel_rate_max = link_freq_to_pixel_rate(link_freq_menu_items[0]);
  1450. pixel_rate_min = link_freq_to_pixel_rate(link_freq_menu_items[1]);
  1451. /* By default, PIXEL_RATE is read only */
  1452. ov13858->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov13858_ctrl_ops,
  1453. V4L2_CID_PIXEL_RATE,
  1454. pixel_rate_min, pixel_rate_max,
  1455. 1, pixel_rate_max);
  1456. mode = ov13858->cur_mode;
  1457. vblank_def = mode->vts_def - mode->height;
  1458. vblank_min = mode->vts_min - mode->height;
  1459. ov13858->vblank = v4l2_ctrl_new_std(
  1460. ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_VBLANK,
  1461. vblank_min, OV13858_VTS_MAX - mode->height, 1,
  1462. vblank_def);
  1463. hblank = link_freq_configs[mode->link_freq_index].pixels_per_line -
  1464. mode->width;
  1465. ov13858->hblank = v4l2_ctrl_new_std(
  1466. ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_HBLANK,
  1467. hblank, hblank, 1, hblank);
  1468. if (ov13858->hblank)
  1469. ov13858->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
  1470. exposure_max = mode->vts_def - 8;
  1471. ov13858->exposure = v4l2_ctrl_new_std(
  1472. ctrl_hdlr, &ov13858_ctrl_ops,
  1473. V4L2_CID_EXPOSURE, OV13858_EXPOSURE_MIN,
  1474. exposure_max, OV13858_EXPOSURE_STEP,
  1475. OV13858_EXPOSURE_DEFAULT);
  1476. v4l2_ctrl_new_std(ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
  1477. OV13858_ANA_GAIN_MIN, OV13858_ANA_GAIN_MAX,
  1478. OV13858_ANA_GAIN_STEP, OV13858_ANA_GAIN_DEFAULT);
  1479. /* Digital gain */
  1480. v4l2_ctrl_new_std(ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
  1481. OV13858_DGTL_GAIN_MIN, OV13858_DGTL_GAIN_MAX,
  1482. OV13858_DGTL_GAIN_STEP, OV13858_DGTL_GAIN_DEFAULT);
  1483. v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov13858_ctrl_ops,
  1484. V4L2_CID_TEST_PATTERN,
  1485. ARRAY_SIZE(ov13858_test_pattern_menu) - 1,
  1486. 0, 0, ov13858_test_pattern_menu);
  1487. if (ctrl_hdlr->error) {
  1488. ret = ctrl_hdlr->error;
  1489. dev_err(&client->dev, "%s control init failed (%d)\n",
  1490. __func__, ret);
  1491. goto error;
  1492. }
  1493. ret = v4l2_fwnode_device_parse(&client->dev, &props);
  1494. if (ret)
  1495. goto error;
  1496. ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov13858_ctrl_ops,
  1497. &props);
  1498. if (ret)
  1499. goto error;
  1500. ov13858->sd.ctrl_handler = ctrl_hdlr;
  1501. return 0;
  1502. error:
  1503. v4l2_ctrl_handler_free(ctrl_hdlr);
  1504. mutex_destroy(&ov13858->mutex);
  1505. return ret;
  1506. }
  1507. static void ov13858_free_controls(struct ov13858 *ov13858)
  1508. {
  1509. v4l2_ctrl_handler_free(ov13858->sd.ctrl_handler);
  1510. mutex_destroy(&ov13858->mutex);
  1511. }
  1512. static int ov13858_probe(struct i2c_client *client)
  1513. {
  1514. struct ov13858 *ov13858;
  1515. int ret;
  1516. u32 val = 0;
  1517. device_property_read_u32(&client->dev, "clock-frequency", &val);
  1518. if (val != 19200000)
  1519. return -EINVAL;
  1520. ov13858 = devm_kzalloc(&client->dev, sizeof(*ov13858), GFP_KERNEL);
  1521. if (!ov13858)
  1522. return -ENOMEM;
  1523. /* Initialize subdev */
  1524. v4l2_i2c_subdev_init(&ov13858->sd, client, &ov13858_subdev_ops);
  1525. /* Check module identity */
  1526. ret = ov13858_identify_module(ov13858);
  1527. if (ret) {
  1528. dev_err(&client->dev, "failed to find sensor: %d\n", ret);
  1529. return ret;
  1530. }
  1531. /* Set default mode to max resolution */
  1532. ov13858->cur_mode = &supported_modes[0];
  1533. ret = ov13858_init_controls(ov13858);
  1534. if (ret)
  1535. return ret;
  1536. /* Initialize subdev */
  1537. ov13858->sd.internal_ops = &ov13858_internal_ops;
  1538. ov13858->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
  1539. V4L2_SUBDEV_FL_HAS_EVENTS;
  1540. ov13858->sd.entity.ops = &ov13858_subdev_entity_ops;
  1541. ov13858->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
  1542. /* Initialize source pad */
  1543. ov13858->pad.flags = MEDIA_PAD_FL_SOURCE;
  1544. ret = media_entity_pads_init(&ov13858->sd.entity, 1, &ov13858->pad);
  1545. if (ret) {
  1546. dev_err(&client->dev, "%s failed:%d\n", __func__, ret);
  1547. goto error_handler_free;
  1548. }
  1549. ret = v4l2_async_register_subdev_sensor(&ov13858->sd);
  1550. if (ret < 0)
  1551. goto error_media_entity;
  1552. /*
  1553. * Device is already turned on by i2c-core with ACPI domain PM.
  1554. * Enable runtime PM and turn off the device.
  1555. */
  1556. pm_runtime_set_active(&client->dev);
  1557. pm_runtime_enable(&client->dev);
  1558. pm_runtime_idle(&client->dev);
  1559. return 0;
  1560. error_media_entity:
  1561. media_entity_cleanup(&ov13858->sd.entity);
  1562. error_handler_free:
  1563. ov13858_free_controls(ov13858);
  1564. dev_err(&client->dev, "%s failed:%d\n", __func__, ret);
  1565. return ret;
  1566. }
  1567. static void ov13858_remove(struct i2c_client *client)
  1568. {
  1569. struct v4l2_subdev *sd = i2c_get_clientdata(client);
  1570. struct ov13858 *ov13858 = to_ov13858(sd);
  1571. v4l2_async_unregister_subdev(sd);
  1572. media_entity_cleanup(&sd->entity);
  1573. ov13858_free_controls(ov13858);
  1574. pm_runtime_disable(&client->dev);
  1575. }
  1576. static const struct i2c_device_id ov13858_id_table[] = {
  1577. { "ov13858" },
  1578. {}
  1579. };
  1580. MODULE_DEVICE_TABLE(i2c, ov13858_id_table);
  1581. #ifdef CONFIG_ACPI
  1582. static const struct acpi_device_id ov13858_acpi_ids[] = {
  1583. {"OVTID858"},
  1584. { /* sentinel */ }
  1585. };
  1586. MODULE_DEVICE_TABLE(acpi, ov13858_acpi_ids);
  1587. #endif
  1588. static struct i2c_driver ov13858_i2c_driver = {
  1589. .driver = {
  1590. .name = "ov13858",
  1591. .acpi_match_table = ACPI_PTR(ov13858_acpi_ids),
  1592. },
  1593. .probe = ov13858_probe,
  1594. .remove = ov13858_remove,
  1595. .id_table = ov13858_id_table,
  1596. };
  1597. module_i2c_driver(ov13858_i2c_driver);
  1598. MODULE_AUTHOR("Kan, Chris <chris.kan@intel.com>");
  1599. MODULE_AUTHOR("Rapolu, Chiranjeevi");
  1600. MODULE_AUTHOR("Yang, Hyungwoo");
  1601. MODULE_DESCRIPTION("Omnivision ov13858 sensor driver");
  1602. MODULE_LICENSE("GPL v2");