meson_venc.c 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569
  1. /*
  2. * Copyright (C) 2016 BayLibre, SAS
  3. * Author: Neil Armstrong <narmstrong@baylibre.com>
  4. * Copyright (C) 2015 Amlogic, Inc. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <drm/drmP.h>
  22. #include "meson_drv.h"
  23. #include "meson_venc.h"
  24. #include "meson_vpp.h"
  25. #include "meson_vclk.h"
  26. #include "meson_registers.h"
  27. /**
  28. * DOC: Video Encoder
  29. *
  30. * VENC Handle the pixels encoding to the output formats.
  31. * We handle the following encodings :
  32. *
  33. * - CVBS Encoding via the ENCI encoder and VDAC digital to analog converter
  34. * - TMDS/HDMI Encoding via ENCI_DIV and ENCP
  35. * - Setup of more clock rates for HDMI modes
  36. *
  37. * What is missing :
  38. *
  39. * - LCD Panel encoding via ENCL
  40. * - TV Panel encoding via ENCT
  41. *
  42. * VENC paths :
  43. *
  44. * .. code::
  45. *
  46. * _____ _____ ____________________
  47. * vd1---| |-| | | VENC /---------|----VDAC
  48. * vd2---| VIU |-| VPP |-|-----ENCI/-ENCI_DVI-|-|
  49. * osd1--| |-| | | \ | X--HDMI-TX
  50. * osd2--|_____|-|_____| | |\-ENCP--ENCP_DVI-|-|
  51. * | | |
  52. * | \--ENCL-----------|----LVDS
  53. * |____________________|
  54. *
  55. * The ENCI is designed for PAl or NTSC encoding and can go through the VDAC
  56. * directly for CVBS encoding or through the ENCI_DVI encoder for HDMI.
  57. * The ENCP is designed for Progressive encoding but can also generate
  58. * 1080i interlaced pixels, and was initialy desined to encode pixels for
  59. * VDAC to output RGB ou YUV analog outputs.
  60. * It's output is only used through the ENCP_DVI encoder for HDMI.
  61. * The ENCL LVDS encoder is not implemented.
  62. *
  63. * The ENCI and ENCP encoders needs specially defined parameters for each
  64. * supported mode and thus cannot be determined from standard video timings.
  65. *
  66. * The ENCI end ENCP DVI encoders are more generic and can generate any timings
  67. * from the pixel data generated by ENCI or ENCP, so can use the standard video
  68. * timings are source for HW parameters.
  69. */
  70. /* HHI Registers */
  71. #define HHI_GCLK_MPEG2 0x148 /* 0x52 offset in data sheet */
  72. #define HHI_VDAC_CNTL0 0x2F4 /* 0xbd offset in data sheet */
  73. #define HHI_VDAC_CNTL1 0x2F8 /* 0xbe offset in data sheet */
  74. #define HHI_HDMI_PHY_CNTL0 0x3a0 /* 0xe8 offset in data sheet */
  75. struct meson_cvbs_enci_mode meson_cvbs_enci_pal = {
  76. .mode_tag = MESON_VENC_MODE_CVBS_PAL,
  77. .hso_begin = 3,
  78. .hso_end = 129,
  79. .vso_even = 3,
  80. .vso_odd = 260,
  81. .macv_max_amp = 7,
  82. .video_prog_mode = 0xff,
  83. .video_mode = 0x13,
  84. .sch_adjust = 0x28,
  85. .yc_delay = 0x343,
  86. .pixel_start = 251,
  87. .pixel_end = 1691,
  88. .top_field_line_start = 22,
  89. .top_field_line_end = 310,
  90. .bottom_field_line_start = 23,
  91. .bottom_field_line_end = 311,
  92. .video_saturation = 9,
  93. .video_contrast = 0,
  94. .video_brightness = 0,
  95. .video_hue = 0,
  96. .analog_sync_adj = 0x8080,
  97. };
  98. struct meson_cvbs_enci_mode meson_cvbs_enci_ntsc = {
  99. .mode_tag = MESON_VENC_MODE_CVBS_NTSC,
  100. .hso_begin = 5,
  101. .hso_end = 129,
  102. .vso_even = 3,
  103. .vso_odd = 260,
  104. .macv_max_amp = 0xb,
  105. .video_prog_mode = 0xf0,
  106. .video_mode = 0x8,
  107. .sch_adjust = 0x20,
  108. .yc_delay = 0x333,
  109. .pixel_start = 227,
  110. .pixel_end = 1667,
  111. .top_field_line_start = 18,
  112. .top_field_line_end = 258,
  113. .bottom_field_line_start = 19,
  114. .bottom_field_line_end = 259,
  115. .video_saturation = 18,
  116. .video_contrast = 3,
  117. .video_brightness = 0,
  118. .video_hue = 0,
  119. .analog_sync_adj = 0x9c00,
  120. };
  121. union meson_hdmi_venc_mode {
  122. struct {
  123. unsigned int mode_tag;
  124. unsigned int hso_begin;
  125. unsigned int hso_end;
  126. unsigned int vso_even;
  127. unsigned int vso_odd;
  128. unsigned int macv_max_amp;
  129. unsigned int video_prog_mode;
  130. unsigned int video_mode;
  131. unsigned int sch_adjust;
  132. unsigned int yc_delay;
  133. unsigned int pixel_start;
  134. unsigned int pixel_end;
  135. unsigned int top_field_line_start;
  136. unsigned int top_field_line_end;
  137. unsigned int bottom_field_line_start;
  138. unsigned int bottom_field_line_end;
  139. } enci;
  140. struct {
  141. unsigned int dvi_settings;
  142. unsigned int video_mode;
  143. unsigned int video_mode_adv;
  144. unsigned int video_prog_mode;
  145. bool video_prog_mode_present;
  146. unsigned int video_sync_mode;
  147. bool video_sync_mode_present;
  148. unsigned int video_yc_dly;
  149. bool video_yc_dly_present;
  150. unsigned int video_rgb_ctrl;
  151. bool video_rgb_ctrl_present;
  152. unsigned int video_filt_ctrl;
  153. bool video_filt_ctrl_present;
  154. unsigned int video_ofld_voav_ofst;
  155. bool video_ofld_voav_ofst_present;
  156. unsigned int yfp1_htime;
  157. unsigned int yfp2_htime;
  158. unsigned int max_pxcnt;
  159. unsigned int hspuls_begin;
  160. unsigned int hspuls_end;
  161. unsigned int hspuls_switch;
  162. unsigned int vspuls_begin;
  163. unsigned int vspuls_end;
  164. unsigned int vspuls_bline;
  165. unsigned int vspuls_eline;
  166. unsigned int eqpuls_begin;
  167. bool eqpuls_begin_present;
  168. unsigned int eqpuls_end;
  169. bool eqpuls_end_present;
  170. unsigned int eqpuls_bline;
  171. bool eqpuls_bline_present;
  172. unsigned int eqpuls_eline;
  173. bool eqpuls_eline_present;
  174. unsigned int havon_begin;
  175. unsigned int havon_end;
  176. unsigned int vavon_bline;
  177. unsigned int vavon_eline;
  178. unsigned int hso_begin;
  179. unsigned int hso_end;
  180. unsigned int vso_begin;
  181. unsigned int vso_end;
  182. unsigned int vso_bline;
  183. unsigned int vso_eline;
  184. bool vso_eline_present;
  185. unsigned int sy_val;
  186. bool sy_val_present;
  187. unsigned int sy2_val;
  188. bool sy2_val_present;
  189. unsigned int max_lncnt;
  190. } encp;
  191. };
  192. union meson_hdmi_venc_mode meson_hdmi_enci_mode_480i = {
  193. .enci = {
  194. .hso_begin = 5,
  195. .hso_end = 129,
  196. .vso_even = 3,
  197. .vso_odd = 260,
  198. .macv_max_amp = 0x810b,
  199. .video_prog_mode = 0xf0,
  200. .video_mode = 0x8,
  201. .sch_adjust = 0x20,
  202. .yc_delay = 0,
  203. .pixel_start = 227,
  204. .pixel_end = 1667,
  205. .top_field_line_start = 18,
  206. .top_field_line_end = 258,
  207. .bottom_field_line_start = 19,
  208. .bottom_field_line_end = 259,
  209. },
  210. };
  211. union meson_hdmi_venc_mode meson_hdmi_enci_mode_576i = {
  212. .enci = {
  213. .hso_begin = 3,
  214. .hso_end = 129,
  215. .vso_even = 3,
  216. .vso_odd = 260,
  217. .macv_max_amp = 8107,
  218. .video_prog_mode = 0xff,
  219. .video_mode = 0x13,
  220. .sch_adjust = 0x28,
  221. .yc_delay = 0x333,
  222. .pixel_start = 251,
  223. .pixel_end = 1691,
  224. .top_field_line_start = 22,
  225. .top_field_line_end = 310,
  226. .bottom_field_line_start = 23,
  227. .bottom_field_line_end = 311,
  228. },
  229. };
  230. union meson_hdmi_venc_mode meson_hdmi_encp_mode_480p = {
  231. .encp = {
  232. .dvi_settings = 0x21,
  233. .video_mode = 0x4000,
  234. .video_mode_adv = 0x9,
  235. .video_prog_mode = 0,
  236. .video_prog_mode_present = true,
  237. .video_sync_mode = 7,
  238. .video_sync_mode_present = true,
  239. /* video_yc_dly */
  240. /* video_rgb_ctrl */
  241. .video_filt_ctrl = 0x2052,
  242. .video_filt_ctrl_present = true,
  243. /* video_ofld_voav_ofst */
  244. .yfp1_htime = 244,
  245. .yfp2_htime = 1630,
  246. .max_pxcnt = 1715,
  247. .hspuls_begin = 0x22,
  248. .hspuls_end = 0xa0,
  249. .hspuls_switch = 88,
  250. .vspuls_begin = 0,
  251. .vspuls_end = 1589,
  252. .vspuls_bline = 0,
  253. .vspuls_eline = 5,
  254. .havon_begin = 249,
  255. .havon_end = 1689,
  256. .vavon_bline = 42,
  257. .vavon_eline = 521,
  258. /* eqpuls_begin */
  259. /* eqpuls_end */
  260. /* eqpuls_bline */
  261. /* eqpuls_eline */
  262. .hso_begin = 3,
  263. .hso_end = 5,
  264. .vso_begin = 3,
  265. .vso_end = 5,
  266. .vso_bline = 0,
  267. /* vso_eline */
  268. .sy_val = 8,
  269. .sy_val_present = true,
  270. .sy2_val = 0x1d8,
  271. .sy2_val_present = true,
  272. .max_lncnt = 524,
  273. },
  274. };
  275. union meson_hdmi_venc_mode meson_hdmi_encp_mode_576p = {
  276. .encp = {
  277. .dvi_settings = 0x21,
  278. .video_mode = 0x4000,
  279. .video_mode_adv = 0x9,
  280. .video_prog_mode = 0,
  281. .video_prog_mode_present = true,
  282. .video_sync_mode = 7,
  283. .video_sync_mode_present = true,
  284. /* video_yc_dly */
  285. /* video_rgb_ctrl */
  286. .video_filt_ctrl = 0x52,
  287. .video_filt_ctrl_present = true,
  288. /* video_ofld_voav_ofst */
  289. .yfp1_htime = 235,
  290. .yfp2_htime = 1674,
  291. .max_pxcnt = 1727,
  292. .hspuls_begin = 0,
  293. .hspuls_end = 0x80,
  294. .hspuls_switch = 88,
  295. .vspuls_begin = 0,
  296. .vspuls_end = 1599,
  297. .vspuls_bline = 0,
  298. .vspuls_eline = 4,
  299. .havon_begin = 235,
  300. .havon_end = 1674,
  301. .vavon_bline = 44,
  302. .vavon_eline = 619,
  303. /* eqpuls_begin */
  304. /* eqpuls_end */
  305. /* eqpuls_bline */
  306. /* eqpuls_eline */
  307. .hso_begin = 0x80,
  308. .hso_end = 0,
  309. .vso_begin = 0,
  310. .vso_end = 5,
  311. .vso_bline = 0,
  312. /* vso_eline */
  313. .sy_val = 8,
  314. .sy_val_present = true,
  315. .sy2_val = 0x1d8,
  316. .sy2_val_present = true,
  317. .max_lncnt = 624,
  318. },
  319. };
  320. union meson_hdmi_venc_mode meson_hdmi_encp_mode_720p60 = {
  321. .encp = {
  322. .dvi_settings = 0x2029,
  323. .video_mode = 0x4040,
  324. .video_mode_adv = 0x19,
  325. /* video_prog_mode */
  326. /* video_sync_mode */
  327. /* video_yc_dly */
  328. /* video_rgb_ctrl */
  329. /* video_filt_ctrl */
  330. /* video_ofld_voav_ofst */
  331. .yfp1_htime = 648,
  332. .yfp2_htime = 3207,
  333. .max_pxcnt = 3299,
  334. .hspuls_begin = 80,
  335. .hspuls_end = 240,
  336. .hspuls_switch = 80,
  337. .vspuls_begin = 688,
  338. .vspuls_end = 3248,
  339. .vspuls_bline = 4,
  340. .vspuls_eline = 8,
  341. .havon_begin = 648,
  342. .havon_end = 3207,
  343. .vavon_bline = 29,
  344. .vavon_eline = 748,
  345. /* eqpuls_begin */
  346. /* eqpuls_end */
  347. /* eqpuls_bline */
  348. /* eqpuls_eline */
  349. .hso_begin = 256,
  350. .hso_end = 168,
  351. .vso_begin = 168,
  352. .vso_end = 256,
  353. .vso_bline = 0,
  354. .vso_eline = 5,
  355. .vso_eline_present = true,
  356. /* sy_val */
  357. /* sy2_val */
  358. .max_lncnt = 749,
  359. },
  360. };
  361. union meson_hdmi_venc_mode meson_hdmi_encp_mode_720p50 = {
  362. .encp = {
  363. .dvi_settings = 0x202d,
  364. .video_mode = 0x4040,
  365. .video_mode_adv = 0x19,
  366. .video_prog_mode = 0x100,
  367. .video_prog_mode_present = true,
  368. .video_sync_mode = 0x407,
  369. .video_sync_mode_present = true,
  370. .video_yc_dly = 0,
  371. .video_yc_dly_present = true,
  372. /* video_rgb_ctrl */
  373. /* video_filt_ctrl */
  374. /* video_ofld_voav_ofst */
  375. .yfp1_htime = 648,
  376. .yfp2_htime = 3207,
  377. .max_pxcnt = 3959,
  378. .hspuls_begin = 80,
  379. .hspuls_end = 240,
  380. .hspuls_switch = 80,
  381. .vspuls_begin = 688,
  382. .vspuls_end = 3248,
  383. .vspuls_bline = 4,
  384. .vspuls_eline = 8,
  385. .havon_begin = 648,
  386. .havon_end = 3207,
  387. .vavon_bline = 29,
  388. .vavon_eline = 748,
  389. /* eqpuls_begin */
  390. /* eqpuls_end */
  391. /* eqpuls_bline */
  392. /* eqpuls_eline */
  393. .hso_begin = 128,
  394. .hso_end = 208,
  395. .vso_begin = 128,
  396. .vso_end = 128,
  397. .vso_bline = 0,
  398. .vso_eline = 5,
  399. .vso_eline_present = true,
  400. /* sy_val */
  401. /* sy2_val */
  402. .max_lncnt = 749,
  403. },
  404. };
  405. union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080i60 = {
  406. .encp = {
  407. .dvi_settings = 0x2029,
  408. .video_mode = 0x5ffc,
  409. .video_mode_adv = 0x19,
  410. .video_prog_mode = 0x100,
  411. .video_prog_mode_present = true,
  412. .video_sync_mode = 0x207,
  413. .video_sync_mode_present = true,
  414. /* video_yc_dly */
  415. /* video_rgb_ctrl */
  416. /* video_filt_ctrl */
  417. .video_ofld_voav_ofst = 0x11,
  418. .video_ofld_voav_ofst_present = true,
  419. .yfp1_htime = 516,
  420. .yfp2_htime = 4355,
  421. .max_pxcnt = 4399,
  422. .hspuls_begin = 88,
  423. .hspuls_end = 264,
  424. .hspuls_switch = 88,
  425. .vspuls_begin = 440,
  426. .vspuls_end = 2200,
  427. .vspuls_bline = 0,
  428. .vspuls_eline = 4,
  429. .havon_begin = 516,
  430. .havon_end = 4355,
  431. .vavon_bline = 20,
  432. .vavon_eline = 559,
  433. .eqpuls_begin = 2288,
  434. .eqpuls_begin_present = true,
  435. .eqpuls_end = 2464,
  436. .eqpuls_end_present = true,
  437. .eqpuls_bline = 0,
  438. .eqpuls_bline_present = true,
  439. .eqpuls_eline = 4,
  440. .eqpuls_eline_present = true,
  441. .hso_begin = 264,
  442. .hso_end = 176,
  443. .vso_begin = 88,
  444. .vso_end = 88,
  445. .vso_bline = 0,
  446. .vso_eline = 5,
  447. .vso_eline_present = true,
  448. /* sy_val */
  449. /* sy2_val */
  450. .max_lncnt = 1124,
  451. },
  452. };
  453. union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080i50 = {
  454. .encp = {
  455. .dvi_settings = 0x202d,
  456. .video_mode = 0x5ffc,
  457. .video_mode_adv = 0x19,
  458. .video_prog_mode = 0x100,
  459. .video_prog_mode_present = true,
  460. .video_sync_mode = 0x7,
  461. .video_sync_mode_present = true,
  462. /* video_yc_dly */
  463. /* video_rgb_ctrl */
  464. /* video_filt_ctrl */
  465. .video_ofld_voav_ofst = 0x11,
  466. .video_ofld_voav_ofst_present = true,
  467. .yfp1_htime = 526,
  468. .yfp2_htime = 4365,
  469. .max_pxcnt = 5279,
  470. .hspuls_begin = 88,
  471. .hspuls_end = 264,
  472. .hspuls_switch = 88,
  473. .vspuls_begin = 440,
  474. .vspuls_end = 2200,
  475. .vspuls_bline = 0,
  476. .vspuls_eline = 4,
  477. .havon_begin = 526,
  478. .havon_end = 4365,
  479. .vavon_bline = 20,
  480. .vavon_eline = 559,
  481. .eqpuls_begin = 2288,
  482. .eqpuls_begin_present = true,
  483. .eqpuls_end = 2464,
  484. .eqpuls_end_present = true,
  485. .eqpuls_bline = 0,
  486. .eqpuls_bline_present = true,
  487. .eqpuls_eline = 4,
  488. .eqpuls_eline_present = true,
  489. .hso_begin = 142,
  490. .hso_end = 230,
  491. .vso_begin = 142,
  492. .vso_end = 142,
  493. .vso_bline = 0,
  494. .vso_eline = 5,
  495. .vso_eline_present = true,
  496. /* sy_val */
  497. /* sy2_val */
  498. .max_lncnt = 1124,
  499. },
  500. };
  501. union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080p24 = {
  502. .encp = {
  503. .dvi_settings = 0xd,
  504. .video_mode = 0x4040,
  505. .video_mode_adv = 0x18,
  506. .video_prog_mode = 0x100,
  507. .video_prog_mode_present = true,
  508. .video_sync_mode = 0x7,
  509. .video_sync_mode_present = true,
  510. .video_yc_dly = 0,
  511. .video_yc_dly_present = true,
  512. .video_rgb_ctrl = 2,
  513. .video_rgb_ctrl_present = true,
  514. .video_filt_ctrl = 0x1052,
  515. .video_filt_ctrl_present = true,
  516. /* video_ofld_voav_ofst */
  517. .yfp1_htime = 271,
  518. .yfp2_htime = 2190,
  519. .max_pxcnt = 2749,
  520. .hspuls_begin = 44,
  521. .hspuls_end = 132,
  522. .hspuls_switch = 44,
  523. .vspuls_begin = 220,
  524. .vspuls_end = 2140,
  525. .vspuls_bline = 0,
  526. .vspuls_eline = 4,
  527. .havon_begin = 271,
  528. .havon_end = 2190,
  529. .vavon_bline = 41,
  530. .vavon_eline = 1120,
  531. /* eqpuls_begin */
  532. /* eqpuls_end */
  533. .eqpuls_bline = 0,
  534. .eqpuls_bline_present = true,
  535. .eqpuls_eline = 4,
  536. .eqpuls_eline_present = true,
  537. .hso_begin = 79,
  538. .hso_end = 123,
  539. .vso_begin = 79,
  540. .vso_end = 79,
  541. .vso_bline = 0,
  542. .vso_eline = 5,
  543. .vso_eline_present = true,
  544. /* sy_val */
  545. /* sy2_val */
  546. .max_lncnt = 1124,
  547. },
  548. };
  549. union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080p30 = {
  550. .encp = {
  551. .dvi_settings = 0x1,
  552. .video_mode = 0x4040,
  553. .video_mode_adv = 0x18,
  554. .video_prog_mode = 0x100,
  555. .video_prog_mode_present = true,
  556. /* video_sync_mode */
  557. /* video_yc_dly */
  558. /* video_rgb_ctrl */
  559. .video_filt_ctrl = 0x1052,
  560. .video_filt_ctrl_present = true,
  561. /* video_ofld_voav_ofst */
  562. .yfp1_htime = 140,
  563. .yfp2_htime = 2060,
  564. .max_pxcnt = 2199,
  565. .hspuls_begin = 2156,
  566. .hspuls_end = 44,
  567. .hspuls_switch = 44,
  568. .vspuls_begin = 140,
  569. .vspuls_end = 2059,
  570. .vspuls_bline = 0,
  571. .vspuls_eline = 4,
  572. .havon_begin = 148,
  573. .havon_end = 2067,
  574. .vavon_bline = 41,
  575. .vavon_eline = 1120,
  576. /* eqpuls_begin */
  577. /* eqpuls_end */
  578. /* eqpuls_bline */
  579. /* eqpuls_eline */
  580. .hso_begin = 44,
  581. .hso_end = 2156,
  582. .vso_begin = 2100,
  583. .vso_end = 2164,
  584. .vso_bline = 0,
  585. .vso_eline = 5,
  586. .vso_eline_present = true,
  587. /* sy_val */
  588. /* sy2_val */
  589. .max_lncnt = 1124,
  590. },
  591. };
  592. union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080p50 = {
  593. .encp = {
  594. .dvi_settings = 0xd,
  595. .video_mode = 0x4040,
  596. .video_mode_adv = 0x18,
  597. .video_prog_mode = 0x100,
  598. .video_prog_mode_present = true,
  599. .video_sync_mode = 0x7,
  600. .video_sync_mode_present = true,
  601. .video_yc_dly = 0,
  602. .video_yc_dly_present = true,
  603. .video_rgb_ctrl = 2,
  604. .video_rgb_ctrl_present = true,
  605. /* video_filt_ctrl */
  606. /* video_ofld_voav_ofst */
  607. .yfp1_htime = 271,
  608. .yfp2_htime = 2190,
  609. .max_pxcnt = 2639,
  610. .hspuls_begin = 44,
  611. .hspuls_end = 132,
  612. .hspuls_switch = 44,
  613. .vspuls_begin = 220,
  614. .vspuls_end = 2140,
  615. .vspuls_bline = 0,
  616. .vspuls_eline = 4,
  617. .havon_begin = 271,
  618. .havon_end = 2190,
  619. .vavon_bline = 41,
  620. .vavon_eline = 1120,
  621. /* eqpuls_begin */
  622. /* eqpuls_end */
  623. .eqpuls_bline = 0,
  624. .eqpuls_bline_present = true,
  625. .eqpuls_eline = 4,
  626. .eqpuls_eline_present = true,
  627. .hso_begin = 79,
  628. .hso_end = 123,
  629. .vso_begin = 79,
  630. .vso_end = 79,
  631. .vso_bline = 0,
  632. .vso_eline = 5,
  633. .vso_eline_present = true,
  634. /* sy_val */
  635. /* sy2_val */
  636. .max_lncnt = 1124,
  637. },
  638. };
  639. union meson_hdmi_venc_mode meson_hdmi_encp_mode_1080p60 = {
  640. .encp = {
  641. .dvi_settings = 0x1,
  642. .video_mode = 0x4040,
  643. .video_mode_adv = 0x18,
  644. .video_prog_mode = 0x100,
  645. .video_prog_mode_present = true,
  646. /* video_sync_mode */
  647. /* video_yc_dly */
  648. /* video_rgb_ctrl */
  649. .video_filt_ctrl = 0x1052,
  650. .video_filt_ctrl_present = true,
  651. /* video_ofld_voav_ofst */
  652. .yfp1_htime = 140,
  653. .yfp2_htime = 2060,
  654. .max_pxcnt = 2199,
  655. .hspuls_begin = 2156,
  656. .hspuls_end = 44,
  657. .hspuls_switch = 44,
  658. .vspuls_begin = 140,
  659. .vspuls_end = 2059,
  660. .vspuls_bline = 0,
  661. .vspuls_eline = 4,
  662. .havon_begin = 148,
  663. .havon_end = 2067,
  664. .vavon_bline = 41,
  665. .vavon_eline = 1120,
  666. /* eqpuls_begin */
  667. /* eqpuls_end */
  668. /* eqpuls_bline */
  669. /* eqpuls_eline */
  670. .hso_begin = 44,
  671. .hso_end = 2156,
  672. .vso_begin = 2100,
  673. .vso_end = 2164,
  674. .vso_bline = 0,
  675. .vso_eline = 5,
  676. .vso_eline_present = true,
  677. /* sy_val */
  678. /* sy2_val */
  679. .max_lncnt = 1124,
  680. },
  681. };
  682. struct meson_hdmi_venc_vic_mode {
  683. unsigned int vic;
  684. union meson_hdmi_venc_mode *mode;
  685. } meson_hdmi_venc_vic_modes[] = {
  686. { 6, &meson_hdmi_enci_mode_480i },
  687. { 7, &meson_hdmi_enci_mode_480i },
  688. { 21, &meson_hdmi_enci_mode_576i },
  689. { 22, &meson_hdmi_enci_mode_576i },
  690. { 2, &meson_hdmi_encp_mode_480p },
  691. { 3, &meson_hdmi_encp_mode_480p },
  692. { 17, &meson_hdmi_encp_mode_576p },
  693. { 18, &meson_hdmi_encp_mode_576p },
  694. { 4, &meson_hdmi_encp_mode_720p60 },
  695. { 19, &meson_hdmi_encp_mode_720p50 },
  696. { 5, &meson_hdmi_encp_mode_1080i60 },
  697. { 20, &meson_hdmi_encp_mode_1080i50 },
  698. { 32, &meson_hdmi_encp_mode_1080p24 },
  699. { 33, &meson_hdmi_encp_mode_1080p50 },
  700. { 34, &meson_hdmi_encp_mode_1080p30 },
  701. { 31, &meson_hdmi_encp_mode_1080p50 },
  702. { 16, &meson_hdmi_encp_mode_1080p60 },
  703. { 0, NULL}, /* sentinel */
  704. };
  705. static signed int to_signed(unsigned int a)
  706. {
  707. if (a <= 7)
  708. return a;
  709. else
  710. return a - 16;
  711. }
  712. static unsigned long modulo(unsigned long a, unsigned long b)
  713. {
  714. if (a >= b)
  715. return a - b;
  716. else
  717. return a;
  718. }
  719. enum drm_mode_status
  720. meson_venc_hdmi_supported_mode(const struct drm_display_mode *mode)
  721. {
  722. if (mode->flags & ~(DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC |
  723. DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC))
  724. return MODE_BAD;
  725. if (mode->hdisplay < 640 || mode->hdisplay > 1920)
  726. return MODE_BAD_HVALUE;
  727. if (mode->vdisplay < 480 || mode->vdisplay > 1200)
  728. return MODE_BAD_VVALUE;
  729. return MODE_OK;
  730. }
  731. EXPORT_SYMBOL_GPL(meson_venc_hdmi_supported_mode);
  732. bool meson_venc_hdmi_supported_vic(int vic)
  733. {
  734. struct meson_hdmi_venc_vic_mode *vmode = meson_hdmi_venc_vic_modes;
  735. while (vmode->vic && vmode->mode) {
  736. if (vmode->vic == vic)
  737. return true;
  738. vmode++;
  739. }
  740. return false;
  741. }
  742. EXPORT_SYMBOL_GPL(meson_venc_hdmi_supported_vic);
  743. void meson_venc_hdmi_get_dmt_vmode(const struct drm_display_mode *mode,
  744. union meson_hdmi_venc_mode *dmt_mode)
  745. {
  746. memset(dmt_mode, 0, sizeof(*dmt_mode));
  747. dmt_mode->encp.dvi_settings = 0x21;
  748. dmt_mode->encp.video_mode = 0x4040;
  749. dmt_mode->encp.video_mode_adv = 0x18;
  750. dmt_mode->encp.max_pxcnt = mode->htotal - 1;
  751. dmt_mode->encp.havon_begin = mode->htotal - mode->hsync_start;
  752. dmt_mode->encp.havon_end = dmt_mode->encp.havon_begin +
  753. mode->hdisplay - 1;
  754. dmt_mode->encp.vavon_bline = mode->vtotal - mode->vsync_start;
  755. dmt_mode->encp.vavon_eline = dmt_mode->encp.vavon_bline +
  756. mode->vdisplay - 1;
  757. dmt_mode->encp.hso_begin = 0;
  758. dmt_mode->encp.hso_end = mode->hsync_end - mode->hsync_start;
  759. dmt_mode->encp.vso_begin = 30;
  760. dmt_mode->encp.vso_end = 50;
  761. dmt_mode->encp.vso_bline = 0;
  762. dmt_mode->encp.vso_eline = mode->vsync_end - mode->vsync_start;
  763. dmt_mode->encp.vso_eline_present = true;
  764. dmt_mode->encp.max_lncnt = mode->vtotal - 1;
  765. }
  766. static union meson_hdmi_venc_mode *meson_venc_hdmi_get_vic_vmode(int vic)
  767. {
  768. struct meson_hdmi_venc_vic_mode *vmode = meson_hdmi_venc_vic_modes;
  769. while (vmode->vic && vmode->mode) {
  770. if (vmode->vic == vic)
  771. return vmode->mode;
  772. vmode++;
  773. }
  774. return NULL;
  775. }
  776. bool meson_venc_hdmi_venc_repeat(int vic)
  777. {
  778. /* Repeat VENC pixels for 480/576i/p, 720p50/60 and 1080p50/60 */
  779. if (vic == 6 || vic == 7 || /* 480i */
  780. vic == 21 || vic == 22 || /* 576i */
  781. vic == 17 || vic == 18 || /* 576p */
  782. vic == 2 || vic == 3 || /* 480p */
  783. vic == 4 || /* 720p60 */
  784. vic == 19 || /* 720p50 */
  785. vic == 5 || /* 1080i60 */
  786. vic == 20) /* 1080i50 */
  787. return true;
  788. return false;
  789. }
  790. EXPORT_SYMBOL_GPL(meson_venc_hdmi_venc_repeat);
  791. void meson_venc_hdmi_mode_set(struct meson_drm *priv, int vic,
  792. struct drm_display_mode *mode)
  793. {
  794. union meson_hdmi_venc_mode *vmode = NULL;
  795. union meson_hdmi_venc_mode vmode_dmt;
  796. bool use_enci = false;
  797. bool venc_repeat = false;
  798. bool hdmi_repeat = false;
  799. unsigned int venc_hdmi_latency = 2;
  800. unsigned long total_pixels_venc = 0;
  801. unsigned long active_pixels_venc = 0;
  802. unsigned long front_porch_venc = 0;
  803. unsigned long hsync_pixels_venc = 0;
  804. unsigned long de_h_begin = 0;
  805. unsigned long de_h_end = 0;
  806. unsigned long de_v_begin_even = 0;
  807. unsigned long de_v_end_even = 0;
  808. unsigned long de_v_begin_odd = 0;
  809. unsigned long de_v_end_odd = 0;
  810. unsigned long hs_begin = 0;
  811. unsigned long hs_end = 0;
  812. unsigned long vs_adjust = 0;
  813. unsigned long vs_bline_evn = 0;
  814. unsigned long vs_eline_evn = 0;
  815. unsigned long vs_bline_odd = 0;
  816. unsigned long vs_eline_odd = 0;
  817. unsigned long vso_begin_evn = 0;
  818. unsigned long vso_begin_odd = 0;
  819. unsigned int eof_lines;
  820. unsigned int sof_lines;
  821. unsigned int vsync_lines;
  822. /* Use VENCI for 480i and 576i and double HDMI pixels */
  823. if (mode->flags & DRM_MODE_FLAG_DBLCLK) {
  824. hdmi_repeat = true;
  825. use_enci = true;
  826. venc_hdmi_latency = 1;
  827. }
  828. if (meson_venc_hdmi_supported_vic(vic)) {
  829. vmode = meson_venc_hdmi_get_vic_vmode(vic);
  830. if (!vmode) {
  831. dev_err(priv->dev, "%s: Fatal Error, unsupported mode "
  832. DRM_MODE_FMT "\n", __func__,
  833. DRM_MODE_ARG(mode));
  834. return;
  835. }
  836. } else {
  837. meson_venc_hdmi_get_dmt_vmode(mode, &vmode_dmt);
  838. vmode = &vmode_dmt;
  839. use_enci = false;
  840. }
  841. /* Repeat VENC pixels for 480/576i/p, 720p50/60 and 1080p50/60 */
  842. if (meson_venc_hdmi_venc_repeat(vic))
  843. venc_repeat = true;
  844. eof_lines = mode->vsync_start - mode->vdisplay;
  845. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  846. eof_lines /= 2;
  847. sof_lines = mode->vtotal - mode->vsync_end;
  848. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  849. sof_lines /= 2;
  850. vsync_lines = mode->vsync_end - mode->vsync_start;
  851. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  852. vsync_lines /= 2;
  853. total_pixels_venc = mode->htotal;
  854. if (hdmi_repeat)
  855. total_pixels_venc /= 2;
  856. if (venc_repeat)
  857. total_pixels_venc *= 2;
  858. active_pixels_venc = mode->hdisplay;
  859. if (hdmi_repeat)
  860. active_pixels_venc /= 2;
  861. if (venc_repeat)
  862. active_pixels_venc *= 2;
  863. front_porch_venc = (mode->hsync_start - mode->hdisplay);
  864. if (hdmi_repeat)
  865. front_porch_venc /= 2;
  866. if (venc_repeat)
  867. front_porch_venc *= 2;
  868. hsync_pixels_venc = (mode->hsync_end - mode->hsync_start);
  869. if (hdmi_repeat)
  870. hsync_pixels_venc /= 2;
  871. if (venc_repeat)
  872. hsync_pixels_venc *= 2;
  873. /* Disable VDACs */
  874. writel_bits_relaxed(0xff, 0xff,
  875. priv->io_base + _REG(VENC_VDAC_SETTING));
  876. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_EN));
  877. writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN));
  878. if (use_enci) {
  879. unsigned int lines_f0;
  880. unsigned int lines_f1;
  881. /* CVBS Filter settings */
  882. writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL));
  883. writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL2));
  884. /* Digital Video Select : Interlace, clk27 clk, external */
  885. writel_relaxed(0, priv->io_base + _REG(VENC_DVI_SETTING));
  886. /* Reset Video Mode */
  887. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE));
  888. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV));
  889. /* Horizontal sync signal output */
  890. writel_relaxed(vmode->enci.hso_begin,
  891. priv->io_base + _REG(ENCI_SYNC_HSO_BEGIN));
  892. writel_relaxed(vmode->enci.hso_end,
  893. priv->io_base + _REG(ENCI_SYNC_HSO_END));
  894. /* Vertical Sync lines */
  895. writel_relaxed(vmode->enci.vso_even,
  896. priv->io_base + _REG(ENCI_SYNC_VSO_EVNLN));
  897. writel_relaxed(vmode->enci.vso_odd,
  898. priv->io_base + _REG(ENCI_SYNC_VSO_ODDLN));
  899. /* Macrovision max amplitude change */
  900. writel_relaxed(vmode->enci.macv_max_amp,
  901. priv->io_base + _REG(ENCI_MACV_MAX_AMP));
  902. /* Video mode */
  903. writel_relaxed(vmode->enci.video_prog_mode,
  904. priv->io_base + _REG(VENC_VIDEO_PROG_MODE));
  905. writel_relaxed(vmode->enci.video_mode,
  906. priv->io_base + _REG(ENCI_VIDEO_MODE));
  907. /* Advanced Video Mode :
  908. * Demux shifting 0x2
  909. * Blank line end at line17/22
  910. * High bandwidth Luma Filter
  911. * Low bandwidth Chroma Filter
  912. * Bypass luma low pass filter
  913. * No macrovision on CSYNC
  914. */
  915. writel_relaxed(0x26, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV));
  916. writel(vmode->enci.sch_adjust,
  917. priv->io_base + _REG(ENCI_VIDEO_SCH));
  918. /* Sync mode : MASTER Master mode, free run, send HSO/VSO out */
  919. writel_relaxed(0x07, priv->io_base + _REG(ENCI_SYNC_MODE));
  920. if (vmode->enci.yc_delay)
  921. writel_relaxed(vmode->enci.yc_delay,
  922. priv->io_base + _REG(ENCI_YC_DELAY));
  923. /* UNreset Interlaced TV Encoder */
  924. writel_relaxed(0, priv->io_base + _REG(ENCI_DBG_PX_RST));
  925. /* Enable Vfifo2vd, Y_Cb_Y_Cr select */
  926. writel_relaxed(0x4e01, priv->io_base + _REG(ENCI_VFIFO2VD_CTL));
  927. /* Timings */
  928. writel_relaxed(vmode->enci.pixel_start,
  929. priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_START));
  930. writel_relaxed(vmode->enci.pixel_end,
  931. priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_END));
  932. writel_relaxed(vmode->enci.top_field_line_start,
  933. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_START));
  934. writel_relaxed(vmode->enci.top_field_line_end,
  935. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_END));
  936. writel_relaxed(vmode->enci.bottom_field_line_start,
  937. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_START));
  938. writel_relaxed(vmode->enci.bottom_field_line_end,
  939. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_END));
  940. /* Select ENCI for VIU */
  941. meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCI);
  942. /* Interlace video enable */
  943. writel_relaxed(1, priv->io_base + _REG(ENCI_VIDEO_EN));
  944. lines_f0 = mode->vtotal >> 1;
  945. lines_f1 = lines_f0 + 1;
  946. de_h_begin = modulo(readl_relaxed(priv->io_base +
  947. _REG(ENCI_VFIFO2VD_PIXEL_START))
  948. + venc_hdmi_latency,
  949. total_pixels_venc);
  950. de_h_end = modulo(de_h_begin + active_pixels_venc,
  951. total_pixels_venc);
  952. writel_relaxed(de_h_begin,
  953. priv->io_base + _REG(ENCI_DE_H_BEGIN));
  954. writel_relaxed(de_h_end,
  955. priv->io_base + _REG(ENCI_DE_H_END));
  956. de_v_begin_even = readl_relaxed(priv->io_base +
  957. _REG(ENCI_VFIFO2VD_LINE_TOP_START));
  958. de_v_end_even = de_v_begin_even + mode->vdisplay;
  959. de_v_begin_odd = readl_relaxed(priv->io_base +
  960. _REG(ENCI_VFIFO2VD_LINE_BOT_START));
  961. de_v_end_odd = de_v_begin_odd + mode->vdisplay;
  962. writel_relaxed(de_v_begin_even,
  963. priv->io_base + _REG(ENCI_DE_V_BEGIN_EVEN));
  964. writel_relaxed(de_v_end_even,
  965. priv->io_base + _REG(ENCI_DE_V_END_EVEN));
  966. writel_relaxed(de_v_begin_odd,
  967. priv->io_base + _REG(ENCI_DE_V_BEGIN_ODD));
  968. writel_relaxed(de_v_end_odd,
  969. priv->io_base + _REG(ENCI_DE_V_END_ODD));
  970. /* Program Hsync timing */
  971. hs_begin = de_h_end + front_porch_venc;
  972. if (de_h_end + front_porch_venc >= total_pixels_venc) {
  973. hs_begin -= total_pixels_venc;
  974. vs_adjust = 1;
  975. } else {
  976. hs_begin = de_h_end + front_porch_venc;
  977. vs_adjust = 0;
  978. }
  979. hs_end = modulo(hs_begin + hsync_pixels_venc,
  980. total_pixels_venc);
  981. writel_relaxed(hs_begin,
  982. priv->io_base + _REG(ENCI_DVI_HSO_BEGIN));
  983. writel_relaxed(hs_end,
  984. priv->io_base + _REG(ENCI_DVI_HSO_END));
  985. /* Program Vsync timing for even field */
  986. if (((de_v_end_odd - 1) + eof_lines + vs_adjust) >= lines_f1) {
  987. vs_bline_evn = (de_v_end_odd - 1)
  988. + eof_lines
  989. + vs_adjust
  990. - lines_f1;
  991. vs_eline_evn = vs_bline_evn + vsync_lines;
  992. writel_relaxed(vs_bline_evn,
  993. priv->io_base + _REG(ENCI_DVI_VSO_BLINE_EVN));
  994. writel_relaxed(vs_eline_evn,
  995. priv->io_base + _REG(ENCI_DVI_VSO_ELINE_EVN));
  996. writel_relaxed(hs_begin,
  997. priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_EVN));
  998. writel_relaxed(hs_begin,
  999. priv->io_base + _REG(ENCI_DVI_VSO_END_EVN));
  1000. } else {
  1001. vs_bline_odd = (de_v_end_odd - 1)
  1002. + eof_lines
  1003. + vs_adjust;
  1004. writel_relaxed(vs_bline_odd,
  1005. priv->io_base + _REG(ENCI_DVI_VSO_BLINE_ODD));
  1006. writel_relaxed(hs_begin,
  1007. priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_ODD));
  1008. if ((vs_bline_odd + vsync_lines) >= lines_f1) {
  1009. vs_eline_evn = vs_bline_odd
  1010. + vsync_lines
  1011. - lines_f1;
  1012. writel_relaxed(vs_eline_evn, priv->io_base
  1013. + _REG(ENCI_DVI_VSO_ELINE_EVN));
  1014. writel_relaxed(hs_begin, priv->io_base
  1015. + _REG(ENCI_DVI_VSO_END_EVN));
  1016. } else {
  1017. vs_eline_odd = vs_bline_odd
  1018. + vsync_lines;
  1019. writel_relaxed(vs_eline_odd, priv->io_base
  1020. + _REG(ENCI_DVI_VSO_ELINE_ODD));
  1021. writel_relaxed(hs_begin, priv->io_base
  1022. + _REG(ENCI_DVI_VSO_END_ODD));
  1023. }
  1024. }
  1025. /* Program Vsync timing for odd field */
  1026. if (((de_v_end_even - 1) + (eof_lines + 1)) >= lines_f0) {
  1027. vs_bline_odd = (de_v_end_even - 1)
  1028. + (eof_lines + 1)
  1029. - lines_f0;
  1030. vs_eline_odd = vs_bline_odd + vsync_lines;
  1031. writel_relaxed(vs_bline_odd,
  1032. priv->io_base + _REG(ENCI_DVI_VSO_BLINE_ODD));
  1033. writel_relaxed(vs_eline_odd,
  1034. priv->io_base + _REG(ENCI_DVI_VSO_ELINE_ODD));
  1035. vso_begin_odd = modulo(hs_begin
  1036. + (total_pixels_venc >> 1),
  1037. total_pixels_venc);
  1038. writel_relaxed(vso_begin_odd,
  1039. priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_ODD));
  1040. writel_relaxed(vso_begin_odd,
  1041. priv->io_base + _REG(ENCI_DVI_VSO_END_ODD));
  1042. } else {
  1043. vs_bline_evn = (de_v_end_even - 1)
  1044. + (eof_lines + 1);
  1045. writel_relaxed(vs_bline_evn,
  1046. priv->io_base + _REG(ENCI_DVI_VSO_BLINE_EVN));
  1047. vso_begin_evn = modulo(hs_begin
  1048. + (total_pixels_venc >> 1),
  1049. total_pixels_venc);
  1050. writel_relaxed(vso_begin_evn, priv->io_base
  1051. + _REG(ENCI_DVI_VSO_BEGIN_EVN));
  1052. if (vs_bline_evn + vsync_lines >= lines_f0) {
  1053. vs_eline_odd = vs_bline_evn
  1054. + vsync_lines
  1055. - lines_f0;
  1056. writel_relaxed(vs_eline_odd, priv->io_base
  1057. + _REG(ENCI_DVI_VSO_ELINE_ODD));
  1058. writel_relaxed(vso_begin_evn, priv->io_base
  1059. + _REG(ENCI_DVI_VSO_END_ODD));
  1060. } else {
  1061. vs_eline_evn = vs_bline_evn + vsync_lines;
  1062. writel_relaxed(vs_eline_evn, priv->io_base
  1063. + _REG(ENCI_DVI_VSO_ELINE_EVN));
  1064. writel_relaxed(vso_begin_evn, priv->io_base
  1065. + _REG(ENCI_DVI_VSO_END_EVN));
  1066. }
  1067. }
  1068. } else {
  1069. writel_relaxed(vmode->encp.dvi_settings,
  1070. priv->io_base + _REG(VENC_DVI_SETTING));
  1071. writel_relaxed(vmode->encp.video_mode,
  1072. priv->io_base + _REG(ENCP_VIDEO_MODE));
  1073. writel_relaxed(vmode->encp.video_mode_adv,
  1074. priv->io_base + _REG(ENCP_VIDEO_MODE_ADV));
  1075. if (vmode->encp.video_prog_mode_present)
  1076. writel_relaxed(vmode->encp.video_prog_mode,
  1077. priv->io_base + _REG(VENC_VIDEO_PROG_MODE));
  1078. if (vmode->encp.video_sync_mode_present)
  1079. writel_relaxed(vmode->encp.video_sync_mode,
  1080. priv->io_base + _REG(ENCP_VIDEO_SYNC_MODE));
  1081. if (vmode->encp.video_yc_dly_present)
  1082. writel_relaxed(vmode->encp.video_yc_dly,
  1083. priv->io_base + _REG(ENCP_VIDEO_YC_DLY));
  1084. if (vmode->encp.video_rgb_ctrl_present)
  1085. writel_relaxed(vmode->encp.video_rgb_ctrl,
  1086. priv->io_base + _REG(ENCP_VIDEO_RGB_CTRL));
  1087. if (vmode->encp.video_filt_ctrl_present)
  1088. writel_relaxed(vmode->encp.video_filt_ctrl,
  1089. priv->io_base + _REG(ENCP_VIDEO_FILT_CTRL));
  1090. if (vmode->encp.video_ofld_voav_ofst_present)
  1091. writel_relaxed(vmode->encp.video_ofld_voav_ofst,
  1092. priv->io_base
  1093. + _REG(ENCP_VIDEO_OFLD_VOAV_OFST));
  1094. writel_relaxed(vmode->encp.yfp1_htime,
  1095. priv->io_base + _REG(ENCP_VIDEO_YFP1_HTIME));
  1096. writel_relaxed(vmode->encp.yfp2_htime,
  1097. priv->io_base + _REG(ENCP_VIDEO_YFP2_HTIME));
  1098. writel_relaxed(vmode->encp.max_pxcnt,
  1099. priv->io_base + _REG(ENCP_VIDEO_MAX_PXCNT));
  1100. writel_relaxed(vmode->encp.hspuls_begin,
  1101. priv->io_base + _REG(ENCP_VIDEO_HSPULS_BEGIN));
  1102. writel_relaxed(vmode->encp.hspuls_end,
  1103. priv->io_base + _REG(ENCP_VIDEO_HSPULS_END));
  1104. writel_relaxed(vmode->encp.hspuls_switch,
  1105. priv->io_base + _REG(ENCP_VIDEO_HSPULS_SWITCH));
  1106. writel_relaxed(vmode->encp.vspuls_begin,
  1107. priv->io_base + _REG(ENCP_VIDEO_VSPULS_BEGIN));
  1108. writel_relaxed(vmode->encp.vspuls_end,
  1109. priv->io_base + _REG(ENCP_VIDEO_VSPULS_END));
  1110. writel_relaxed(vmode->encp.vspuls_bline,
  1111. priv->io_base + _REG(ENCP_VIDEO_VSPULS_BLINE));
  1112. writel_relaxed(vmode->encp.vspuls_eline,
  1113. priv->io_base + _REG(ENCP_VIDEO_VSPULS_ELINE));
  1114. if (vmode->encp.eqpuls_begin_present)
  1115. writel_relaxed(vmode->encp.eqpuls_begin,
  1116. priv->io_base + _REG(ENCP_VIDEO_EQPULS_BEGIN));
  1117. if (vmode->encp.eqpuls_end_present)
  1118. writel_relaxed(vmode->encp.eqpuls_end,
  1119. priv->io_base + _REG(ENCP_VIDEO_EQPULS_END));
  1120. if (vmode->encp.eqpuls_bline_present)
  1121. writel_relaxed(vmode->encp.eqpuls_bline,
  1122. priv->io_base + _REG(ENCP_VIDEO_EQPULS_BLINE));
  1123. if (vmode->encp.eqpuls_eline_present)
  1124. writel_relaxed(vmode->encp.eqpuls_eline,
  1125. priv->io_base + _REG(ENCP_VIDEO_EQPULS_ELINE));
  1126. writel_relaxed(vmode->encp.havon_begin,
  1127. priv->io_base + _REG(ENCP_VIDEO_HAVON_BEGIN));
  1128. writel_relaxed(vmode->encp.havon_end,
  1129. priv->io_base + _REG(ENCP_VIDEO_HAVON_END));
  1130. writel_relaxed(vmode->encp.vavon_bline,
  1131. priv->io_base + _REG(ENCP_VIDEO_VAVON_BLINE));
  1132. writel_relaxed(vmode->encp.vavon_eline,
  1133. priv->io_base + _REG(ENCP_VIDEO_VAVON_ELINE));
  1134. writel_relaxed(vmode->encp.hso_begin,
  1135. priv->io_base + _REG(ENCP_VIDEO_HSO_BEGIN));
  1136. writel_relaxed(vmode->encp.hso_end,
  1137. priv->io_base + _REG(ENCP_VIDEO_HSO_END));
  1138. writel_relaxed(vmode->encp.vso_begin,
  1139. priv->io_base + _REG(ENCP_VIDEO_VSO_BEGIN));
  1140. writel_relaxed(vmode->encp.vso_end,
  1141. priv->io_base + _REG(ENCP_VIDEO_VSO_END));
  1142. writel_relaxed(vmode->encp.vso_bline,
  1143. priv->io_base + _REG(ENCP_VIDEO_VSO_BLINE));
  1144. if (vmode->encp.vso_eline_present)
  1145. writel_relaxed(vmode->encp.vso_eline,
  1146. priv->io_base + _REG(ENCP_VIDEO_VSO_ELINE));
  1147. if (vmode->encp.sy_val_present)
  1148. writel_relaxed(vmode->encp.sy_val,
  1149. priv->io_base + _REG(ENCP_VIDEO_SY_VAL));
  1150. if (vmode->encp.sy2_val_present)
  1151. writel_relaxed(vmode->encp.sy2_val,
  1152. priv->io_base + _REG(ENCP_VIDEO_SY2_VAL));
  1153. writel_relaxed(vmode->encp.max_lncnt,
  1154. priv->io_base + _REG(ENCP_VIDEO_MAX_LNCNT));
  1155. writel_relaxed(1, priv->io_base + _REG(ENCP_VIDEO_EN));
  1156. /* Set DE signal’s polarity is active high */
  1157. writel_bits_relaxed(BIT(14), BIT(14),
  1158. priv->io_base + _REG(ENCP_VIDEO_MODE));
  1159. /* Program DE timing */
  1160. de_h_begin = modulo(readl_relaxed(priv->io_base +
  1161. _REG(ENCP_VIDEO_HAVON_BEGIN))
  1162. + venc_hdmi_latency,
  1163. total_pixels_venc);
  1164. de_h_end = modulo(de_h_begin + active_pixels_venc,
  1165. total_pixels_venc);
  1166. writel_relaxed(de_h_begin,
  1167. priv->io_base + _REG(ENCP_DE_H_BEGIN));
  1168. writel_relaxed(de_h_end,
  1169. priv->io_base + _REG(ENCP_DE_H_END));
  1170. /* Program DE timing for even field */
  1171. de_v_begin_even = readl_relaxed(priv->io_base
  1172. + _REG(ENCP_VIDEO_VAVON_BLINE));
  1173. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  1174. de_v_end_even = de_v_begin_even +
  1175. (mode->vdisplay / 2);
  1176. else
  1177. de_v_end_even = de_v_begin_even + mode->vdisplay;
  1178. writel_relaxed(de_v_begin_even,
  1179. priv->io_base + _REG(ENCP_DE_V_BEGIN_EVEN));
  1180. writel_relaxed(de_v_end_even,
  1181. priv->io_base + _REG(ENCP_DE_V_END_EVEN));
  1182. /* Program DE timing for odd field if needed */
  1183. if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
  1184. unsigned int ofld_voav_ofst =
  1185. readl_relaxed(priv->io_base +
  1186. _REG(ENCP_VIDEO_OFLD_VOAV_OFST));
  1187. de_v_begin_odd = to_signed((ofld_voav_ofst & 0xf0) >> 4)
  1188. + de_v_begin_even
  1189. + ((mode->vtotal - 1) / 2);
  1190. de_v_end_odd = de_v_begin_odd + (mode->vdisplay / 2);
  1191. writel_relaxed(de_v_begin_odd,
  1192. priv->io_base + _REG(ENCP_DE_V_BEGIN_ODD));
  1193. writel_relaxed(de_v_end_odd,
  1194. priv->io_base + _REG(ENCP_DE_V_END_ODD));
  1195. }
  1196. /* Program Hsync timing */
  1197. if ((de_h_end + front_porch_venc) >= total_pixels_venc) {
  1198. hs_begin = de_h_end
  1199. + front_porch_venc
  1200. - total_pixels_venc;
  1201. vs_adjust = 1;
  1202. } else {
  1203. hs_begin = de_h_end
  1204. + front_porch_venc;
  1205. vs_adjust = 0;
  1206. }
  1207. hs_end = modulo(hs_begin + hsync_pixels_venc,
  1208. total_pixels_venc);
  1209. writel_relaxed(hs_begin,
  1210. priv->io_base + _REG(ENCP_DVI_HSO_BEGIN));
  1211. writel_relaxed(hs_end,
  1212. priv->io_base + _REG(ENCP_DVI_HSO_END));
  1213. /* Program Vsync timing for even field */
  1214. if (de_v_begin_even >=
  1215. (sof_lines + vsync_lines + (1 - vs_adjust)))
  1216. vs_bline_evn = de_v_begin_even
  1217. - sof_lines
  1218. - vsync_lines
  1219. - (1 - vs_adjust);
  1220. else
  1221. vs_bline_evn = mode->vtotal
  1222. + de_v_begin_even
  1223. - sof_lines
  1224. - vsync_lines
  1225. - (1 - vs_adjust);
  1226. vs_eline_evn = modulo(vs_bline_evn + vsync_lines,
  1227. mode->vtotal);
  1228. writel_relaxed(vs_bline_evn,
  1229. priv->io_base + _REG(ENCP_DVI_VSO_BLINE_EVN));
  1230. writel_relaxed(vs_eline_evn,
  1231. priv->io_base + _REG(ENCP_DVI_VSO_ELINE_EVN));
  1232. vso_begin_evn = hs_begin;
  1233. writel_relaxed(vso_begin_evn,
  1234. priv->io_base + _REG(ENCP_DVI_VSO_BEGIN_EVN));
  1235. writel_relaxed(vso_begin_evn,
  1236. priv->io_base + _REG(ENCP_DVI_VSO_END_EVN));
  1237. /* Program Vsync timing for odd field if needed */
  1238. if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
  1239. vs_bline_odd = (de_v_begin_odd - 1)
  1240. - sof_lines
  1241. - vsync_lines;
  1242. vs_eline_odd = (de_v_begin_odd - 1)
  1243. - vsync_lines;
  1244. vso_begin_odd = modulo(hs_begin
  1245. + (total_pixels_venc >> 1),
  1246. total_pixels_venc);
  1247. writel_relaxed(vs_bline_odd,
  1248. priv->io_base + _REG(ENCP_DVI_VSO_BLINE_ODD));
  1249. writel_relaxed(vs_eline_odd,
  1250. priv->io_base + _REG(ENCP_DVI_VSO_ELINE_ODD));
  1251. writel_relaxed(vso_begin_odd,
  1252. priv->io_base + _REG(ENCP_DVI_VSO_BEGIN_ODD));
  1253. writel_relaxed(vso_begin_odd,
  1254. priv->io_base + _REG(ENCP_DVI_VSO_END_ODD));
  1255. }
  1256. /* Select ENCP for VIU */
  1257. meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCP);
  1258. }
  1259. writel_relaxed((use_enci ? 1 : 2) |
  1260. (mode->flags & DRM_MODE_FLAG_PHSYNC ? 1 << 2 : 0) |
  1261. (mode->flags & DRM_MODE_FLAG_PVSYNC ? 1 << 3 : 0) |
  1262. 4 << 5 |
  1263. (venc_repeat ? 1 << 8 : 0) |
  1264. (hdmi_repeat ? 1 << 12 : 0),
  1265. priv->io_base + _REG(VPU_HDMI_SETTING));
  1266. priv->venc.hdmi_repeat = hdmi_repeat;
  1267. priv->venc.venc_repeat = venc_repeat;
  1268. priv->venc.hdmi_use_enci = use_enci;
  1269. priv->venc.current_mode = MESON_VENC_MODE_HDMI;
  1270. }
  1271. EXPORT_SYMBOL_GPL(meson_venc_hdmi_mode_set);
  1272. void meson_venci_cvbs_mode_set(struct meson_drm *priv,
  1273. struct meson_cvbs_enci_mode *mode)
  1274. {
  1275. if (mode->mode_tag == priv->venc.current_mode)
  1276. return;
  1277. /* CVBS Filter settings */
  1278. writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL));
  1279. writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL2));
  1280. /* Digital Video Select : Interlace, clk27 clk, external */
  1281. writel_relaxed(0, priv->io_base + _REG(VENC_DVI_SETTING));
  1282. /* Reset Video Mode */
  1283. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE));
  1284. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV));
  1285. /* Horizontal sync signal output */
  1286. writel_relaxed(mode->hso_begin,
  1287. priv->io_base + _REG(ENCI_SYNC_HSO_BEGIN));
  1288. writel_relaxed(mode->hso_end,
  1289. priv->io_base + _REG(ENCI_SYNC_HSO_END));
  1290. /* Vertical Sync lines */
  1291. writel_relaxed(mode->vso_even,
  1292. priv->io_base + _REG(ENCI_SYNC_VSO_EVNLN));
  1293. writel_relaxed(mode->vso_odd,
  1294. priv->io_base + _REG(ENCI_SYNC_VSO_ODDLN));
  1295. /* Macrovision max amplitude change */
  1296. writel_relaxed(0x8100 + mode->macv_max_amp,
  1297. priv->io_base + _REG(ENCI_MACV_MAX_AMP));
  1298. /* Video mode */
  1299. writel_relaxed(mode->video_prog_mode,
  1300. priv->io_base + _REG(VENC_VIDEO_PROG_MODE));
  1301. writel_relaxed(mode->video_mode,
  1302. priv->io_base + _REG(ENCI_VIDEO_MODE));
  1303. /* Advanced Video Mode :
  1304. * Demux shifting 0x2
  1305. * Blank line end at line17/22
  1306. * High bandwidth Luma Filter
  1307. * Low bandwidth Chroma Filter
  1308. * Bypass luma low pass filter
  1309. * No macrovision on CSYNC
  1310. */
  1311. writel_relaxed(0x26, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV));
  1312. writel(mode->sch_adjust, priv->io_base + _REG(ENCI_VIDEO_SCH));
  1313. /* Sync mode : MASTER Master mode, free run, send HSO/VSO out */
  1314. writel_relaxed(0x07, priv->io_base + _REG(ENCI_SYNC_MODE));
  1315. /* 0x3 Y, C, and Component Y delay */
  1316. writel_relaxed(mode->yc_delay, priv->io_base + _REG(ENCI_YC_DELAY));
  1317. /* Timings */
  1318. writel_relaxed(mode->pixel_start,
  1319. priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_START));
  1320. writel_relaxed(mode->pixel_end,
  1321. priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_END));
  1322. writel_relaxed(mode->top_field_line_start,
  1323. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_START));
  1324. writel_relaxed(mode->top_field_line_end,
  1325. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_END));
  1326. writel_relaxed(mode->bottom_field_line_start,
  1327. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_START));
  1328. writel_relaxed(mode->bottom_field_line_end,
  1329. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_END));
  1330. /* Internal Venc, Internal VIU Sync, Internal Vencoder */
  1331. writel_relaxed(0, priv->io_base + _REG(VENC_SYNC_ROUTE));
  1332. /* UNreset Interlaced TV Encoder */
  1333. writel_relaxed(0, priv->io_base + _REG(ENCI_DBG_PX_RST));
  1334. /* Enable Vfifo2vd, Y_Cb_Y_Cr select */
  1335. writel_relaxed(0x4e01, priv->io_base + _REG(ENCI_VFIFO2VD_CTL));
  1336. /* Power UP Dacs */
  1337. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_SETTING));
  1338. /* Video Upsampling */
  1339. writel_relaxed(0x0061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL0));
  1340. writel_relaxed(0x4061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL1));
  1341. writel_relaxed(0x5061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL2));
  1342. /* Select Interlace Y DACs */
  1343. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL0));
  1344. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL1));
  1345. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL2));
  1346. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL3));
  1347. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL4));
  1348. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL5));
  1349. /* Select ENCI for VIU */
  1350. meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCI);
  1351. /* Enable ENCI FIFO */
  1352. writel_relaxed(0x2000, priv->io_base + _REG(VENC_VDAC_FIFO_CTRL));
  1353. /* Select ENCI DACs 0, 1, 4, and 5 */
  1354. writel_relaxed(0x11, priv->io_base + _REG(ENCI_DACSEL_0));
  1355. writel_relaxed(0x11, priv->io_base + _REG(ENCI_DACSEL_1));
  1356. /* Interlace video enable */
  1357. writel_relaxed(1, priv->io_base + _REG(ENCI_VIDEO_EN));
  1358. /* Configure Video Saturation / Contrast / Brightness / Hue */
  1359. writel_relaxed(mode->video_saturation,
  1360. priv->io_base + _REG(ENCI_VIDEO_SAT));
  1361. writel_relaxed(mode->video_contrast,
  1362. priv->io_base + _REG(ENCI_VIDEO_CONT));
  1363. writel_relaxed(mode->video_brightness,
  1364. priv->io_base + _REG(ENCI_VIDEO_BRIGHT));
  1365. writel_relaxed(mode->video_hue,
  1366. priv->io_base + _REG(ENCI_VIDEO_HUE));
  1367. /* Enable DAC0 Filter */
  1368. writel_relaxed(0x1, priv->io_base + _REG(VENC_VDAC_DAC0_FILT_CTRL0));
  1369. writel_relaxed(0xfc48, priv->io_base + _REG(VENC_VDAC_DAC0_FILT_CTRL1));
  1370. /* 0 in Macrovision register 0 */
  1371. writel_relaxed(0, priv->io_base + _REG(ENCI_MACV_N0));
  1372. /* Analog Synchronization and color burst value adjust */
  1373. writel_relaxed(mode->analog_sync_adj,
  1374. priv->io_base + _REG(ENCI_SYNC_ADJ));
  1375. priv->venc.current_mode = mode->mode_tag;
  1376. }
  1377. /* Returns the current ENCI field polarity */
  1378. unsigned int meson_venci_get_field(struct meson_drm *priv)
  1379. {
  1380. return readl_relaxed(priv->io_base + _REG(ENCI_INFO_READ)) & BIT(29);
  1381. }
  1382. void meson_venc_enable_vsync(struct meson_drm *priv)
  1383. {
  1384. writel_relaxed(2, priv->io_base + _REG(VENC_INTCTRL));
  1385. regmap_update_bits(priv->hhi, HHI_GCLK_MPEG2, BIT(25), BIT(25));
  1386. }
  1387. void meson_venc_disable_vsync(struct meson_drm *priv)
  1388. {
  1389. regmap_update_bits(priv->hhi, HHI_GCLK_MPEG2, BIT(25), 0);
  1390. writel_relaxed(0, priv->io_base + _REG(VENC_INTCTRL));
  1391. }
  1392. void meson_venc_init(struct meson_drm *priv)
  1393. {
  1394. /* Disable CVBS VDAC */
  1395. regmap_write(priv->hhi, HHI_VDAC_CNTL0, 0);
  1396. regmap_write(priv->hhi, HHI_VDAC_CNTL1, 8);
  1397. /* Power Down Dacs */
  1398. writel_relaxed(0xff, priv->io_base + _REG(VENC_VDAC_SETTING));
  1399. /* Disable HDMI PHY */
  1400. regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0);
  1401. /* Disable HDMI */
  1402. writel_bits_relaxed(0x3, 0,
  1403. priv->io_base + _REG(VPU_HDMI_SETTING));
  1404. /* Disable all encoders */
  1405. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_EN));
  1406. writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN));
  1407. writel_relaxed(0, priv->io_base + _REG(ENCL_VIDEO_EN));
  1408. /* Disable VSync IRQ */
  1409. meson_venc_disable_vsync(priv);
  1410. priv->venc.current_mode = MESON_VENC_MODE_NONE;
  1411. }