meson_venc.c 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568
  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. if (meson_venc_hdmi_supported_vic(vic)) {
  823. vmode = meson_venc_hdmi_get_vic_vmode(vic);
  824. if (!vmode) {
  825. dev_err(priv->dev, "%s: Fatal Error, unsupported mode "
  826. DRM_MODE_FMT "\n", __func__,
  827. DRM_MODE_ARG(mode));
  828. return;
  829. }
  830. } else {
  831. meson_venc_hdmi_get_dmt_vmode(mode, &vmode_dmt);
  832. vmode = &vmode_dmt;
  833. }
  834. /* Use VENCI for 480i and 576i and double HDMI pixels */
  835. if (mode->flags & DRM_MODE_FLAG_DBLCLK) {
  836. hdmi_repeat = true;
  837. use_enci = true;
  838. venc_hdmi_latency = 1;
  839. }
  840. /* Repeat VENC pixels for 480/576i/p, 720p50/60 and 1080p50/60 */
  841. if (meson_venc_hdmi_venc_repeat(vic))
  842. venc_repeat = true;
  843. eof_lines = mode->vsync_start - mode->vdisplay;
  844. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  845. eof_lines /= 2;
  846. sof_lines = mode->vtotal - mode->vsync_end;
  847. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  848. sof_lines /= 2;
  849. vsync_lines = mode->vsync_end - mode->vsync_start;
  850. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  851. vsync_lines /= 2;
  852. total_pixels_venc = mode->htotal;
  853. if (hdmi_repeat)
  854. total_pixels_venc /= 2;
  855. if (venc_repeat)
  856. total_pixels_venc *= 2;
  857. active_pixels_venc = mode->hdisplay;
  858. if (hdmi_repeat)
  859. active_pixels_venc /= 2;
  860. if (venc_repeat)
  861. active_pixels_venc *= 2;
  862. front_porch_venc = (mode->hsync_start - mode->hdisplay);
  863. if (hdmi_repeat)
  864. front_porch_venc /= 2;
  865. if (venc_repeat)
  866. front_porch_venc *= 2;
  867. hsync_pixels_venc = (mode->hsync_end - mode->hsync_start);
  868. if (hdmi_repeat)
  869. hsync_pixels_venc /= 2;
  870. if (venc_repeat)
  871. hsync_pixels_venc *= 2;
  872. /* Disable VDACs */
  873. writel_bits_relaxed(0xff, 0xff,
  874. priv->io_base + _REG(VENC_VDAC_SETTING));
  875. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_EN));
  876. writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN));
  877. if (use_enci) {
  878. unsigned int lines_f0;
  879. unsigned int lines_f1;
  880. /* CVBS Filter settings */
  881. writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL));
  882. writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL2));
  883. /* Digital Video Select : Interlace, clk27 clk, external */
  884. writel_relaxed(0, priv->io_base + _REG(VENC_DVI_SETTING));
  885. /* Reset Video Mode */
  886. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE));
  887. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV));
  888. /* Horizontal sync signal output */
  889. writel_relaxed(vmode->enci.hso_begin,
  890. priv->io_base + _REG(ENCI_SYNC_HSO_BEGIN));
  891. writel_relaxed(vmode->enci.hso_end,
  892. priv->io_base + _REG(ENCI_SYNC_HSO_END));
  893. /* Vertical Sync lines */
  894. writel_relaxed(vmode->enci.vso_even,
  895. priv->io_base + _REG(ENCI_SYNC_VSO_EVNLN));
  896. writel_relaxed(vmode->enci.vso_odd,
  897. priv->io_base + _REG(ENCI_SYNC_VSO_ODDLN));
  898. /* Macrovision max amplitude change */
  899. writel_relaxed(vmode->enci.macv_max_amp,
  900. priv->io_base + _REG(ENCI_MACV_MAX_AMP));
  901. /* Video mode */
  902. writel_relaxed(vmode->enci.video_prog_mode,
  903. priv->io_base + _REG(VENC_VIDEO_PROG_MODE));
  904. writel_relaxed(vmode->enci.video_mode,
  905. priv->io_base + _REG(ENCI_VIDEO_MODE));
  906. /* Advanced Video Mode :
  907. * Demux shifting 0x2
  908. * Blank line end at line17/22
  909. * High bandwidth Luma Filter
  910. * Low bandwidth Chroma Filter
  911. * Bypass luma low pass filter
  912. * No macrovision on CSYNC
  913. */
  914. writel_relaxed(0x26, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV));
  915. writel(vmode->enci.sch_adjust,
  916. priv->io_base + _REG(ENCI_VIDEO_SCH));
  917. /* Sync mode : MASTER Master mode, free run, send HSO/VSO out */
  918. writel_relaxed(0x07, priv->io_base + _REG(ENCI_SYNC_MODE));
  919. if (vmode->enci.yc_delay)
  920. writel_relaxed(vmode->enci.yc_delay,
  921. priv->io_base + _REG(ENCI_YC_DELAY));
  922. /* UNreset Interlaced TV Encoder */
  923. writel_relaxed(0, priv->io_base + _REG(ENCI_DBG_PX_RST));
  924. /* Enable Vfifo2vd, Y_Cb_Y_Cr select */
  925. writel_relaxed(0x4e01, priv->io_base + _REG(ENCI_VFIFO2VD_CTL));
  926. /* Timings */
  927. writel_relaxed(vmode->enci.pixel_start,
  928. priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_START));
  929. writel_relaxed(vmode->enci.pixel_end,
  930. priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_END));
  931. writel_relaxed(vmode->enci.top_field_line_start,
  932. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_START));
  933. writel_relaxed(vmode->enci.top_field_line_end,
  934. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_END));
  935. writel_relaxed(vmode->enci.bottom_field_line_start,
  936. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_START));
  937. writel_relaxed(vmode->enci.bottom_field_line_end,
  938. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_END));
  939. /* Select ENCI for VIU */
  940. meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCI);
  941. /* Interlace video enable */
  942. writel_relaxed(1, priv->io_base + _REG(ENCI_VIDEO_EN));
  943. lines_f0 = mode->vtotal >> 1;
  944. lines_f1 = lines_f0 + 1;
  945. de_h_begin = modulo(readl_relaxed(priv->io_base +
  946. _REG(ENCI_VFIFO2VD_PIXEL_START))
  947. + venc_hdmi_latency,
  948. total_pixels_venc);
  949. de_h_end = modulo(de_h_begin + active_pixels_venc,
  950. total_pixels_venc);
  951. writel_relaxed(de_h_begin,
  952. priv->io_base + _REG(ENCI_DE_H_BEGIN));
  953. writel_relaxed(de_h_end,
  954. priv->io_base + _REG(ENCI_DE_H_END));
  955. de_v_begin_even = readl_relaxed(priv->io_base +
  956. _REG(ENCI_VFIFO2VD_LINE_TOP_START));
  957. de_v_end_even = de_v_begin_even + mode->vdisplay;
  958. de_v_begin_odd = readl_relaxed(priv->io_base +
  959. _REG(ENCI_VFIFO2VD_LINE_BOT_START));
  960. de_v_end_odd = de_v_begin_odd + mode->vdisplay;
  961. writel_relaxed(de_v_begin_even,
  962. priv->io_base + _REG(ENCI_DE_V_BEGIN_EVEN));
  963. writel_relaxed(de_v_end_even,
  964. priv->io_base + _REG(ENCI_DE_V_END_EVEN));
  965. writel_relaxed(de_v_begin_odd,
  966. priv->io_base + _REG(ENCI_DE_V_BEGIN_ODD));
  967. writel_relaxed(de_v_end_odd,
  968. priv->io_base + _REG(ENCI_DE_V_END_ODD));
  969. /* Program Hsync timing */
  970. hs_begin = de_h_end + front_porch_venc;
  971. if (de_h_end + front_porch_venc >= total_pixels_venc) {
  972. hs_begin -= total_pixels_venc;
  973. vs_adjust = 1;
  974. } else {
  975. hs_begin = de_h_end + front_porch_venc;
  976. vs_adjust = 0;
  977. }
  978. hs_end = modulo(hs_begin + hsync_pixels_venc,
  979. total_pixels_venc);
  980. writel_relaxed(hs_begin,
  981. priv->io_base + _REG(ENCI_DVI_HSO_BEGIN));
  982. writel_relaxed(hs_end,
  983. priv->io_base + _REG(ENCI_DVI_HSO_END));
  984. /* Program Vsync timing for even field */
  985. if (((de_v_end_odd - 1) + eof_lines + vs_adjust) >= lines_f1) {
  986. vs_bline_evn = (de_v_end_odd - 1)
  987. + eof_lines
  988. + vs_adjust
  989. - lines_f1;
  990. vs_eline_evn = vs_bline_evn + vsync_lines;
  991. writel_relaxed(vs_bline_evn,
  992. priv->io_base + _REG(ENCI_DVI_VSO_BLINE_EVN));
  993. writel_relaxed(vs_eline_evn,
  994. priv->io_base + _REG(ENCI_DVI_VSO_ELINE_EVN));
  995. writel_relaxed(hs_begin,
  996. priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_EVN));
  997. writel_relaxed(hs_begin,
  998. priv->io_base + _REG(ENCI_DVI_VSO_END_EVN));
  999. } else {
  1000. vs_bline_odd = (de_v_end_odd - 1)
  1001. + eof_lines
  1002. + vs_adjust;
  1003. writel_relaxed(vs_bline_odd,
  1004. priv->io_base + _REG(ENCI_DVI_VSO_BLINE_ODD));
  1005. writel_relaxed(hs_begin,
  1006. priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_ODD));
  1007. if ((vs_bline_odd + vsync_lines) >= lines_f1) {
  1008. vs_eline_evn = vs_bline_odd
  1009. + vsync_lines
  1010. - lines_f1;
  1011. writel_relaxed(vs_eline_evn, priv->io_base
  1012. + _REG(ENCI_DVI_VSO_ELINE_EVN));
  1013. writel_relaxed(hs_begin, priv->io_base
  1014. + _REG(ENCI_DVI_VSO_END_EVN));
  1015. } else {
  1016. vs_eline_odd = vs_bline_odd
  1017. + vsync_lines;
  1018. writel_relaxed(vs_eline_odd, priv->io_base
  1019. + _REG(ENCI_DVI_VSO_ELINE_ODD));
  1020. writel_relaxed(hs_begin, priv->io_base
  1021. + _REG(ENCI_DVI_VSO_END_ODD));
  1022. }
  1023. }
  1024. /* Program Vsync timing for odd field */
  1025. if (((de_v_end_even - 1) + (eof_lines + 1)) >= lines_f0) {
  1026. vs_bline_odd = (de_v_end_even - 1)
  1027. + (eof_lines + 1)
  1028. - lines_f0;
  1029. vs_eline_odd = vs_bline_odd + vsync_lines;
  1030. writel_relaxed(vs_bline_odd,
  1031. priv->io_base + _REG(ENCI_DVI_VSO_BLINE_ODD));
  1032. writel_relaxed(vs_eline_odd,
  1033. priv->io_base + _REG(ENCI_DVI_VSO_ELINE_ODD));
  1034. vso_begin_odd = modulo(hs_begin
  1035. + (total_pixels_venc >> 1),
  1036. total_pixels_venc);
  1037. writel_relaxed(vso_begin_odd,
  1038. priv->io_base + _REG(ENCI_DVI_VSO_BEGIN_ODD));
  1039. writel_relaxed(vso_begin_odd,
  1040. priv->io_base + _REG(ENCI_DVI_VSO_END_ODD));
  1041. } else {
  1042. vs_bline_evn = (de_v_end_even - 1)
  1043. + (eof_lines + 1);
  1044. writel_relaxed(vs_bline_evn,
  1045. priv->io_base + _REG(ENCI_DVI_VSO_BLINE_EVN));
  1046. vso_begin_evn = modulo(hs_begin
  1047. + (total_pixels_venc >> 1),
  1048. total_pixels_venc);
  1049. writel_relaxed(vso_begin_evn, priv->io_base
  1050. + _REG(ENCI_DVI_VSO_BEGIN_EVN));
  1051. if (vs_bline_evn + vsync_lines >= lines_f0) {
  1052. vs_eline_odd = vs_bline_evn
  1053. + vsync_lines
  1054. - lines_f0;
  1055. writel_relaxed(vs_eline_odd, priv->io_base
  1056. + _REG(ENCI_DVI_VSO_ELINE_ODD));
  1057. writel_relaxed(vso_begin_evn, priv->io_base
  1058. + _REG(ENCI_DVI_VSO_END_ODD));
  1059. } else {
  1060. vs_eline_evn = vs_bline_evn + vsync_lines;
  1061. writel_relaxed(vs_eline_evn, priv->io_base
  1062. + _REG(ENCI_DVI_VSO_ELINE_EVN));
  1063. writel_relaxed(vso_begin_evn, priv->io_base
  1064. + _REG(ENCI_DVI_VSO_END_EVN));
  1065. }
  1066. }
  1067. } else {
  1068. writel_relaxed(vmode->encp.dvi_settings,
  1069. priv->io_base + _REG(VENC_DVI_SETTING));
  1070. writel_relaxed(vmode->encp.video_mode,
  1071. priv->io_base + _REG(ENCP_VIDEO_MODE));
  1072. writel_relaxed(vmode->encp.video_mode_adv,
  1073. priv->io_base + _REG(ENCP_VIDEO_MODE_ADV));
  1074. if (vmode->encp.video_prog_mode_present)
  1075. writel_relaxed(vmode->encp.video_prog_mode,
  1076. priv->io_base + _REG(VENC_VIDEO_PROG_MODE));
  1077. if (vmode->encp.video_sync_mode_present)
  1078. writel_relaxed(vmode->encp.video_sync_mode,
  1079. priv->io_base + _REG(ENCP_VIDEO_SYNC_MODE));
  1080. if (vmode->encp.video_yc_dly_present)
  1081. writel_relaxed(vmode->encp.video_yc_dly,
  1082. priv->io_base + _REG(ENCP_VIDEO_YC_DLY));
  1083. if (vmode->encp.video_rgb_ctrl_present)
  1084. writel_relaxed(vmode->encp.video_rgb_ctrl,
  1085. priv->io_base + _REG(ENCP_VIDEO_RGB_CTRL));
  1086. if (vmode->encp.video_filt_ctrl_present)
  1087. writel_relaxed(vmode->encp.video_filt_ctrl,
  1088. priv->io_base + _REG(ENCP_VIDEO_FILT_CTRL));
  1089. if (vmode->encp.video_ofld_voav_ofst_present)
  1090. writel_relaxed(vmode->encp.video_ofld_voav_ofst,
  1091. priv->io_base
  1092. + _REG(ENCP_VIDEO_OFLD_VOAV_OFST));
  1093. writel_relaxed(vmode->encp.yfp1_htime,
  1094. priv->io_base + _REG(ENCP_VIDEO_YFP1_HTIME));
  1095. writel_relaxed(vmode->encp.yfp2_htime,
  1096. priv->io_base + _REG(ENCP_VIDEO_YFP2_HTIME));
  1097. writel_relaxed(vmode->encp.max_pxcnt,
  1098. priv->io_base + _REG(ENCP_VIDEO_MAX_PXCNT));
  1099. writel_relaxed(vmode->encp.hspuls_begin,
  1100. priv->io_base + _REG(ENCP_VIDEO_HSPULS_BEGIN));
  1101. writel_relaxed(vmode->encp.hspuls_end,
  1102. priv->io_base + _REG(ENCP_VIDEO_HSPULS_END));
  1103. writel_relaxed(vmode->encp.hspuls_switch,
  1104. priv->io_base + _REG(ENCP_VIDEO_HSPULS_SWITCH));
  1105. writel_relaxed(vmode->encp.vspuls_begin,
  1106. priv->io_base + _REG(ENCP_VIDEO_VSPULS_BEGIN));
  1107. writel_relaxed(vmode->encp.vspuls_end,
  1108. priv->io_base + _REG(ENCP_VIDEO_VSPULS_END));
  1109. writel_relaxed(vmode->encp.vspuls_bline,
  1110. priv->io_base + _REG(ENCP_VIDEO_VSPULS_BLINE));
  1111. writel_relaxed(vmode->encp.vspuls_eline,
  1112. priv->io_base + _REG(ENCP_VIDEO_VSPULS_ELINE));
  1113. if (vmode->encp.eqpuls_begin_present)
  1114. writel_relaxed(vmode->encp.eqpuls_begin,
  1115. priv->io_base + _REG(ENCP_VIDEO_EQPULS_BEGIN));
  1116. if (vmode->encp.eqpuls_end_present)
  1117. writel_relaxed(vmode->encp.eqpuls_end,
  1118. priv->io_base + _REG(ENCP_VIDEO_EQPULS_END));
  1119. if (vmode->encp.eqpuls_bline_present)
  1120. writel_relaxed(vmode->encp.eqpuls_bline,
  1121. priv->io_base + _REG(ENCP_VIDEO_EQPULS_BLINE));
  1122. if (vmode->encp.eqpuls_eline_present)
  1123. writel_relaxed(vmode->encp.eqpuls_eline,
  1124. priv->io_base + _REG(ENCP_VIDEO_EQPULS_ELINE));
  1125. writel_relaxed(vmode->encp.havon_begin,
  1126. priv->io_base + _REG(ENCP_VIDEO_HAVON_BEGIN));
  1127. writel_relaxed(vmode->encp.havon_end,
  1128. priv->io_base + _REG(ENCP_VIDEO_HAVON_END));
  1129. writel_relaxed(vmode->encp.vavon_bline,
  1130. priv->io_base + _REG(ENCP_VIDEO_VAVON_BLINE));
  1131. writel_relaxed(vmode->encp.vavon_eline,
  1132. priv->io_base + _REG(ENCP_VIDEO_VAVON_ELINE));
  1133. writel_relaxed(vmode->encp.hso_begin,
  1134. priv->io_base + _REG(ENCP_VIDEO_HSO_BEGIN));
  1135. writel_relaxed(vmode->encp.hso_end,
  1136. priv->io_base + _REG(ENCP_VIDEO_HSO_END));
  1137. writel_relaxed(vmode->encp.vso_begin,
  1138. priv->io_base + _REG(ENCP_VIDEO_VSO_BEGIN));
  1139. writel_relaxed(vmode->encp.vso_end,
  1140. priv->io_base + _REG(ENCP_VIDEO_VSO_END));
  1141. writel_relaxed(vmode->encp.vso_bline,
  1142. priv->io_base + _REG(ENCP_VIDEO_VSO_BLINE));
  1143. if (vmode->encp.vso_eline_present)
  1144. writel_relaxed(vmode->encp.vso_eline,
  1145. priv->io_base + _REG(ENCP_VIDEO_VSO_ELINE));
  1146. if (vmode->encp.sy_val_present)
  1147. writel_relaxed(vmode->encp.sy_val,
  1148. priv->io_base + _REG(ENCP_VIDEO_SY_VAL));
  1149. if (vmode->encp.sy2_val_present)
  1150. writel_relaxed(vmode->encp.sy2_val,
  1151. priv->io_base + _REG(ENCP_VIDEO_SY2_VAL));
  1152. writel_relaxed(vmode->encp.max_lncnt,
  1153. priv->io_base + _REG(ENCP_VIDEO_MAX_LNCNT));
  1154. writel_relaxed(1, priv->io_base + _REG(ENCP_VIDEO_EN));
  1155. /* Set DE signal’s polarity is active high */
  1156. writel_bits_relaxed(BIT(14), BIT(14),
  1157. priv->io_base + _REG(ENCP_VIDEO_MODE));
  1158. /* Program DE timing */
  1159. de_h_begin = modulo(readl_relaxed(priv->io_base +
  1160. _REG(ENCP_VIDEO_HAVON_BEGIN))
  1161. + venc_hdmi_latency,
  1162. total_pixels_venc);
  1163. de_h_end = modulo(de_h_begin + active_pixels_venc,
  1164. total_pixels_venc);
  1165. writel_relaxed(de_h_begin,
  1166. priv->io_base + _REG(ENCP_DE_H_BEGIN));
  1167. writel_relaxed(de_h_end,
  1168. priv->io_base + _REG(ENCP_DE_H_END));
  1169. /* Program DE timing for even field */
  1170. de_v_begin_even = readl_relaxed(priv->io_base
  1171. + _REG(ENCP_VIDEO_VAVON_BLINE));
  1172. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  1173. de_v_end_even = de_v_begin_even +
  1174. (mode->vdisplay / 2);
  1175. else
  1176. de_v_end_even = de_v_begin_even + mode->vdisplay;
  1177. writel_relaxed(de_v_begin_even,
  1178. priv->io_base + _REG(ENCP_DE_V_BEGIN_EVEN));
  1179. writel_relaxed(de_v_end_even,
  1180. priv->io_base + _REG(ENCP_DE_V_END_EVEN));
  1181. /* Program DE timing for odd field if needed */
  1182. if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
  1183. unsigned int ofld_voav_ofst =
  1184. readl_relaxed(priv->io_base +
  1185. _REG(ENCP_VIDEO_OFLD_VOAV_OFST));
  1186. de_v_begin_odd = to_signed((ofld_voav_ofst & 0xf0) >> 4)
  1187. + de_v_begin_even
  1188. + ((mode->vtotal - 1) / 2);
  1189. de_v_end_odd = de_v_begin_odd + (mode->vdisplay / 2);
  1190. writel_relaxed(de_v_begin_odd,
  1191. priv->io_base + _REG(ENCP_DE_V_BEGIN_ODD));
  1192. writel_relaxed(de_v_end_odd,
  1193. priv->io_base + _REG(ENCP_DE_V_END_ODD));
  1194. }
  1195. /* Program Hsync timing */
  1196. if ((de_h_end + front_porch_venc) >= total_pixels_venc) {
  1197. hs_begin = de_h_end
  1198. + front_porch_venc
  1199. - total_pixels_venc;
  1200. vs_adjust = 1;
  1201. } else {
  1202. hs_begin = de_h_end
  1203. + front_porch_venc;
  1204. vs_adjust = 0;
  1205. }
  1206. hs_end = modulo(hs_begin + hsync_pixels_venc,
  1207. total_pixels_venc);
  1208. writel_relaxed(hs_begin,
  1209. priv->io_base + _REG(ENCP_DVI_HSO_BEGIN));
  1210. writel_relaxed(hs_end,
  1211. priv->io_base + _REG(ENCP_DVI_HSO_END));
  1212. /* Program Vsync timing for even field */
  1213. if (de_v_begin_even >=
  1214. (sof_lines + vsync_lines + (1 - vs_adjust)))
  1215. vs_bline_evn = de_v_begin_even
  1216. - sof_lines
  1217. - vsync_lines
  1218. - (1 - vs_adjust);
  1219. else
  1220. vs_bline_evn = mode->vtotal
  1221. + de_v_begin_even
  1222. - sof_lines
  1223. - vsync_lines
  1224. - (1 - vs_adjust);
  1225. vs_eline_evn = modulo(vs_bline_evn + vsync_lines,
  1226. mode->vtotal);
  1227. writel_relaxed(vs_bline_evn,
  1228. priv->io_base + _REG(ENCP_DVI_VSO_BLINE_EVN));
  1229. writel_relaxed(vs_eline_evn,
  1230. priv->io_base + _REG(ENCP_DVI_VSO_ELINE_EVN));
  1231. vso_begin_evn = hs_begin;
  1232. writel_relaxed(vso_begin_evn,
  1233. priv->io_base + _REG(ENCP_DVI_VSO_BEGIN_EVN));
  1234. writel_relaxed(vso_begin_evn,
  1235. priv->io_base + _REG(ENCP_DVI_VSO_END_EVN));
  1236. /* Program Vsync timing for odd field if needed */
  1237. if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
  1238. vs_bline_odd = (de_v_begin_odd - 1)
  1239. - sof_lines
  1240. - vsync_lines;
  1241. vs_eline_odd = (de_v_begin_odd - 1)
  1242. - vsync_lines;
  1243. vso_begin_odd = modulo(hs_begin
  1244. + (total_pixels_venc >> 1),
  1245. total_pixels_venc);
  1246. writel_relaxed(vs_bline_odd,
  1247. priv->io_base + _REG(ENCP_DVI_VSO_BLINE_ODD));
  1248. writel_relaxed(vs_eline_odd,
  1249. priv->io_base + _REG(ENCP_DVI_VSO_ELINE_ODD));
  1250. writel_relaxed(vso_begin_odd,
  1251. priv->io_base + _REG(ENCP_DVI_VSO_BEGIN_ODD));
  1252. writel_relaxed(vso_begin_odd,
  1253. priv->io_base + _REG(ENCP_DVI_VSO_END_ODD));
  1254. }
  1255. /* Select ENCP for VIU */
  1256. meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCP);
  1257. }
  1258. writel_relaxed((use_enci ? 1 : 2) |
  1259. (mode->flags & DRM_MODE_FLAG_PHSYNC ? 1 << 2 : 0) |
  1260. (mode->flags & DRM_MODE_FLAG_PVSYNC ? 1 << 3 : 0) |
  1261. 4 << 5 |
  1262. (venc_repeat ? 1 << 8 : 0) |
  1263. (hdmi_repeat ? 1 << 12 : 0),
  1264. priv->io_base + _REG(VPU_HDMI_SETTING));
  1265. priv->venc.hdmi_repeat = hdmi_repeat;
  1266. priv->venc.venc_repeat = venc_repeat;
  1267. priv->venc.hdmi_use_enci = use_enci;
  1268. priv->venc.current_mode = MESON_VENC_MODE_HDMI;
  1269. }
  1270. EXPORT_SYMBOL_GPL(meson_venc_hdmi_mode_set);
  1271. void meson_venci_cvbs_mode_set(struct meson_drm *priv,
  1272. struct meson_cvbs_enci_mode *mode)
  1273. {
  1274. if (mode->mode_tag == priv->venc.current_mode)
  1275. return;
  1276. /* CVBS Filter settings */
  1277. writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL));
  1278. writel_relaxed(0x12, priv->io_base + _REG(ENCI_CFILT_CTRL2));
  1279. /* Digital Video Select : Interlace, clk27 clk, external */
  1280. writel_relaxed(0, priv->io_base + _REG(VENC_DVI_SETTING));
  1281. /* Reset Video Mode */
  1282. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE));
  1283. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV));
  1284. /* Horizontal sync signal output */
  1285. writel_relaxed(mode->hso_begin,
  1286. priv->io_base + _REG(ENCI_SYNC_HSO_BEGIN));
  1287. writel_relaxed(mode->hso_end,
  1288. priv->io_base + _REG(ENCI_SYNC_HSO_END));
  1289. /* Vertical Sync lines */
  1290. writel_relaxed(mode->vso_even,
  1291. priv->io_base + _REG(ENCI_SYNC_VSO_EVNLN));
  1292. writel_relaxed(mode->vso_odd,
  1293. priv->io_base + _REG(ENCI_SYNC_VSO_ODDLN));
  1294. /* Macrovision max amplitude change */
  1295. writel_relaxed(0x8100 + mode->macv_max_amp,
  1296. priv->io_base + _REG(ENCI_MACV_MAX_AMP));
  1297. /* Video mode */
  1298. writel_relaxed(mode->video_prog_mode,
  1299. priv->io_base + _REG(VENC_VIDEO_PROG_MODE));
  1300. writel_relaxed(mode->video_mode,
  1301. priv->io_base + _REG(ENCI_VIDEO_MODE));
  1302. /* Advanced Video Mode :
  1303. * Demux shifting 0x2
  1304. * Blank line end at line17/22
  1305. * High bandwidth Luma Filter
  1306. * Low bandwidth Chroma Filter
  1307. * Bypass luma low pass filter
  1308. * No macrovision on CSYNC
  1309. */
  1310. writel_relaxed(0x26, priv->io_base + _REG(ENCI_VIDEO_MODE_ADV));
  1311. writel(mode->sch_adjust, priv->io_base + _REG(ENCI_VIDEO_SCH));
  1312. /* Sync mode : MASTER Master mode, free run, send HSO/VSO out */
  1313. writel_relaxed(0x07, priv->io_base + _REG(ENCI_SYNC_MODE));
  1314. /* 0x3 Y, C, and Component Y delay */
  1315. writel_relaxed(mode->yc_delay, priv->io_base + _REG(ENCI_YC_DELAY));
  1316. /* Timings */
  1317. writel_relaxed(mode->pixel_start,
  1318. priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_START));
  1319. writel_relaxed(mode->pixel_end,
  1320. priv->io_base + _REG(ENCI_VFIFO2VD_PIXEL_END));
  1321. writel_relaxed(mode->top_field_line_start,
  1322. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_START));
  1323. writel_relaxed(mode->top_field_line_end,
  1324. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_TOP_END));
  1325. writel_relaxed(mode->bottom_field_line_start,
  1326. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_START));
  1327. writel_relaxed(mode->bottom_field_line_end,
  1328. priv->io_base + _REG(ENCI_VFIFO2VD_LINE_BOT_END));
  1329. /* Internal Venc, Internal VIU Sync, Internal Vencoder */
  1330. writel_relaxed(0, priv->io_base + _REG(VENC_SYNC_ROUTE));
  1331. /* UNreset Interlaced TV Encoder */
  1332. writel_relaxed(0, priv->io_base + _REG(ENCI_DBG_PX_RST));
  1333. /* Enable Vfifo2vd, Y_Cb_Y_Cr select */
  1334. writel_relaxed(0x4e01, priv->io_base + _REG(ENCI_VFIFO2VD_CTL));
  1335. /* Power UP Dacs */
  1336. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_SETTING));
  1337. /* Video Upsampling */
  1338. writel_relaxed(0x0061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL0));
  1339. writel_relaxed(0x4061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL1));
  1340. writel_relaxed(0x5061, priv->io_base + _REG(VENC_UPSAMPLE_CTRL2));
  1341. /* Select Interlace Y DACs */
  1342. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL0));
  1343. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL1));
  1344. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL2));
  1345. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL3));
  1346. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL4));
  1347. writel_relaxed(0, priv->io_base + _REG(VENC_VDAC_DACSEL5));
  1348. /* Select ENCI for VIU */
  1349. meson_vpp_setup_mux(priv, MESON_VIU_VPP_MUX_ENCI);
  1350. /* Enable ENCI FIFO */
  1351. writel_relaxed(0x2000, priv->io_base + _REG(VENC_VDAC_FIFO_CTRL));
  1352. /* Select ENCI DACs 0, 1, 4, and 5 */
  1353. writel_relaxed(0x11, priv->io_base + _REG(ENCI_DACSEL_0));
  1354. writel_relaxed(0x11, priv->io_base + _REG(ENCI_DACSEL_1));
  1355. /* Interlace video enable */
  1356. writel_relaxed(1, priv->io_base + _REG(ENCI_VIDEO_EN));
  1357. /* Configure Video Saturation / Contrast / Brightness / Hue */
  1358. writel_relaxed(mode->video_saturation,
  1359. priv->io_base + _REG(ENCI_VIDEO_SAT));
  1360. writel_relaxed(mode->video_contrast,
  1361. priv->io_base + _REG(ENCI_VIDEO_CONT));
  1362. writel_relaxed(mode->video_brightness,
  1363. priv->io_base + _REG(ENCI_VIDEO_BRIGHT));
  1364. writel_relaxed(mode->video_hue,
  1365. priv->io_base + _REG(ENCI_VIDEO_HUE));
  1366. /* Enable DAC0 Filter */
  1367. writel_relaxed(0x1, priv->io_base + _REG(VENC_VDAC_DAC0_FILT_CTRL0));
  1368. writel_relaxed(0xfc48, priv->io_base + _REG(VENC_VDAC_DAC0_FILT_CTRL1));
  1369. /* 0 in Macrovision register 0 */
  1370. writel_relaxed(0, priv->io_base + _REG(ENCI_MACV_N0));
  1371. /* Analog Synchronization and color burst value adjust */
  1372. writel_relaxed(mode->analog_sync_adj,
  1373. priv->io_base + _REG(ENCI_SYNC_ADJ));
  1374. priv->venc.current_mode = mode->mode_tag;
  1375. }
  1376. /* Returns the current ENCI field polarity */
  1377. unsigned int meson_venci_get_field(struct meson_drm *priv)
  1378. {
  1379. return readl_relaxed(priv->io_base + _REG(ENCI_INFO_READ)) & BIT(29);
  1380. }
  1381. void meson_venc_enable_vsync(struct meson_drm *priv)
  1382. {
  1383. writel_relaxed(2, priv->io_base + _REG(VENC_INTCTRL));
  1384. regmap_update_bits(priv->hhi, HHI_GCLK_MPEG2, BIT(25), BIT(25));
  1385. }
  1386. void meson_venc_disable_vsync(struct meson_drm *priv)
  1387. {
  1388. regmap_update_bits(priv->hhi, HHI_GCLK_MPEG2, BIT(25), 0);
  1389. writel_relaxed(0, priv->io_base + _REG(VENC_INTCTRL));
  1390. }
  1391. void meson_venc_init(struct meson_drm *priv)
  1392. {
  1393. /* Disable CVBS VDAC */
  1394. regmap_write(priv->hhi, HHI_VDAC_CNTL0, 0);
  1395. regmap_write(priv->hhi, HHI_VDAC_CNTL1, 8);
  1396. /* Power Down Dacs */
  1397. writel_relaxed(0xff, priv->io_base + _REG(VENC_VDAC_SETTING));
  1398. /* Disable HDMI PHY */
  1399. regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0);
  1400. /* Disable HDMI */
  1401. writel_bits_relaxed(0x3, 0,
  1402. priv->io_base + _REG(VPU_HDMI_SETTING));
  1403. /* Disable all encoders */
  1404. writel_relaxed(0, priv->io_base + _REG(ENCI_VIDEO_EN));
  1405. writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN));
  1406. writel_relaxed(0, priv->io_base + _REG(ENCL_VIDEO_EN));
  1407. /* Disable VSync IRQ */
  1408. meson_venc_disable_vsync(priv);
  1409. priv->venc.current_mode = MESON_VENC_MODE_NONE;
  1410. }