ddp_ovl.c 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #define LOG_TAG "OVL"
  32. #include "platform/ddp_reg.h"
  33. #include "platform/ddp_matrix_para.h"
  34. #include "platform/ddp_info.h"
  35. #include "platform/ddp_log.h"
  36. #include "platform/ddp_ovl.h"
  37. #include "platform/disp_drv_platform.h"
  38. #include "platform/mt_gpt.h"
  39. #define OVL_REG_BACK_MAX (40)
  40. #define OVL_LAYER_OFFSET (0x20)
  41. #define OVL_RDMA_DEBUG_OFFSET (0x4)
  42. enum OVL_COLOR_SPACE {
  43. OVL_COLOR_SPACE_RGB = 0,
  44. OVL_COLOR_SPACE_YUV,
  45. };
  46. enum OVL_INPUT_FORMAT {
  47. OVL_INPUT_FORMAT_BGR565 = 0,
  48. OVL_INPUT_FORMAT_RGB888 = 1,
  49. OVL_INPUT_FORMAT_RGBA8888 = 2,
  50. OVL_INPUT_FORMAT_ARGB8888 = 3,
  51. OVL_INPUT_FORMAT_VYUY = 4,
  52. OVL_INPUT_FORMAT_YVYU = 5,
  53. OVL_INPUT_FORMAT_RGB565 = 6,
  54. OVL_INPUT_FORMAT_BGR888 = 7,
  55. OVL_INPUT_FORMAT_BGRA8888 = 8,
  56. OVL_INPUT_FORMAT_ABGR8888 = 9,
  57. OVL_INPUT_FORMAT_UYVY = 10,
  58. OVL_INPUT_FORMAT_YUYV = 11,
  59. OVL_INPUT_FORMAT_RGBA4444 = 12,
  60. OVL_INPUT_FORMAT_BGRA4444 = 13,
  61. OVL_INPUT_FORMAT_UNKNOWN = 32,
  62. };
  63. typedef struct {
  64. unsigned int address;
  65. unsigned int value;
  66. } OVL_REG;
  67. static int reg_back_cnt[OVL_NUM];
  68. static OVL_REG reg_back[OVL_NUM][OVL_REG_BACK_MAX];
  69. static enum OVL_INPUT_FORMAT ovl_input_fmt_convert(DpColorFormat fmt);
  70. static unsigned int ovl_input_fmt_byte_swap(enum OVL_INPUT_FORMAT inputFormat);
  71. static unsigned int ovl_input_fmt_bpp(enum OVL_INPUT_FORMAT inputFormat);
  72. static enum OVL_COLOR_SPACE ovl_input_fmt_color_space(enum OVL_INPUT_FORMAT inputFormat);
  73. static unsigned int ovl_input_fmt_reg_value(enum OVL_INPUT_FORMAT inputFormat);
  74. static void ovl_store_regs(int idx);
  75. static void ovl_restore_regs(int idx,void * handle);
  76. static enum OVL_INPUT_FORMAT ovl_input_fmt_convert(DpColorFormat fmt)
  77. {
  78. enum OVL_INPUT_FORMAT ovl_fmt = OVL_INPUT_FORMAT_UNKNOWN;
  79. switch (fmt) {
  80. case eBGR565:
  81. ovl_fmt = OVL_INPUT_FORMAT_BGR565;
  82. break;
  83. case eRGB565:
  84. ovl_fmt = OVL_INPUT_FORMAT_RGB565;
  85. break;
  86. case eRGB888:
  87. ovl_fmt = OVL_INPUT_FORMAT_RGB888;
  88. break;
  89. case eBGR888:
  90. ovl_fmt = OVL_INPUT_FORMAT_BGR888;
  91. break;
  92. case eRGBA4444:
  93. ovl_fmt = OVL_INPUT_FORMAT_RGBA4444;
  94. break;
  95. case eBGRA4444:
  96. ovl_fmt = OVL_INPUT_FORMAT_BGRA4444;
  97. break;
  98. case eRGBA8888:
  99. ovl_fmt = OVL_INPUT_FORMAT_RGBA8888;
  100. break;
  101. case eBGRA8888:
  102. ovl_fmt = OVL_INPUT_FORMAT_BGRA8888;
  103. break;
  104. case eARGB8888:
  105. ovl_fmt = OVL_INPUT_FORMAT_ARGB8888;
  106. break;
  107. case eABGR8888:
  108. ovl_fmt = OVL_INPUT_FORMAT_ABGR8888;
  109. break;
  110. case eVYUY:
  111. ovl_fmt = OVL_INPUT_FORMAT_VYUY;
  112. break;
  113. case eYVYU:
  114. ovl_fmt = OVL_INPUT_FORMAT_YVYU;
  115. break;
  116. case eUYVY:
  117. ovl_fmt = OVL_INPUT_FORMAT_UYVY;
  118. break;
  119. case eYUY2:
  120. ovl_fmt = OVL_INPUT_FORMAT_YUYV;
  121. break;
  122. default:
  123. DDPERR("ovl_fmt_convert fmt=%d, ovl_fmt=%d\n", fmt, ovl_fmt);
  124. break;
  125. }
  126. return ovl_fmt;
  127. }
  128. unsigned long ovl_base_addr(DISP_MODULE_ENUM module)
  129. {
  130. switch (module) {
  131. case DISP_MODULE_OVL0:
  132. return DISPSYS_OVL0_BASE;
  133. case DISP_MODULE_OVL0_2L:
  134. return DISPSYS_OVL0_2L_BASE;
  135. case DISP_MODULE_OVL1_2L:
  136. return DISPSYS_OVL1_2L_BASE;
  137. default:
  138. return 0;
  139. }
  140. }
  141. unsigned long mmsys_ovl_ultra_offset(DISP_MODULE_ENUM module)
  142. {
  143. switch (module) {
  144. case DISP_MODULE_OVL0:
  145. return FLD_OVL0_ULTRA_SEL;
  146. case DISP_MODULE_OVL0_2L:
  147. return FLD_OVL0_2L_ULTRA_SEL;
  148. case DISP_MODULE_OVL1_2L:
  149. return FLD_OVL1_2L_ULTRA_SEL;
  150. default:
  151. return 0;
  152. }
  153. return 0;
  154. }
  155. static DpColorFormat ovl_input_fmt(enum OVL_INPUT_FORMAT fmt, int swap)
  156. {
  157. switch (fmt) {
  158. case OVL_INPUT_FORMAT_BGR565:
  159. return swap ? eBGR565 : eRGB565;
  160. case OVL_INPUT_FORMAT_RGB888:
  161. return swap ? eRGB888 : eBGR888;
  162. case OVL_INPUT_FORMAT_RGBA8888:
  163. return swap ? eRGBA8888 : eBGRA8888;
  164. case OVL_INPUT_FORMAT_ARGB8888:
  165. return swap ? eARGB8888 : eABGR8888;
  166. case OVL_INPUT_FORMAT_VYUY:
  167. return swap ? eVYUY : eUYVY;
  168. case OVL_INPUT_FORMAT_YVYU:
  169. return swap ? eYVYU : eYUY2;
  170. case OVL_INPUT_FORMAT_RGBA4444:
  171. return swap ? eRGBA4444 : eBGRA4444;
  172. default:
  173. DDPERR("ovl_input_fmt fmt=%d, swap=%d\n", fmt, swap);
  174. break;
  175. }
  176. return eRGB888;
  177. }
  178. static char *ovl_intput_format_name(enum OVL_INPUT_FORMAT fmt, int swap)
  179. {
  180. switch (fmt) {
  181. case OVL_INPUT_FORMAT_BGR565:
  182. return swap ? "eBGR565" : "eRGB565";
  183. case OVL_INPUT_FORMAT_RGB565:
  184. return "eRGB565";
  185. case OVL_INPUT_FORMAT_RGB888:
  186. return swap ? "eRGB888" : "eBGR888";
  187. case OVL_INPUT_FORMAT_BGR888:
  188. return "eBGR888";
  189. case OVL_INPUT_FORMAT_RGBA8888:
  190. return swap ? "eRGBA8888" : "eBGRA8888";
  191. case OVL_INPUT_FORMAT_BGRA8888:
  192. return "eBGRA8888";
  193. case OVL_INPUT_FORMAT_ARGB8888:
  194. return swap ? "eARGB8888" : "eABGR8888";
  195. case OVL_INPUT_FORMAT_ABGR8888:
  196. return "eABGR8888";
  197. case OVL_INPUT_FORMAT_VYUY:
  198. return swap ? "eVYUY" : "eUYVY";
  199. case OVL_INPUT_FORMAT_UYVY:
  200. return "eUYVY";
  201. case OVL_INPUT_FORMAT_YVYU:
  202. return swap ? "eYVYU" : "eYUY2";
  203. case OVL_INPUT_FORMAT_YUYV:
  204. return "eYUY2";
  205. case OVL_INPUT_FORMAT_RGBA4444:
  206. return swap ? "eRGBA4444" : "eBGRA4444";
  207. default:
  208. DDPERR("ovl_intput_fmt unknow fmt=%d, swap=%d\n", fmt, swap);
  209. break;
  210. }
  211. return "unknow";
  212. }
  213. static unsigned int ovl_index(DISP_MODULE_ENUM module)
  214. {
  215. int idx = 0;
  216. switch (module) {
  217. case DISP_MODULE_OVL0:
  218. idx = 0;
  219. break;
  220. case DISP_MODULE_OVL0_2L:
  221. idx = 1;
  222. break;
  223. case DISP_MODULE_OVL1:
  224. idx = 2;
  225. break;
  226. case DISP_MODULE_OVL1_2L:
  227. idx = 3;
  228. break;
  229. case DISP_MODULE_OVL2_2L:
  230. idx = 4;
  231. break;
  232. case DISP_MODULE_OVL3_2L:
  233. idx = 5;
  234. break;
  235. default:
  236. DDPERR("invalid module=%d \n", module);// invalid module
  237. ASSERT(0);
  238. }
  239. return idx;
  240. }
  241. int OVLStart(DISP_MODULE_ENUM module, void *handle)
  242. {
  243. int idx = ovl_index(module);
  244. DISP_REG_SET_FIELD(handle, EN_FLD_OVL_EN, idx*DISP_INDEX_OFFSET + DISP_REG_OVL_EN, 0x1);
  245. DISP_REG_SET(handle, idx*DISP_INDEX_OFFSET + DISP_REG_OVL_INTEN,
  246. 0x1E | REG_FLD_VAL(INTEN_FLD_ABNORMAL_SOF, 1));
  247. DISP_REG_SET_FIELD(handle, FLD_RDMA_BURST_CON1_BURST16_EN,
  248. idx * DISP_INDEX_OFFSET +
  249. DISP_REG_OVL_RDMA_BURST_CON1, 1);
  250. DISP_REG_SET_FIELD(handle, DATAPATH_CON_FLD_LAYER_SMI_ID_EN,
  251. idx * DISP_INDEX_OFFSET +
  252. DISP_REG_OVL_DATAPATH_CON, 1);
  253. DISP_REG_SET_FIELD(handle, DATAPATH_CON_FLD_GCLAST_EN,
  254. idx * DISP_INDEX_OFFSET +
  255. DISP_REG_OVL_DATAPATH_CON, 1);
  256. DISP_REG_SET_FIELD(handle, DATAPATH_CON_FLD_OUTPUT_CLAMP,
  257. idx * DISP_INDEX_OFFSET +
  258. DISP_REG_OVL_DATAPATH_CON, 1);
  259. /* DISP_REG_SET_FIELD(handle, FLD_FBDC_8XE_MODE,
  260. idx * DISP_INDEX_OFFSET +
  261. DISP_REG_OVL_FBDC_CFG1, 1);
  262. */
  263. #if 0
  264. dprintf(CRITICAL, "ovl start done idx = %d, addr = 0x%x\n", idx, idx*DISP_INDEX_OFFSET + DISP_REG_OVL_EN);
  265. dprintf(CRITICAL, "ovl start done addr0 = 0x%x\n", DISP_INDEX_OFFSET);
  266. dprintf(CRITICAL, "ovl start done addr1 = 0x%x\n", idx*DISP_INDEX_OFFSET);
  267. dprintf(CRITICAL, "ovl start done addr2 = 0x%x\n", DISP_REG_OVL_EN);
  268. dprintf(CRITICAL, "ovl start done addr3 = 0x%x\n", (idx*DISP_INDEX_OFFSET) + DISP_REG_OVL_EN);
  269. dprintf(CRITICAL, "ovl start done addr4 = 0x%x\n", idx*DISP_INDEX_OFFSET+DISP_REG_OVL_EN);
  270. #endif
  271. return 0;
  272. }
  273. int OVLStop(DISP_MODULE_ENUM module, void *handle)
  274. {
  275. int idx = ovl_index(module);
  276. DISP_REG_SET(handle,idx*DISP_INDEX_OFFSET+DISP_REG_OVL_INTEN, 0x00);
  277. DISP_REG_SET(handle,idx*DISP_INDEX_OFFSET+DISP_REG_OVL_EN, 0x00);
  278. DISP_REG_SET(handle,idx*DISP_INDEX_OFFSET+DISP_REG_OVL_INTSTA, 0x00);
  279. return 0;
  280. }
  281. int OVLReset(DISP_MODULE_ENUM module, void *handle)
  282. {
  283. #define OVL_IDLE (0x3)
  284. unsigned int delay_cnt = 0;
  285. int idx = ovl_index(module);
  286. /*always use cpu do reset*/
  287. DISP_CPU_REG_SET(idx*DISP_INDEX_OFFSET+DISP_REG_OVL_RST, 0x1); // soft reset
  288. DISP_CPU_REG_SET(idx*DISP_INDEX_OFFSET+DISP_REG_OVL_RST, 0x0);
  289. while (!(DISP_REG_GET(idx*DISP_INDEX_OFFSET+DISP_REG_OVL_FLOW_CTRL_DBG) & OVL_IDLE)) {
  290. delay_cnt++;
  291. udelay(10);
  292. if (delay_cnt>2000) {
  293. DDPERR("OVL%dReset() timeout! \n",idx);
  294. break;
  295. }
  296. }
  297. return 0;
  298. }
  299. int OVLROI(DISP_MODULE_ENUM module,
  300. unsigned int bgW,
  301. unsigned int bgH,
  302. unsigned int bgColor,
  303. void * handle)
  304. {
  305. int idx = ovl_index(module);
  306. if ((bgW > OVL_MAX_WIDTH) || (bgH > OVL_MAX_HEIGHT)) {
  307. DDPERR("OVLROI(), exceed OVL max size, w=%d, h=%d \n", bgW, bgH);
  308. ASSERT(0);
  309. }
  310. DISP_REG_SET(handle,idx*DISP_INDEX_OFFSET+DISP_REG_OVL_ROI_SIZE, bgH<<16 | bgW);
  311. DISP_REG_SET(handle,idx*DISP_INDEX_OFFSET+DISP_REG_OVL_ROI_BGCLR, bgColor);
  312. return 0;
  313. }
  314. int OVLLayerSwitch(DISP_MODULE_ENUM module,
  315. unsigned layer,
  316. unsigned int en,
  317. void * handle)
  318. {
  319. int idx = ovl_index(module);
  320. ASSERT(layer<=3);
  321. switch (layer) {
  322. case 0:
  323. DISP_REG_SET_FIELD(handle,SRC_CON_FLD_L0_EN, idx*DISP_INDEX_OFFSET+DISP_REG_OVL_SRC_CON, en);
  324. break;
  325. case 1:
  326. DISP_REG_SET_FIELD(handle,SRC_CON_FLD_L1_EN, idx*DISP_INDEX_OFFSET+DISP_REG_OVL_SRC_CON, en);
  327. break;
  328. case 2:
  329. DISP_REG_SET_FIELD(handle,SRC_CON_FLD_L2_EN, idx*DISP_INDEX_OFFSET+DISP_REG_OVL_SRC_CON, en);
  330. break;
  331. case 3:
  332. DISP_REG_SET_FIELD(handle,SRC_CON_FLD_L3_EN, idx*DISP_INDEX_OFFSET+DISP_REG_OVL_SRC_CON, en);
  333. break;
  334. default:
  335. DDPERR("invalid layer=%d\n", layer); // invalid layer
  336. ASSERT(0);
  337. }
  338. return 0;
  339. }
  340. int OVL3DConfig(DISP_MODULE_ENUM module,
  341. unsigned int layer_id,
  342. unsigned int en_3d,
  343. unsigned int landscape,
  344. unsigned int r_first,
  345. void *handle)
  346. {
  347. return 0;
  348. }
  349. int OVLLayerConfig(DISP_MODULE_ENUM module,
  350. unsigned int layer,
  351. unsigned int source,
  352. DpColorFormat format,
  353. unsigned int addr,
  354. unsigned int src_x, // ROI x offset
  355. unsigned int src_y, // ROI y offset
  356. unsigned int src_pitch,
  357. unsigned int dst_x, // ROI x offset
  358. unsigned int dst_y, // ROI y offset
  359. unsigned int dst_w, // ROT width
  360. unsigned int dst_h, // ROI height
  361. unsigned int keyEn,
  362. unsigned int key, // color key
  363. unsigned int aen, // alpha enable
  364. unsigned char alpha,
  365. void * handle)
  366. {
  367. int idx = ovl_index(module);
  368. unsigned int value = 0;
  369. enum OVL_INPUT_FORMAT fmt = ovl_input_fmt_convert(format);
  370. unsigned int bpp = ovl_input_fmt_bpp(fmt);
  371. unsigned int input_swap = ovl_input_fmt_byte_swap(fmt);
  372. unsigned int input_fmt = ovl_input_fmt_reg_value(fmt);
  373. enum OVL_COLOR_SPACE space = ovl_input_fmt_color_space(fmt);
  374. unsigned int offset = 0;
  375. /*0100 MTX_JPEG_TO_RGB (YUV FUll TO RGB)*/
  376. int color_matrix = 0x4;
  377. unsigned int idx_offset = idx*DISP_INDEX_OFFSET;
  378. unsigned int layer_offset = idx_offset + layer * 0x20;
  379. #ifdef MTK_LCM_PHYSICAL_ROTATION_HW
  380. unsigned int bg_h, bg_w;
  381. #endif
  382. ASSERT((dst_w <= OVL_MAX_WIDTH) &&
  383. (dst_h <= OVL_MAX_HEIGHT) &&
  384. (layer <= 3));
  385. if (addr == 0) {
  386. DDPERR("source from memory, but addr is 0!\n");
  387. ASSERT(0);
  388. }
  389. DDPDBG("ovl%d, layer=%d, source=%s, off(x=%d, y=%d), dst(%d, %d, %d, %d),pitch=%d,"
  390. "fmt=%s, addr=%x, keyEn=%d, key=%d, aen=%d, alpha=%d \n",
  391. idx,
  392. layer,
  393. (source==0)?"memory":"constant_color",
  394. src_x,
  395. src_y,
  396. dst_x,
  397. dst_y,
  398. dst_w,
  399. dst_h,
  400. src_pitch,
  401. ovl_intput_format_name(fmt, input_swap),
  402. addr,
  403. keyEn,
  404. key,
  405. aen,
  406. alpha);
  407. if (source==OVL_LAYER_SOURCE_RESERVED) { //==1, means constant color
  408. if (aen==0) {
  409. DDPERR("dim layer ahpha enable should be 1!\n");
  410. }
  411. if (fmt!=OVL_INPUT_FORMAT_RGB565) {
  412. DDPERR("dim layer format should be RGB565");
  413. fmt = OVL_INPUT_FORMAT_RGB565;
  414. }
  415. }
  416. DISP_REG_SET(handle, DISP_REG_OVL_RDMA0_CTRL+layer_offset, 0x1);
  417. value = (REG_FLD_VAL((L_CON_FLD_LARC), (source)) |
  418. REG_FLD_VAL((L_CON_FLD_CFMT), (input_fmt)) |
  419. REG_FLD_VAL((L_CON_FLD_AEN), (aen)) |
  420. REG_FLD_VAL((L_CON_FLD_APHA), (alpha)) |
  421. REG_FLD_VAL((L_CON_FLD_SKEN), (keyEn)) |
  422. REG_FLD_VAL((L_CON_FLD_BTSW), (input_swap)));
  423. if (fmt == OVL_INPUT_FORMAT_RGBA4444)
  424. value |= REG_FLD_VAL((L_CON_FLD_CLRFMT_MAN), (1));
  425. if (space == OVL_COLOR_SPACE_YUV)
  426. value = value | REG_FLD_VAL((L_CON_FLD_MTX), (color_matrix));
  427. #ifdef MTK_LCM_PHYSICAL_ROTATION_HW
  428. value |= (REG_FLD_VAL((L_CON_FLD_VIRTICAL_FLIP), 1) |
  429. REG_FLD_VAL((L_CON_FLD_HORI_FLIP), 1));
  430. #endif
  431. DISP_REG_SET(handle, DISP_REG_OVL_L0_CON+layer_offset, value);
  432. #ifdef MTK_LCM_PHYSICAL_ROTATION_HW
  433. bg_h = DISP_REG_GET(idx_offset + DISP_REG_OVL_ROI_SIZE);
  434. bg_w = bg_h & 0xFFFF;
  435. bg_h = bg_h >> 16;
  436. DISP_REG_SET(handle, DISP_REG_OVL_L0_OFFSET+layer_offset,
  437. (bg_h-dst_h-dst_y)<<16 | (bg_w-dst_w-dst_x));
  438. offset = (src_x+dst_w)*bpp + (src_y+dst_h-1)*src_pitch - 1;
  439. #else
  440. DISP_REG_SET(handle, DISP_REG_OVL_L0_OFFSET+layer_offset,
  441. dst_y<<16 | dst_x);
  442. offset = src_x*bpp+src_y*src_pitch;
  443. #endif
  444. DISP_REG_SET(handle, DISP_REG_OVL_L0_ADDR+layer_offset,
  445. addr+offset);
  446. DISP_REG_SET(handle, DISP_REG_OVL_L0_SRC_SIZE+layer_offset,
  447. dst_h<<16 | dst_w);
  448. DISP_REG_SET(handle, DISP_REG_OVL_L0_SRCKEY+layer_offset,
  449. key);
  450. value = REG_FLD_VAL((L_PITCH_FLD_LSP), (src_pitch));
  451. if (fmt == OVL_INPUT_FORMAT_RGBA4444) {
  452. value |= REG_FLD_VAL(L_PITCH_FLD_SRGB_SEL, (1)) |
  453. REG_FLD_VAL(L_PITCH_FLD_DRGB_SEL, (2)) |
  454. REG_FLD_VAL(L_PITCH_FLD_SURFL_EN, (1));
  455. }
  456. DISP_REG_SET(handle, DISP_REG_OVL_L0_PITCH+layer_offset, value);
  457. return 0;
  458. }
  459. static unsigned int ovl_input_fmt_byte_swap(enum OVL_INPUT_FORMAT inputFormat)
  460. {
  461. int input_swap = 0;
  462. switch (inputFormat) {
  463. case OVL_INPUT_FORMAT_BGR565:
  464. case OVL_INPUT_FORMAT_RGB888:
  465. case OVL_INPUT_FORMAT_RGBA8888:
  466. case OVL_INPUT_FORMAT_ARGB8888:
  467. case OVL_INPUT_FORMAT_BGRA4444:
  468. case OVL_INPUT_FORMAT_VYUY:
  469. case OVL_INPUT_FORMAT_YVYU:
  470. input_swap = 1;
  471. break;
  472. case OVL_INPUT_FORMAT_RGB565:
  473. case OVL_INPUT_FORMAT_BGR888:
  474. case OVL_INPUT_FORMAT_BGRA8888:
  475. case OVL_INPUT_FORMAT_ABGR8888:
  476. case OVL_INPUT_FORMAT_RGBA4444:
  477. case OVL_INPUT_FORMAT_UYVY:
  478. case OVL_INPUT_FORMAT_YUYV:
  479. input_swap = 0;
  480. break;
  481. default:
  482. DDPERR("unknow input ovl format is %d\n", inputFormat);
  483. ASSERT(0);
  484. }
  485. return input_swap;
  486. }
  487. static unsigned int ovl_input_fmt_bpp(enum OVL_INPUT_FORMAT inputFormat)
  488. {
  489. int bpp = 0;
  490. switch (inputFormat) {
  491. case OVL_INPUT_FORMAT_BGR565:
  492. case OVL_INPUT_FORMAT_RGB565:
  493. case OVL_INPUT_FORMAT_VYUY:
  494. case OVL_INPUT_FORMAT_UYVY:
  495. case OVL_INPUT_FORMAT_YVYU:
  496. case OVL_INPUT_FORMAT_YUYV:
  497. case OVL_INPUT_FORMAT_RGBA4444:
  498. case OVL_INPUT_FORMAT_BGRA4444:
  499. bpp = 2;
  500. break;
  501. case OVL_INPUT_FORMAT_RGB888:
  502. case OVL_INPUT_FORMAT_BGR888:
  503. bpp = 3;
  504. break;
  505. case OVL_INPUT_FORMAT_RGBA8888:
  506. case OVL_INPUT_FORMAT_BGRA8888:
  507. case OVL_INPUT_FORMAT_ARGB8888:
  508. case OVL_INPUT_FORMAT_ABGR8888:
  509. bpp = 4;
  510. break;
  511. default:
  512. DDPERR("unknown ovl input format = %d\n", inputFormat);
  513. ASSERT(0);
  514. }
  515. return bpp;
  516. }
  517. static enum OVL_COLOR_SPACE ovl_input_fmt_color_space(enum OVL_INPUT_FORMAT inputFormat)
  518. {
  519. enum OVL_COLOR_SPACE space = OVL_COLOR_SPACE_RGB;
  520. switch (inputFormat) {
  521. case OVL_INPUT_FORMAT_BGR565:
  522. case OVL_INPUT_FORMAT_RGB565:
  523. case OVL_INPUT_FORMAT_RGB888:
  524. case OVL_INPUT_FORMAT_BGR888:
  525. case OVL_INPUT_FORMAT_BGRA4444:
  526. case OVL_INPUT_FORMAT_RGBA4444:
  527. case OVL_INPUT_FORMAT_RGBA8888:
  528. case OVL_INPUT_FORMAT_BGRA8888:
  529. case OVL_INPUT_FORMAT_ARGB8888:
  530. case OVL_INPUT_FORMAT_ABGR8888:
  531. space = OVL_COLOR_SPACE_RGB;
  532. break;
  533. case OVL_INPUT_FORMAT_VYUY:
  534. case OVL_INPUT_FORMAT_UYVY:
  535. case OVL_INPUT_FORMAT_YVYU:
  536. case OVL_INPUT_FORMAT_YUYV:
  537. space = OVL_COLOR_SPACE_YUV;
  538. break;
  539. default:
  540. DDPERR("unknown ovl input format = %d\n", inputFormat);
  541. ASSERT(0);
  542. }
  543. return space;
  544. }
  545. static unsigned int ovl_input_fmt_reg_value(enum OVL_INPUT_FORMAT inputFormat)
  546. {
  547. int reg_value = 0;
  548. switch (inputFormat) {
  549. case OVL_INPUT_FORMAT_BGR565:
  550. case OVL_INPUT_FORMAT_RGB565:
  551. reg_value = 0x0;
  552. break;
  553. case OVL_INPUT_FORMAT_RGB888:
  554. case OVL_INPUT_FORMAT_BGR888:
  555. reg_value = 0x1;
  556. break;
  557. case OVL_INPUT_FORMAT_RGBA8888:
  558. case OVL_INPUT_FORMAT_BGRA8888:
  559. reg_value = 0x2;
  560. break;
  561. case OVL_INPUT_FORMAT_ARGB8888:
  562. case OVL_INPUT_FORMAT_ABGR8888:
  563. reg_value = 0x3;
  564. break;
  565. case OVL_INPUT_FORMAT_VYUY:
  566. case OVL_INPUT_FORMAT_UYVY:
  567. case OVL_INPUT_FORMAT_RGBA4444:
  568. case OVL_INPUT_FORMAT_BGRA4444:
  569. reg_value = 0x4;
  570. break;
  571. case OVL_INPUT_FORMAT_YVYU:
  572. case OVL_INPUT_FORMAT_YUYV:
  573. reg_value = 0x5;
  574. break;
  575. default:
  576. DDPERR("unknow ovl input format is %d\n", inputFormat);
  577. ASSERT(0);
  578. }
  579. return reg_value;
  580. }
  581. void OVLRegStore(DISP_MODULE_ENUM module)
  582. {
  583. int i =0;
  584. int idx = ovl_index(module);
  585. const unsigned int regs[] = {
  586. //start
  587. DISP_REG_OVL_INTEN , DISP_REG_OVL_EN ,DISP_REG_OVL_DATAPATH_CON,
  588. // roi
  589. DISP_REG_OVL_ROI_SIZE , DISP_REG_OVL_ROI_BGCLR ,
  590. //layers enable
  591. DISP_REG_OVL_SRC_CON,
  592. //layer0
  593. DISP_REG_OVL_RDMA0_CTRL , DISP_REG_OVL_L0_CON ,DISP_REG_OVL_L0_SRC_SIZE,
  594. DISP_REG_OVL_L0_OFFSET , DISP_REG_OVL_L0_ADDR ,DISP_REG_OVL_L0_PITCH,
  595. DISP_REG_OVL_L0_SRCKEY ,
  596. //layer1
  597. DISP_REG_OVL_RDMA1_CTRL , DISP_REG_OVL_L1_CON ,DISP_REG_OVL_L1_SRC_SIZE,
  598. DISP_REG_OVL_L1_OFFSET , DISP_REG_OVL_L1_ADDR ,DISP_REG_OVL_L1_PITCH,
  599. DISP_REG_OVL_L1_SRCKEY ,
  600. //layer2
  601. DISP_REG_OVL_RDMA2_CTRL , DISP_REG_OVL_L2_CON ,DISP_REG_OVL_L2_SRC_SIZE,
  602. DISP_REG_OVL_L2_OFFSET , DISP_REG_OVL_L2_ADDR ,DISP_REG_OVL_L2_PITCH,
  603. DISP_REG_OVL_L2_SRCKEY ,
  604. //layer3
  605. DISP_REG_OVL_RDMA3_CTRL , DISP_REG_OVL_L3_CON ,DISP_REG_OVL_L3_SRC_SIZE,
  606. DISP_REG_OVL_L3_OFFSET , DISP_REG_OVL_L3_ADDR ,DISP_REG_OVL_L3_PITCH,
  607. DISP_REG_OVL_L3_SRCKEY ,
  608. };
  609. reg_back_cnt[idx] = sizeof(regs)/sizeof(unsigned int);
  610. ASSERT(reg_back_cnt[idx] <= OVL_REG_BACK_MAX);
  611. for (i =0; i< reg_back_cnt[idx]; i++) {
  612. reg_back[idx][i].address = regs[i];
  613. reg_back[idx][i].value = DISP_REG_GET(regs[i]);
  614. }
  615. DDPDBG("store %c cnt registers on ovl %d",reg_back_cnt[idx],idx);
  616. }
  617. void OVLRegRestore(DISP_MODULE_ENUM module,void * handle)
  618. {
  619. int idx = ovl_index(module);
  620. int i = reg_back_cnt[idx];
  621. while (i > 0) {
  622. i--;
  623. DISP_REG_SET(handle,reg_back[idx][i].address, reg_back[idx][i].value);
  624. }
  625. DDPDBG("restore %d cnt registers on ovl %d",reg_back_cnt[idx],idx);
  626. reg_back_cnt[idx] = 0;
  627. }
  628. int OVLClockOn(DISP_MODULE_ENUM module,void * handle)
  629. {
  630. int idx = ovl_index(module);
  631. ddp_enable_module_clock(module);
  632. DDPMSG("OVL%dClockOn CG 0x%x \n",idx, DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0));
  633. return 0;
  634. }
  635. int OVLClockOff(DISP_MODULE_ENUM module,void * handle)
  636. {
  637. int idx = ovl_index(module);
  638. DDPMSG("OVL%dClockOff\n",idx);
  639. //store registers
  640. // OVLRegRestore(module,handle);
  641. DISP_REG_SET(handle, idx * DISP_INDEX_OFFSET + DISP_REG_OVL_EN, 0x00);
  642. OVLReset(module,handle);
  643. DISP_REG_SET(handle,idx*DISP_INDEX_OFFSET+DISP_REG_OVL_INTEN, 0x00);
  644. DISP_REG_SET(handle, idx * DISP_INDEX_OFFSET + DISP_REG_OVL_INTSTA, 0x00);
  645. ddp_disable_module_clock(module);
  646. return 0;
  647. }
  648. int OVLInit(DISP_MODULE_ENUM module,void * handle)
  649. {
  650. //power on, no need to care clock
  651. ddp_enable_module_clock(module);
  652. return 0;
  653. }
  654. int OVLDeInit(DISP_MODULE_ENUM module,void * handle)
  655. {
  656. int idx = ovl_index(module);
  657. DDPMSG("OVL%dDeInit close CG \n",idx);
  658. ddp_disable_module_clock(module);
  659. return 0;
  660. }
  661. static inline int is_module_ovl(DISP_MODULE_ENUM module)
  662. {
  663. if (module == DISP_MODULE_OVL0 ||
  664. module == DISP_MODULE_OVL0_2L)
  665. return 1;
  666. else
  667. return 0;
  668. }
  669. int OVLConnect(DISP_MODULE_ENUM module, DISP_MODULE_ENUM prev,
  670. DISP_MODULE_ENUM next, int connect, void *handle)
  671. {
  672. int idx = ovl_index(module);
  673. if (connect && is_module_ovl(prev))
  674. DISP_REG_SET_FIELD(handle, DATAPATH_CON_FLD_BGCLR_IN_SEL,
  675. idx * DISP_INDEX_OFFSET + DISP_REG_OVL_DATAPATH_CON, 1);
  676. else
  677. DISP_REG_SET_FIELD(handle, DATAPATH_CON_FLD_BGCLR_IN_SEL,
  678. idx * DISP_INDEX_OFFSET + DISP_REG_OVL_DATAPATH_CON, 0);
  679. if (connect && is_module_ovl(next)) {
  680. switch (module) {
  681. case DISP_MODULE_OVL0:
  682. DISP_REG_SET_FIELD(handle, FLD_CON_OVL0, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x2);
  683. break;
  684. case DISP_MODULE_OVL0_2L:
  685. DISP_REG_SET_FIELD(handle, FLD_CON_OVL0_2L, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x2);
  686. break;
  687. case DISP_MODULE_OVL1:
  688. DISP_REG_SET_FIELD(handle, FLD_CON_OVL1, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x2);
  689. break;
  690. case DISP_MODULE_OVL1_2L:
  691. DISP_REG_SET_FIELD(handle, FLD_CON_OVL1_2L, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x2);
  692. break;
  693. case DISP_MODULE_OVL2_2L:
  694. break;
  695. case DISP_MODULE_OVL3_2L:
  696. DISP_REG_SET_FIELD(handle, FLD_CON_OVL3_2L, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x2);
  697. break;
  698. default:
  699. DDPERR("invalid module=%d \n", module);// invalid module
  700. ASSERT(0);
  701. }
  702. } else {
  703. switch (module) {
  704. case DISP_MODULE_OVL0:
  705. DISP_REG_SET_FIELD(handle, FLD_CON_OVL0, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x1);
  706. break;
  707. case DISP_MODULE_OVL0_2L:
  708. DISP_REG_SET_FIELD(handle, FLD_CON_OVL0_2L, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x1);
  709. break;
  710. case DISP_MODULE_OVL1:
  711. DISP_REG_SET_FIELD(handle, FLD_CON_OVL1, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x1);
  712. break;
  713. case DISP_MODULE_OVL1_2L:
  714. DISP_REG_SET_FIELD(handle, FLD_CON_OVL1_2L, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x1);
  715. break;
  716. case DISP_MODULE_OVL2_2L:
  717. break;
  718. case DISP_MODULE_OVL3_2L:
  719. DISP_REG_SET_FIELD(handle, FLD_CON_OVL3_2L, DISP_REG_CONFIG_MMSYS_OVL_CON, 0x1);
  720. break;
  721. default:
  722. DDPERR("invalid module=%d \n", module);// invalid module
  723. ASSERT(0);
  724. }
  725. }
  726. return 0;
  727. }
  728. void ovl_dump_golden_setting(DISP_MODULE_ENUM module)
  729. {
  730. unsigned long base = ovl_base_addr(module);
  731. base -= DISPSYS_OVL0_BASE;
  732. DDPDUMP("-- %s Golden Setting --\n", ddp_get_module_name(module));
  733. DDPDUMP("RDMA0_MEM_GMC_SETTING1\n");
  734. DDPDUMP("[9:0]:%x [25:16]:%x [28]:%x [31]:%x\n",
  735. DISP_REG_GET_FIELD(FLD_OVL_RDMA_MEM_GMC_ULTRA_THRESHOLD,
  736. base + DISP_REG_OVL_RDMA0_MEM_GMC_SETTING),
  737. DISP_REG_GET_FIELD(FLD_OVL_RDMA_MEM_GMC_PRE_ULTRA_THRESHOLD,
  738. base + DISP_REG_OVL_RDMA0_MEM_GMC_SETTING),
  739. DISP_REG_GET_FIELD(
  740. FLD_OVL_RDMA_MEM_GMC_ULTRA_THRESHOLD_HIGH_OFS,
  741. base + DISP_REG_OVL_RDMA0_MEM_GMC_SETTING),
  742. DISP_REG_GET_FIELD(
  743. FLD_OVL_RDMA_MEM_GMC_PRE_ULTRA_THRESHOLD_HIGH_OFS,
  744. base + DISP_REG_OVL_RDMA0_MEM_GMC_SETTING));
  745. DDPDUMP("RDMA0_FIFO_CTRL\n");
  746. DDPDUMP("[9:0]:%u [25:16]:%u\n",
  747. DISP_REG_GET_FIELD(FLD_OVL_RDMA_FIFO_THRD,
  748. base + DISP_REG_OVL_RDMA0_FIFO_CTRL),
  749. DISP_REG_GET_FIELD(FLD_OVL_RDMA_FIFO_SIZE,
  750. base + DISP_REG_OVL_RDMA0_FIFO_CTRL));
  751. DDPDUMP("RDMA0_MEM_GMC_SETTING2\n");
  752. DDPDUMP("[11:0]:%u [27:16]:%u [28]:%u [29]:%u [30]:%u\n",
  753. DISP_REG_GET_FIELD(FLD_OVL_RDMA_MEM_GMC2_ISSUE_REQ_THRES,
  754. base + DISP_REG_OVL_RDMA0_MEM_GMC_S2),
  755. DISP_REG_GET_FIELD(FLD_OVL_RDMA_MEM_GMC2_ISSUE_REQ_THRES_URG,
  756. base + DISP_REG_OVL_RDMA0_MEM_GMC_S2),
  757. DISP_REG_GET_FIELD(FLD_OVL_RDMA_MEM_GMC2_REQ_THRES_PREULTRA,
  758. base + DISP_REG_OVL_RDMA0_MEM_GMC_S2),
  759. DISP_REG_GET_FIELD(FLD_OVL_RDMA_MEM_GMC2_REQ_THRES_ULTRA,
  760. base + DISP_REG_OVL_RDMA0_MEM_GMC_S2),
  761. DISP_REG_GET_FIELD(FLD_OVL_RDMA_MEM_GMC2_FORCE_REQ_THRES,
  762. base + DISP_REG_OVL_RDMA0_MEM_GMC_S2));
  763. DDPDUMP("OVL_RDMA_BURST_CON1\n");
  764. DDPDUMP("[28]:%u\n",
  765. DISP_REG_GET_FIELD(FLD_RDMA_BURST_CON1_BURST16_EN,
  766. base + DISP_REG_OVL_RDMA_BURST_CON1));
  767. DDPDUMP("RDMA_GREQ_NUM\n");
  768. DDPDUMP("[3:0]%u [7:4]%u [11:8]%u [15:12]%u [23:16]%x [26:24]%u\n",
  769. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_LAYER0_GREQ_NUM,
  770. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  771. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_LAYER1_GREQ_NUM,
  772. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  773. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_LAYER2_GREQ_NUM,
  774. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  775. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_LAYER3_GREQ_NUM,
  776. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  777. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_OSTD_GREQ_NUM,
  778. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  779. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_GREQ_DIS_CNT,
  780. base + DISP_REG_OVL_RDMA_GREQ_NUM));
  781. DDPDUMP("[27]%u [28]%u [29]%u [30]%u [31]%u\n",
  782. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_STOP_EN,
  783. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  784. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_GRP_END_STOP,
  785. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  786. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_GRP_BRK_STOP,
  787. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  788. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_IOBUF_FLUSH_PREULTRA,
  789. base + DISP_REG_OVL_RDMA_GREQ_NUM),
  790. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_IOBUF_FLUSH_ULTRA,
  791. base + DISP_REG_OVL_RDMA_GREQ_NUM));
  792. DDPDUMP("RDMA_GREQ_URG_NUM\n");
  793. DDPDUMP("[3:0]:%u [7:4]:%u [11:8]:%u [15:12]:%u [25:16]:%u [28]:%u\n",
  794. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_LAYER0_GREQ_URG_NUM,
  795. base + DISP_REG_OVL_RDMA_GREQ_URG_NUM),
  796. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_LAYER1_GREQ_URG_NUM,
  797. base + DISP_REG_OVL_RDMA_GREQ_URG_NUM),
  798. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_LAYER2_GREQ_URG_NUM,
  799. base + DISP_REG_OVL_RDMA_GREQ_URG_NUM),
  800. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_LAYER3_GREQ_URG_NUM,
  801. base + DISP_REG_OVL_RDMA_GREQ_URG_NUM),
  802. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_ARG_GREQ_URG_TH,
  803. base + DISP_REG_OVL_RDMA_GREQ_URG_NUM),
  804. DISP_REG_GET_FIELD(FLD_OVL_RDMA_GREQ_ARG_URG_BIAS,
  805. base + DISP_REG_OVL_RDMA_GREQ_URG_NUM));
  806. DDPDUMP("RDMA_ULTRA_SRC\n");
  807. DDPDUMP("[1:0]%u [3:2]%u [5:4]%u [7:6]%u [9:8]%u\n",
  808. DISP_REG_GET_FIELD(FLD_OVL_RDMA_PREULTRA_BUF_SRC,
  809. base + DISP_REG_OVL_RDMA_ULTRA_SRC),
  810. DISP_REG_GET_FIELD(FLD_OVL_RDMA_PREULTRA_SMI_SRC,
  811. base + DISP_REG_OVL_RDMA_ULTRA_SRC),
  812. DISP_REG_GET_FIELD(FLD_OVL_RDMA_PREULTRA_ROI_END_SRC,
  813. base + DISP_REG_OVL_RDMA_ULTRA_SRC),
  814. DISP_REG_GET_FIELD(FLD_OVL_RDMA_PREULTRA_RDMA_SRC,
  815. base + DISP_REG_OVL_RDMA_ULTRA_SRC),
  816. DISP_REG_GET_FIELD(FLD_OVL_RDMA_ULTRA_BUF_SRC,
  817. base + DISP_REG_OVL_RDMA_ULTRA_SRC));
  818. DDPDUMP("[11:10]%u [13:12]%u [15:14]%u\n",
  819. DISP_REG_GET_FIELD(FLD_OVL_RDMA_ULTRA_SMI_SRC,
  820. base + DISP_REG_OVL_RDMA_ULTRA_SRC),
  821. DISP_REG_GET_FIELD(FLD_OVL_RDMA_ULTRA_ROI_END_SRC,
  822. base + DISP_REG_OVL_RDMA_ULTRA_SRC),
  823. DISP_REG_GET_FIELD(FLD_OVL_RDMA_ULTRA_RDMA_SRC,
  824. base + DISP_REG_OVL_RDMA_ULTRA_SRC));
  825. DDPDUMP("RDMA0_BUF_LOW\n");
  826. DDPDUMP("[11:0]:%x [23:12]:%x\n",
  827. DISP_REG_GET_FIELD(FLD_OVL_RDMA_BUF_LOW_ULTRA_TH,
  828. base + DISP_REG_OVL_RDMAn_BUF_LOW(0)),
  829. DISP_REG_GET_FIELD(FLD_OVL_RDMA_BUF_LOW_PREULTRA_TH,
  830. base + DISP_REG_OVL_RDMAn_BUF_LOW(0)));
  831. DDPDUMP("RDMA0_BUF_HIGH\n");
  832. DDPDUMP("[23:12]:%x [31]:%x\n",
  833. DISP_REG_GET_FIELD(FLD_OVL_RDMA_BUF_HIGH_PREULTRA_TH,
  834. base + DISP_REG_OVL_RDMAn_BUF_HIGH(0)),
  835. DISP_REG_GET_FIELD(FLD_OVL_RDMA_BUF_HIGH_PREULTRA_DIS,
  836. base + DISP_REG_OVL_RDMAn_BUF_HIGH(0)));
  837. DDPDUMP("OVL_EN\n");
  838. DDPDUMP("[18]:%x [19]:%x\n",
  839. DISP_REG_GET_FIELD(EN_FLD_BLOCK_EXT_ULTRA,
  840. base + DISP_REG_OVL_EN),
  841. DISP_REG_GET_FIELD(EN_FLD_BLOCK_EXT_PREULTRA,
  842. base + DISP_REG_OVL_EN));
  843. DDPDUMP("DATAPATH_CON\n");
  844. DDPDUMP("[0]:%u, [3]:%u [24]:%u [25]:%u [26]:%u\n",
  845. DISP_REG_GET_FIELD(DATAPATH_CON_FLD_LAYER_SMI_ID_EN,
  846. base + DISP_REG_OVL_DATAPATH_CON),
  847. DISP_REG_GET_FIELD(DATAPATH_CON_FLD_OUTPUT_NO_RND,
  848. base + DISP_REG_OVL_DATAPATH_CON),
  849. DISP_REG_GET_FIELD(DATAPATH_CON_FLD_GCLAST_EN,
  850. base + DISP_REG_OVL_DATAPATH_CON),
  851. DISP_REG_GET_FIELD(DATAPATH_CON_FLD_HDR_GCLAST_EN,
  852. base + DISP_REG_OVL_DATAPATH_CON),
  853. DISP_REG_GET_FIELD(DATAPATH_CON_FLD_OUTPUT_CLAMP,
  854. base + DISP_REG_OVL_DATAPATH_CON));
  855. DDPDUMP("OVL_FBDC_CFG1\n");
  856. DDPDUMP("[24]:%u\n", DISP_REG_GET_FIELD(FLD_FBDC_8XE_MODE,
  857. base + DISP_REG_OVL_FBDC_CFG1));
  858. }
  859. void OVLDump(DISP_MODULE_ENUM module)
  860. {
  861. #if 0
  862. int idx = ovl_index(module);
  863. unsigned long module_base = 0;
  864. const char *module_name = ddp_get_module_name(module);
  865. module_base = idx * DISP_INDEX_OFFSET + DISP_OVL0_OVL_STA;
  866. DDPDUMP("== START: DISP %s registers ==\n", module_name);
  867. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  868. module_name,
  869. 0x0, INREG32(module_base + 0x0),
  870. 0x4, INREG32(module_base + 0x4),
  871. 0x8, INREG32(module_base + 0x8),
  872. 0xC, INREG32(module_base + 0xC));
  873. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  874. module_name,
  875. 0x10, INREG32(module_base + 0x10),
  876. 0x14, INREG32(module_base + 0x14),
  877. 0x20, INREG32(module_base + 0x20),
  878. 0x24, INREG32(module_base + 0x24));
  879. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  880. module_name,
  881. 0x28, INREG32(module_base + 0x28),
  882. 0x2C, INREG32(module_base + 0x2C),
  883. 0x30, INREG32(module_base + 0x30),
  884. 0x34, INREG32(module_base + 0x34));
  885. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  886. module_name,
  887. 0x38, INREG32(module_base + 0x38),
  888. 0x3C, INREG32(module_base + 0x3C),
  889. 0xF40, INREG32(module_base + 0xF40),
  890. 0x44, INREG32(module_base + 0x44));
  891. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  892. module_name,
  893. 0x48, INREG32(module_base + 0x48),
  894. 0x4C, INREG32(module_base + 0x4C),
  895. 0x50, INREG32(module_base + 0x50),
  896. 0x54, INREG32(module_base + 0x54));
  897. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  898. module_name,
  899. 0x58, INREG32(module_base + 0x58),
  900. 0x5C, INREG32(module_base + 0x5C),
  901. 0xF60, INREG32(module_base + 0xF60),
  902. 0x64, INREG32(module_base + 0x64));
  903. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  904. module_name,
  905. 0x68, INREG32(module_base + 0x68),
  906. 0x6C, INREG32(module_base + 0x6C),
  907. 0x70, INREG32(module_base + 0x70),
  908. 0x74, INREG32(module_base + 0x74));
  909. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  910. module_name,
  911. 0x78, INREG32(module_base + 0x78),
  912. 0x7C, INREG32(module_base + 0x7C),
  913. 0xF80, INREG32(module_base + 0xF80),
  914. 0x84, INREG32(module_base + 0x84));
  915. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  916. module_name,
  917. 0x88, INREG32(module_base + 0x88),
  918. 0x8C, INREG32(module_base + 0x8C),
  919. 0x90, INREG32(module_base + 0x90),
  920. 0x94, INREG32(module_base + 0x94));
  921. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  922. module_name,
  923. 0x98, INREG32(module_base + 0x98),
  924. 0x9C, INREG32(module_base + 0x9C),
  925. 0xFa0, INREG32(module_base + 0xFa0),
  926. 0xa4, INREG32(module_base + 0xa4));
  927. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  928. module_name,
  929. 0xa8, INREG32(module_base + 0xa8),
  930. 0xAC, INREG32(module_base + 0xAC),
  931. 0xc0, INREG32(module_base + 0xc0),
  932. 0xc8, INREG32(module_base + 0xc8));
  933. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  934. module_name,
  935. 0xcc, INREG32(module_base + 0xcc),
  936. 0xd0, INREG32(module_base + 0xd0),
  937. 0xe0, INREG32(module_base + 0xe0),
  938. 0xe8, INREG32(module_base + 0xe8));
  939. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  940. module_name,
  941. 0xec, INREG32(module_base + 0xec),
  942. 0xf0, INREG32(module_base + 0xf0),
  943. 0x100, INREG32(module_base + 0x100),
  944. 0x108, INREG32(module_base + 0x108));
  945. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  946. module_name,
  947. 0x10c, INREG32(module_base + 0x10c),
  948. 0x110, INREG32(module_base + 0x110),
  949. 0x120, INREG32(module_base + 0x120),
  950. 0x128, INREG32(module_base + 0x128));
  951. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  952. module_name,
  953. 0x12c, INREG32(module_base + 0x12c),
  954. 0x130, INREG32(module_base + 0x130),
  955. 0x134, INREG32(module_base + 0x134),
  956. 0x138, INREG32(module_base + 0x138));
  957. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  958. module_name,
  959. 0x13c, INREG32(module_base + 0x13c),
  960. 0x140, INREG32(module_base + 0x140),
  961. 0x144, INREG32(module_base + 0x144),
  962. 0x148, INREG32(module_base + 0x148));
  963. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  964. module_name,
  965. 0x14c, INREG32(module_base + 0x14c),
  966. 0x150, INREG32(module_base + 0x150),
  967. 0x154, INREG32(module_base + 0x154),
  968. 0x158, INREG32(module_base + 0x158));
  969. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  970. module_name,
  971. 0x15c, INREG32(module_base + 0x15c),
  972. 0x160, INREG32(module_base + 0x160),
  973. 0x164, INREG32(module_base + 0x164),
  974. 0x168, INREG32(module_base + 0x168));
  975. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  976. module_name,
  977. 0x16c, INREG32(module_base + 0x16c),
  978. 0x170, INREG32(module_base + 0x170),
  979. 0x174, INREG32(module_base + 0x174),
  980. 0x178, INREG32(module_base + 0x178));
  981. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  982. module_name,
  983. 0x17c, INREG32(module_base + 0x17c),
  984. 0x180, INREG32(module_base + 0x180),
  985. 0x184, INREG32(module_base + 0x184),
  986. 0x188, INREG32(module_base + 0x188));
  987. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  988. module_name,
  989. 0x18c, INREG32(module_base + 0x18c),
  990. 0x190, INREG32(module_base + 0x190),
  991. 0x194, INREG32(module_base + 0x194),
  992. 0x198, INREG32(module_base + 0x198));
  993. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  994. module_name,
  995. 0x19c, INREG32(module_base + 0x19c),
  996. 0x1a0, INREG32(module_base + 0x1a0),
  997. 0x1a4, INREG32(module_base + 0x1a4),
  998. 0x1a8, INREG32(module_base + 0x1a8));
  999. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1000. module_name,
  1001. 0x1ac, INREG32(module_base + 0x1ac),
  1002. 0x1b0, INREG32(module_base + 0x1b0),
  1003. 0x1b4, INREG32(module_base + 0x1b4),
  1004. 0x1b8, INREG32(module_base + 0x1b8));
  1005. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1006. module_name,
  1007. 0x1bc, INREG32(module_base + 0x1bc),
  1008. 0x1c0, INREG32(module_base + 0x1c0),
  1009. 0x1c4, INREG32(module_base + 0x1c4),
  1010. 0x1c8, INREG32(module_base + 0x1c8));
  1011. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1012. module_name,
  1013. 0x1cc, INREG32(module_base + 0x1cc),
  1014. 0x1d0, INREG32(module_base + 0x1d0),
  1015. 0x1d4, INREG32(module_base + 0x1d4),
  1016. 0x1dc, INREG32(module_base + 0x1dc));
  1017. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1018. module_name,
  1019. 0x1e0, INREG32(module_base + 0x1e0),
  1020. 0x1e4, INREG32(module_base + 0x1e4),
  1021. 0x1e8, INREG32(module_base + 0x1e8),
  1022. 0x1ec, INREG32(module_base + 0x1ec));
  1023. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1024. module_name,
  1025. 0x1F0, INREG32(module_base + 0x1F0),
  1026. 0x1F4, INREG32(module_base + 0x1F4),
  1027. 0x1F8, INREG32(module_base + 0x1F8),
  1028. 0x1FC, INREG32(module_base + 0x1FC));
  1029. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1030. module_name,
  1031. 0x200, INREG32(module_base + 0x200),
  1032. 0x208, INREG32(module_base + 0x208),
  1033. 0x20C, INREG32(module_base + 0x20C),
  1034. 0x210, INREG32(module_base + 0x210));
  1035. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1036. module_name,
  1037. 0x214, INREG32(module_base + 0x214),
  1038. 0x218, INREG32(module_base + 0x218),
  1039. 0x21C, INREG32(module_base + 0x21C),
  1040. 0x220, INREG32(module_base + 0x220));
  1041. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1042. module_name,
  1043. 0x224, INREG32(module_base + 0x224),
  1044. 0x228, INREG32(module_base + 0x228),
  1045. 0x22C, INREG32(module_base + 0x22C),
  1046. 0x230, INREG32(module_base + 0x230));
  1047. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1048. module_name,
  1049. 0x234, INREG32(module_base + 0x234),
  1050. 0x238, INREG32(module_base + 0x238),
  1051. 0x240, INREG32(module_base + 0x240),
  1052. 0x244, INREG32(module_base + 0x244));
  1053. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1054. module_name,
  1055. 0x24c, INREG32(module_base + 0x24c),
  1056. 0x250, INREG32(module_base + 0x250),
  1057. 0x254, INREG32(module_base + 0x254),
  1058. 0x258, INREG32(module_base + 0x258));
  1059. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1060. module_name,
  1061. 0x25c, INREG32(module_base + 0x25c),
  1062. 0x260, INREG32(module_base + 0x260),
  1063. 0x264, INREG32(module_base + 0x264),
  1064. 0x268, INREG32(module_base + 0x268));
  1065. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1066. module_name,
  1067. 0x26C, INREG32(module_base + 0x26C),
  1068. 0x270, INREG32(module_base + 0x270),
  1069. 0x280, INREG32(module_base + 0x280),
  1070. 0x284, INREG32(module_base + 0x284));
  1071. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1072. module_name,
  1073. 0x288, INREG32(module_base + 0x288),
  1074. 0x28C, INREG32(module_base + 0x28C),
  1075. 0x290, INREG32(module_base + 0x290),
  1076. 0x29C, INREG32(module_base + 0x29C));
  1077. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1078. module_name,
  1079. 0x2A0, INREG32(module_base + 0x2A0),
  1080. 0x2A4, INREG32(module_base + 0x2A4),
  1081. 0x2B0, INREG32(module_base + 0x2B0),
  1082. 0x2B4, INREG32(module_base + 0x2B4));
  1083. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1084. module_name,
  1085. 0x2B8, INREG32(module_base + 0x2B8),
  1086. 0x2BC, INREG32(module_base + 0x2BC),
  1087. 0x2C0, INREG32(module_base + 0x2C0),
  1088. 0x2C4, INREG32(module_base + 0x2C4));
  1089. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1090. module_name,
  1091. 0x2C8, INREG32(module_base + 0x2C8),
  1092. 0x324, INREG32(module_base + 0x324),
  1093. 0x330, INREG32(module_base + 0x330),
  1094. 0x334, INREG32(module_base + 0x334));
  1095. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1096. module_name,
  1097. 0x338, INREG32(module_base + 0x338),
  1098. 0x33C, INREG32(module_base + 0x33C),
  1099. 0xFB0, INREG32(module_base + 0xFB0),
  1100. 0x344, INREG32(module_base + 0x344));
  1101. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1102. module_name,
  1103. 0x348, INREG32(module_base + 0x348),
  1104. 0x34C, INREG32(module_base + 0x34C),
  1105. 0x350, INREG32(module_base + 0x350),
  1106. 0x354, INREG32(module_base + 0x354));
  1107. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1108. module_name,
  1109. 0x358, INREG32(module_base + 0x358),
  1110. 0x35C, INREG32(module_base + 0x35C),
  1111. 0xFB4, INREG32(module_base + 0xFB4),
  1112. 0x364, INREG32(module_base + 0x364));
  1113. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1114. module_name,
  1115. 0x368, INREG32(module_base + 0x368),
  1116. 0x36C, INREG32(module_base + 0x36C),
  1117. 0x370, INREG32(module_base + 0x370),
  1118. 0x374, INREG32(module_base + 0x374));
  1119. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1120. module_name,
  1121. 0x378, INREG32(module_base + 0x378),
  1122. 0x37C, INREG32(module_base + 0x37C),
  1123. 0xFB8, INREG32(module_base + 0xFB8),
  1124. 0x384, INREG32(module_base + 0x384));
  1125. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1126. module_name,
  1127. 0x388, INREG32(module_base + 0x388),
  1128. 0x38C, INREG32(module_base + 0x38C),
  1129. 0x390, INREG32(module_base + 0x390),
  1130. 0x394, INREG32(module_base + 0x394));
  1131. DDPDUMP("%s 0x%04x=0x%08x, 0x%04x=0x%08x\n",
  1132. module_name,
  1133. 0x398, INREG32(module_base + 0x398),
  1134. 0xFC0, INREG32(module_base + 0xFC0));
  1135. DDPDUMP("-- END: DISP %s registers --\n", module_name);
  1136. #endif
  1137. ovl_dump_golden_setting(module);
  1138. }
  1139. static void ovl_printf_status(unsigned int status)
  1140. {
  1141. DDPDUMP("=OVL_FLOW_CONTROL_DEBUG=:\n");
  1142. DDPDUMP("addcon_idle:%d,blend_idle:%d,out_valid:%d,out_ready:%d,out_idle:%d\n",
  1143. (status >> 10) & (0x1),
  1144. (status >> 11) & (0x1),
  1145. (status >> 12) & (0x1), (status >> 13) & (0x1), (status >> 15) & (0x1)
  1146. );
  1147. DDPDUMP("rdma3_idle:%d,rdma2_idle:%d,rdma1_idle:%d, rdma0_idle:%d,rst:%d\n",
  1148. (status >> 16) & (0x1),
  1149. (status >> 17) & (0x1),
  1150. (status >> 18) & (0x1), (status >> 19) & (0x1), (status >> 20) & (0x1)
  1151. );
  1152. DDPDUMP("trig:%d,frame_hwrst_done:%d,frame_swrst_done:%d,frame_underrun:%d,frame_done:%d\n",
  1153. (status >> 21) & (0x1),
  1154. (status >> 23) & (0x1),
  1155. (status >> 24) & (0x1), (status >> 25) & (0x1), (status >> 26) & (0x1)
  1156. );
  1157. DDPDUMP("ovl_running:%d,ovl_start:%d,ovl_clr:%d,reg_update:%d,ovl_upd_reg:%d\n",
  1158. (status >> 27) & (0x1),
  1159. (status >> 28) & (0x1),
  1160. (status >> 29) & (0x1), (status >> 30) & (0x1), (status >> 31) & (0x1)
  1161. );
  1162. DDPDUMP("ovl_fms_state:\n");
  1163. switch (status & 0x3ff) {
  1164. case 0x1:
  1165. DDPDUMP("idle\n");
  1166. break;
  1167. case 0x2:
  1168. DDPDUMP("wait_SOF\n");
  1169. break;
  1170. case 0x4:
  1171. DDPDUMP("prepare\n");
  1172. break;
  1173. case 0x8:
  1174. DDPDUMP("reg_update\n");
  1175. break;
  1176. case 0x10:
  1177. DDPDUMP("eng_clr(internal reset)\n");
  1178. break;
  1179. case 0x20:
  1180. DDPDUMP("eng_act(processing)\n");
  1181. break;
  1182. case 0x40:
  1183. DDPDUMP("h_wait_w_rst\n");
  1184. break;
  1185. case 0x80:
  1186. DDPDUMP("s_wait_w_rst\n");
  1187. break;
  1188. case 0x100:
  1189. DDPDUMP("h_w_rst\n");
  1190. break;
  1191. case 0x200:
  1192. DDPDUMP("s_w_rst\n");
  1193. break;
  1194. default:
  1195. DDPDUMP("ovl_fsm_unknown\n");
  1196. break;
  1197. }
  1198. }
  1199. static void ovl_print_ovl_rdma_status(unsigned int status)
  1200. {
  1201. DDPDUMP("wram_rst_cs:0x%x,layer_greq:0x%x,out_data:0x%x,",
  1202. status & 0x7, (status >> 3) & 0x1, (status >> 4) & 0xffffff);
  1203. DDPDUMP("out_ready:0x%x,out_valid:0x%x,smi_busy:0x%x,smi_greq:0x%x\n",
  1204. (status >> 28) & 0x1, (status >> 29) & 0x1, (status >> 30) & 0x1,
  1205. (status >> 31) & 0x1);
  1206. }
  1207. static void ovl_dump_layer_info(int layer, unsigned long layer_offset)
  1208. {
  1209. DDPDUMP("layer%d: w=%d,h=%d,off(x=%d,y=%d),pitch=%d,addr=0x%x,fmt=%s,source=%s,aen=%d,alpha=%d\n",
  1210. layer, DISP_REG_GET(layer_offset + DISP_REG_OVL_L0_SRC_SIZE) & 0xfff,
  1211. (DISP_REG_GET(layer_offset + DISP_REG_OVL_L0_SRC_SIZE) >> 16) & 0xfff,
  1212. DISP_REG_GET(layer_offset + DISP_REG_OVL_L0_OFFSET) & 0xfff,
  1213. (DISP_REG_GET(layer_offset + DISP_REG_OVL_L0_OFFSET) >> 16) & 0xfff,
  1214. DISP_REG_GET(layer_offset + DISP_REG_OVL_L0_PITCH) & 0xffff,
  1215. DISP_REG_GET(layer_offset + DISP_REG_OVL_L0_ADDR),
  1216. ovl_intput_format_name(
  1217. DISP_REG_GET_FIELD(L_CON_FLD_CFMT, DISP_REG_OVL_L0_CON+layer_offset),
  1218. DISP_REG_GET_FIELD(L_CON_FLD_BTSW, DISP_REG_OVL_L0_CON+layer_offset)),
  1219. (DISP_REG_GET_FIELD(L_CON_FLD_LARC, DISP_REG_OVL_L0_CON + layer_offset) ==
  1220. 0) ? "memory" : "constant_color", DISP_REG_GET_FIELD(L_CON_FLD_AEN,
  1221. DISP_REG_OVL_L0_CON +
  1222. layer_offset),
  1223. DISP_REG_GET_FIELD(L_CON_FLD_APHA, DISP_REG_OVL_L0_CON + layer_offset)
  1224. );
  1225. }
  1226. void ovl_dump_analysis(DISP_MODULE_ENUM module)
  1227. {
  1228. int i = 0;
  1229. unsigned int layer_offset = 0;
  1230. unsigned int rdma_offset = 0;
  1231. int idx = ovl_index(module);
  1232. unsigned int offset = idx * DISP_INDEX_OFFSET;
  1233. unsigned int src_on = DISP_REG_GET(DISP_REG_OVL_SRC_CON+offset);
  1234. unsigned int rdma_ctrl;
  1235. DDPDUMP("==DISP %s ANALYSIS==\n", ddp_get_module_name(module));
  1236. DDPDUMP("ovl_en=%d,layer_enable(%d,%d,%d,%d),bg(w=%d, h=%d),",
  1237. DISP_REG_GET(DISP_REG_OVL_EN + offset),
  1238. DISP_REG_GET(DISP_REG_OVL_SRC_CON + offset) & 0x1,
  1239. (DISP_REG_GET(DISP_REG_OVL_SRC_CON + offset) >> 1) & 0x1,
  1240. (DISP_REG_GET(DISP_REG_OVL_SRC_CON + offset) >> 2) & 0x1,
  1241. (DISP_REG_GET(DISP_REG_OVL_SRC_CON + offset) >> 3) & 0x1,
  1242. DISP_REG_GET(DISP_REG_OVL_ROI_SIZE + offset) & 0xfff,
  1243. (DISP_REG_GET(DISP_REG_OVL_ROI_SIZE + offset) >> 16) & 0xfff);
  1244. DDPDUMP("cur_pos(x=%d,y=%d),layer_hit(%d,%d,%d,%d),bg_mode=%s,sta=0x%x\n",
  1245. DISP_REG_GET_FIELD(ADDCON_DBG_FLD_ROI_X, DISP_REG_OVL_ADDCON_DBG + offset),
  1246. DISP_REG_GET_FIELD(ADDCON_DBG_FLD_ROI_Y, DISP_REG_OVL_ADDCON_DBG + offset),
  1247. DISP_REG_GET_FIELD(ADDCON_DBG_FLD_L0_WIN_HIT, DISP_REG_OVL_ADDCON_DBG + offset),
  1248. DISP_REG_GET_FIELD(ADDCON_DBG_FLD_L1_WIN_HIT, DISP_REG_OVL_ADDCON_DBG + offset),
  1249. DISP_REG_GET_FIELD(ADDCON_DBG_FLD_L2_WIN_HIT, DISP_REG_OVL_ADDCON_DBG + offset),
  1250. DISP_REG_GET_FIELD(ADDCON_DBG_FLD_L3_WIN_HIT, DISP_REG_OVL_ADDCON_DBG + offset),
  1251. DISP_REG_GET_FIELD(DATAPATH_CON_FLD_BGCLR_IN_SEL,
  1252. DISP_REG_OVL_DATAPATH_CON + offset) ? "directlink" : "const",
  1253. DISP_REG_GET(DISP_REG_OVL_STA + offset)
  1254. );
  1255. for (i = 0; i < 4; i++) {
  1256. layer_offset = i * OVL_LAYER_OFFSET + offset;
  1257. rdma_offset = i * OVL_RDMA_DEBUG_OFFSET + offset;
  1258. if (src_on & (0x1 << i))
  1259. ovl_dump_layer_info(i, layer_offset);
  1260. else
  1261. DDPDUMP("layer%d: disabled\n", i);
  1262. rdma_ctrl = DISP_REG_GET(layer_offset + DISP_REG_OVL_RDMA0_CTRL);
  1263. DDPDUMP("ovl rdma%d status:(en=%d, fifo_used %d, GMC=0x%x)\n", i,
  1264. REG_FLD_VAL_GET(RDMA0_CTRL_FLD_RDMA_EN, rdma_ctrl),
  1265. REG_FLD_VAL_GET(RDMA0_CTRL_FLD_RMDA_FIFO_USED_SZ, rdma_ctrl),
  1266. DISP_REG_GET(layer_offset + DISP_REG_OVL_RDMA0_MEM_GMC_SETTING));
  1267. ovl_print_ovl_rdma_status(DISP_REG_GET(DISP_REG_OVL_RDMA0_DBG + rdma_offset));
  1268. }
  1269. ovl_printf_status(DISP_REG_GET(DISP_REG_OVL_FLOW_CTRL_DBG + offset));
  1270. }
  1271. static inline unsigned long ovl_layer_num(DISP_MODULE_ENUM module)
  1272. {
  1273. switch (module) {
  1274. case DISP_MODULE_OVL0:
  1275. case DISP_MODULE_OVL1:
  1276. return 4;
  1277. case DISP_MODULE_OVL0_2L:
  1278. case DISP_MODULE_OVL1_2L:
  1279. case DISP_MODULE_OVL2_2L:
  1280. case DISP_MODULE_OVL3_2L:
  1281. return 2;
  1282. default:
  1283. DDPERR("invalid ovl module=%d\n", module);
  1284. ASSERT(0);
  1285. }
  1286. return 0;
  1287. }
  1288. void ovl_cal_golden_setting(unsigned int *gs)
  1289. {
  1290. /* OVL_RDMA_MEM_GMC_SETTING_1 */
  1291. gs[GS_OVL_RDMA_ULTRA_TH] = 0x3ff;
  1292. gs[GS_OVL_RDMA_PRE_ULTRA_TH] = 0x3ff;
  1293. /* OVL_RDMA_FIFO_CTRL */
  1294. gs[GS_OVL_RDMA_FIFO_THRD] = 0;
  1295. gs[GS_OVL_RDMA_FIFO_SIZE] = 384;
  1296. /* OVL_RDMA_MEM_GMC_SETTING_2 */
  1297. gs[GS_OVL_RDMA_ISSUE_REQ_TH] = 255;
  1298. gs[GS_OVL_RDMA_ISSUE_REQ_TH_URG] = 127;
  1299. gs[GS_OVL_RDMA_REQ_TH_PRE_ULTRA] = 0;
  1300. gs[GS_OVL_RDMA_REQ_TH_ULTRA] = 1;
  1301. gs[GS_OVL_RDMA_FORCE_REQ_TH] = 0;
  1302. /* OVL_RDMA_GREQ_NUM */
  1303. gs[GS_OVL_RDMA_GREQ_NUM] = 0xF1FF7777;
  1304. /* OVL_RDMA_GREQURG_NUM */
  1305. gs[GS_OVL_RDMA_GREQ_URG_NUM] = 0x7777;
  1306. /* OVL_RDMA_ULTRA_SRC */
  1307. gs[GS_OVL_RDMA_ULTRA_SRC] = 0x8040;
  1308. /* OVL_RDMA_BUF_LOW_TH */
  1309. gs[GS_OVL_RDMA_ULTRA_LOW_TH] = 0;
  1310. gs[GS_OVL_RDMA_PRE_ULTRA_LOW_TH] = 0;
  1311. /* OVL_RDMA_BUF_HIGH_TH */
  1312. gs[GS_OVL_RDMA_PRE_ULTRA_HIGH_TH] = 0;
  1313. gs[GS_OVL_RDMA_PRE_ULTRA_HIGH_DIS] = 1;
  1314. /* OVL_EN */
  1315. gs[GS_OVL_BLOCK_EXT_ULTRA] = 0;
  1316. gs[GS_OVL_BLOCK_EXT_PRE_ULTRA] = 0;
  1317. }
  1318. static int ovl_golden_setting(DISP_MODULE_ENUM module, void *cmdq)
  1319. {
  1320. unsigned long baddr = ovl_base_addr(module);
  1321. unsigned int regval;
  1322. unsigned int gs[GS_OVL_FLD_NUM];
  1323. int i, layer_num;
  1324. unsigned long Lx_base;
  1325. baddr -= DISPSYS_OVL0_BASE;
  1326. layer_num = ovl_layer_num(module);
  1327. /* calculate ovl golden setting */
  1328. ovl_cal_golden_setting(gs);
  1329. /* OVL_RDMA_MEM_GMC_SETTING_1 */
  1330. regval = gs[GS_OVL_RDMA_ULTRA_TH] +
  1331. (gs[GS_OVL_RDMA_PRE_ULTRA_TH] << 16);
  1332. for (i = 0; i < layer_num; i++) {
  1333. Lx_base = i * OVL_LAYER_OFFSET + baddr;
  1334. DISP_REG_SET(cmdq, Lx_base +
  1335. DISP_REG_OVL_RDMA0_MEM_GMC_SETTING, regval);
  1336. }
  1337. /* OVL_RDMA_FIFO_CTRL */
  1338. regval = gs[GS_OVL_RDMA_FIFO_THRD] +
  1339. (gs[GS_OVL_RDMA_FIFO_SIZE] << 16);
  1340. for (i = 0; i < layer_num; i++) {
  1341. Lx_base = i * OVL_LAYER_OFFSET + baddr;
  1342. DISP_REG_SET(cmdq, Lx_base + DISP_REG_OVL_RDMA0_FIFO_CTRL,
  1343. regval);
  1344. }
  1345. /* OVL_RDMA_MEM_GMC_SETTING_2 */
  1346. regval = gs[GS_OVL_RDMA_ISSUE_REQ_TH] +
  1347. (gs[GS_OVL_RDMA_ISSUE_REQ_TH_URG] << 16) +
  1348. (gs[GS_OVL_RDMA_REQ_TH_PRE_ULTRA] << 28) +
  1349. (gs[GS_OVL_RDMA_REQ_TH_ULTRA] << 29) +
  1350. (gs[GS_OVL_RDMA_FORCE_REQ_TH] << 30);
  1351. for (i = 0; i < layer_num; i++)
  1352. DISP_REG_SET(cmdq, baddr + DISP_REG_OVL_RDMA0_MEM_GMC_S2 +
  1353. i * 4, regval);
  1354. /* DISP_REG_OVL_RDMA_GREQ_NUM */
  1355. regval = gs[GS_OVL_RDMA_GREQ_NUM];
  1356. DISP_REG_SET(cmdq, baddr + DISP_REG_OVL_RDMA_GREQ_NUM, regval);
  1357. /* DISP_REG_OVL_RDMA_GREQ_URG_NUM */
  1358. regval = gs[GS_OVL_RDMA_GREQ_URG_NUM];
  1359. DISP_REG_SET(cmdq, baddr + DISP_REG_OVL_RDMA_GREQ_URG_NUM, regval);
  1360. /* DISP_REG_OVL_RDMA_ULTRA_SRC */
  1361. regval = gs[GS_OVL_RDMA_ULTRA_SRC];
  1362. DISP_REG_SET(cmdq, baddr + DISP_REG_OVL_RDMA_ULTRA_SRC, regval);
  1363. /* DISP_REG_OVL_RDMAn_BUF_LOW */
  1364. regval = gs[GS_OVL_RDMA_ULTRA_LOW_TH] +
  1365. (gs[GS_OVL_RDMA_PRE_ULTRA_LOW_TH] << 12);
  1366. for (i = 0; i < layer_num; i++)
  1367. DISP_REG_SET(cmdq, baddr + DISP_REG_OVL_RDMAn_BUF_LOW(i),
  1368. regval);
  1369. /* DISP_REG_OVL_RDMAn_BUF_HIGH */
  1370. regval = (gs[GS_OVL_RDMA_PRE_ULTRA_HIGH_TH] << 12) +
  1371. (gs[GS_OVL_RDMA_PRE_ULTRA_HIGH_DIS] << 31);
  1372. for (i = 0; i < layer_num; i++)
  1373. DISP_REG_SET(cmdq, baddr + DISP_REG_OVL_RDMAn_BUF_HIGH(i),
  1374. regval);
  1375. /* OVL_EN */
  1376. regval = gs[GS_OVL_BLOCK_EXT_ULTRA] +
  1377. (gs[GS_OVL_BLOCK_EXT_PRE_ULTRA] << 1);
  1378. DISP_REG_SET_FIELD(cmdq, REG_FLD_MSB_LSB(19, 18), baddr +
  1379. DISP_REG_OVL_EN, regval);
  1380. /* Set ultra_sel of ovl0 & ovl0_2l to RDMA0 if path is DL with rsz
  1381. * OVL0_2l -> RSZ -> OVL0 -> RDMA0 -> DSI
  1382. */
  1383. DISP_REG_SET_FIELD(cmdq, mmsys_ovl_ultra_offset(module),
  1384. DISP_REG_CONFIG_MMSYS_MISC, 1);
  1385. return 0;
  1386. }
  1387. static int OVLConfig_l(DISP_MODULE_ENUM module, disp_ddp_path_config* pConfig, void* handle)
  1388. {
  1389. int enabled_layers = 0;
  1390. unsigned int local_layer = 0, global_layer = 0;
  1391. int idx = ovl_index(module);
  1392. if (pConfig->dst_dirty) {
  1393. OVLROI(module,
  1394. pConfig->dst_w, // width
  1395. pConfig->dst_h, // height
  1396. 0xFF000000, // background color
  1397. handle);
  1398. }
  1399. if (!pConfig->ovl_dirty) {
  1400. return 0;
  1401. }
  1402. for (global_layer = 0; global_layer < TOTAL_OVL_LAYER_NUM; global_layer++) {
  1403. if (!(pConfig->ovl_layer_scanned & (1 << global_layer)))
  1404. break;
  1405. }
  1406. if (global_layer > TOTAL_OVL_LAYER_NUM - ovl_layer_num(module)) {
  1407. DDPERR("%s: %s scan error, layer_scanned=%u\n", __func__,
  1408. ddp_get_module_name(module), pConfig->ovl_layer_scanned);
  1409. ASSERT(0);
  1410. }
  1411. for (local_layer = 0; local_layer < ovl_layer_num(module); local_layer++, global_layer++) {
  1412. OVL_CONFIG_STRUCT *ovl_cfg = &pConfig->ovl_config[global_layer];
  1413. pConfig->ovl_layer_scanned |= (1 << global_layer);
  1414. if (ovl_cfg->layer_en == 0)
  1415. continue;
  1416. if (ovl_cfg->addr==0 || ovl_cfg->dst_w==0 || ovl_cfg->dst_h==0) {
  1417. DDPERR("ovl parameter invalidate, addr=0x%x, w=%d, h=%d \n",
  1418. ovl_cfg->addr,
  1419. ovl_cfg->dst_w,
  1420. ovl_cfg->dst_h);
  1421. return -1;
  1422. }
  1423. DDPDBG("module %d, layer=%d, en=%d, src=%d, fmt=%d, addr=0x%x, x=%d, y=%d, pitch=%d, dst(%d, %d, %d, %d),keyEn=%d, key=%d, aen=%d, alpha=%d\n",
  1424. module,
  1425. local_layer,
  1426. ovl_cfg->layer_en,
  1427. ovl_cfg->source, // data source (0=memory)
  1428. ovl_cfg->fmt,
  1429. ovl_cfg->addr, // addr
  1430. ovl_cfg->src_x, // x
  1431. ovl_cfg->src_y, // y
  1432. ovl_cfg->src_pitch, //pitch, pixel number
  1433. ovl_cfg->dst_x, // x
  1434. ovl_cfg->dst_y, // y
  1435. ovl_cfg->dst_w, // width
  1436. ovl_cfg->dst_h, // height
  1437. ovl_cfg->keyEn, //color key
  1438. ovl_cfg->key, //color key
  1439. ovl_cfg->aen, // alpha enable
  1440. ovl_cfg->alpha);
  1441. OVLLayerConfig(module,
  1442. local_layer,
  1443. ovl_cfg->source,
  1444. ovl_cfg->fmt,
  1445. ovl_cfg->addr,
  1446. ovl_cfg->src_x,
  1447. ovl_cfg->src_y,
  1448. ovl_cfg->src_pitch,
  1449. ovl_cfg->dst_x,
  1450. ovl_cfg->dst_y,
  1451. ovl_cfg->dst_w,
  1452. ovl_cfg->dst_h,
  1453. ovl_cfg->keyEn,
  1454. ovl_cfg->key,
  1455. ovl_cfg->aen,
  1456. ovl_cfg->alpha,
  1457. handle);
  1458. // print_layer_config_args(module, local_layer, ovl_cfg);
  1459. // ovl_layer_config(module, local_layer, has_sec_layer, ovl_cfg, handle);
  1460. enabled_layers |= 1 << local_layer;
  1461. }
  1462. DISP_REG_SET(handle, idx * DISP_INDEX_OFFSET + DISP_REG_OVL_SRC_CON, enabled_layers);
  1463. ovl_golden_setting(module, handle);
  1464. return 0;
  1465. }
  1466. DDP_MODULE_DRIVER ddp_driver_ovl = {
  1467. .module = DISP_MODULE_OVL0,
  1468. .init = OVLInit,
  1469. .deinit = OVLDeInit,
  1470. .config = OVLConfig_l,
  1471. .start = OVLStart,
  1472. .trigger = NULL,
  1473. .stop = OVLStop,
  1474. .reset = NULL,
  1475. .power_on = OVLClockOn,
  1476. .power_off = OVLClockOff,
  1477. .is_idle = NULL,
  1478. .is_busy = NULL,
  1479. .dump_info = NULL,
  1480. .bypass = NULL,
  1481. .build_cmdq = NULL,
  1482. .set_lcm_utils = NULL,
  1483. .connect = OVLConnect,
  1484. };