ddp_path.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  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 "ddp_path"
  32. #include "platform/mt_irq.h"
  33. #include "platform/mt_irq.h"
  34. #include "platform/disp_drv_platform.h"
  35. #include "platform/ddp_reg.h"
  36. #include "platform/ddp_path.h"
  37. #include "platform/ddp_info.h"
  38. #include "platform/ddp_log.h"
  39. typedef struct module_map_s {
  40. DISP_MODULE_ENUM module;
  41. int bit;
  42. int mod_num;
  43. } module_map_t;
  44. typedef struct {
  45. int m;
  46. int v;
  47. } m_to_b;
  48. typedef struct mout_s {
  49. int id;
  50. m_to_b out_id_bit_map[6];
  51. volatile unsigned long *reg;
  52. unsigned int reg_val;
  53. } mout_t;
  54. typedef struct selection_s {
  55. int id;
  56. int id_bit_map[6];
  57. volatile unsigned long *reg;
  58. unsigned int reg_val;
  59. } sel_t;
  60. #define DDP_ENING_NUM (20)
  61. #define DDP_MOUT_NUM 10
  62. #define DDP_SEL_OUT_NUM 10
  63. #define DDP_SEL_IN_NUM 20
  64. #define DDP_MUTEX_MAX 5
  65. unsigned int module_list_scenario[DDP_SCENARIO_MAX][DDP_ENING_NUM] = {
  66. /*PRIMARY_DISP */
  67. {
  68. DISP_MODULE_OVL0, DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0_VIRTUAL,
  69. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0, /*DISP_MODULE_OD,*/
  70. DISP_MODULE_DITHER0, DISP_MODULE_RDMA0, DISP_PATH0,
  71. DISP_MODULE_UFOE, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1},
  72. /*PRIMARY_RDMA0_COLOR0_DISP */
  73. {
  74. DISP_MODULE_RDMA0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, DISP_MODULE_AAL0,
  75. DISP_MODULE_GAMMA0, /*DISP_MODULE_OD,*/ DISP_MODULE_DITHER0, DISP_PATH0, DISP_MODULE_UFOE,
  76. DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1},
  77. /*PRIMARY_RDMA0_DISP */
  78. {
  79. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1},
  80. /*PRIMARY_BYPASS_RDMA */
  81. {
  82. DISP_MODULE_OVL0, DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0_VIRTUAL,
  83. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0, /*DISP_MODULE_OD,*/
  84. DISP_MODULE_DITHER0, DISP_PATH0,
  85. DISP_MODULE_UFOE, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1},
  86. /*PRIMARY_OVL_MEMOUT */
  87. {
  88. DISP_MODULE_OVL0, DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0_VIRTUAL, DISP_MODULE_WDMA0, -1},
  89. /*PRIMARY_DITHER_MEMOUT */
  90. {
  91. DISP_MODULE_OVL0, DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0_VIRTUAL,
  92. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0, /*DISP_MODULE_OD,*/
  93. DISP_MODULE_DITHER0, DISP_MODULE_WDMA0, -1},
  94. /*PRIMARY_UFOE_MEMOUT */
  95. {
  96. DISP_MODULE_OVL0, DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0_VIRTUAL,
  97. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0, /*DISP_MODULE_OD,*/
  98. DISP_MODULE_DITHER0, DISP_MODULE_RDMA0, DISP_PATH0, DISP_MODULE_UFOE, DISP_MODULE_WDMA0, -1},
  99. /*SUB_DISP */
  100. {
  101. DISP_MODULE_OVL1, DISP_MODULE_OVL1_2L, DISP_MODULE_RDMA1, DISP_MODULE_DSC, DISP_MODULE_DPI, -1},
  102. /*SUB_RDMA1_DISP */
  103. {
  104. DISP_MODULE_RDMA1, DISP_MODULE_DSC, DISP_MODULE_DPI, -1},
  105. /*SUB_OVL_MEMOUT */
  106. {
  107. DISP_MODULE_OVL1, DISP_MODULE_OVL1_2L, DISP_MODULE_WDMA1, -1},
  108. /*PRIMARY_DISP ALL*/
  109. {
  110. DISP_MODULE_OVL0, DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0_VIRTUAL, DISP_MODULE_WDMA0,
  111. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0, /*DISP_MODULE_OD,*/
  112. DISP_MODULE_DITHER0, DISP_MODULE_RDMA0, DISP_PATH0, DISP_MODULE_UFOE, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1},
  113. /*SUB_ALL */
  114. {
  115. DISP_MODULE_OVL1, DISP_MODULE_OVL1_2L, DISP_MODULE_WDMA1, DISP_MODULE_RDMA1, DISP_MODULE_DSC, DISP_MODULE_DPI, -1},
  116. /*DDP_SCENARIO_DITHER_1TO2*/
  117. {
  118. DISP_MODULE_OVL0, DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0_VIRTUAL,
  119. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0, /*DISP_MODULE_OD,*/
  120. DISP_MODULE_DITHER0, DISP_MODULE_WDMA0, DISP_MODULE_RDMA0, DISP_PATH0, DISP_MODULE_UFOE, DISP_MODULE_PWM0,
  121. DISP_MODULE_DSI0, -1},
  122. /*DDP_SCENARIO_UFOE_1TO2*/
  123. {
  124. DISP_MODULE_OVL0, DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0_VIRTUAL,
  125. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0, /*DISP_MODULE_OD,*/
  126. DISP_MODULE_DITHER0, DISP_MODULE_RDMA0, DISP_PATH0, DISP_MODULE_UFOE, DISP_MODULE_WDMA0, DISP_MODULE_PWM0,
  127. DISP_MODULE_DSI0, -1},
  128. };
  129. /* 1st para is mout's input, 2nd para is mout's output */
  130. static mout_t mout_map[DDP_MOUT_NUM] = {
  131. /* OVL_MOUT */
  132. {DISP_MODULE_OVL0,
  133. {{DISP_MODULE_OVL0_2L, 1 << 0}, {DISP_MODULE_WDMA0, 1 << 1}, {-1, 0} },
  134. 0, 0},
  135. {DISP_MODULE_OVL0_VIRTUAL,
  136. {{DISP_MODULE_COLOR0, 1 << 0}, {DISP_MODULE_WDMA0, 1 << 1}, {-1, 0} },
  137. 0, 0},
  138. {DISP_MODULE_OVL1,
  139. {{DISP_MODULE_OVL1_2L, 1 << 0}, {DISP_MODULE_OVL0_VIRTUAL, 1 << 1}, {DISP_MODULE_WDMA1, 1 << 2},
  140. {DISP_MODULE_COLOR1, 1 << 3}, {-1, 0} },
  141. 0, 0},
  142. {DISP_MODULE_OVL1_2L,
  143. {{DISP_MODULE_COLOR1, 1 << 0}, {DISP_MODULE_WDMA1, 1 << 1}, {DISP_MODULE_OVL0_VIRTUAL, 1 << 2},
  144. {-1, 0} },
  145. 0, 0},
  146. /* DITHER0_MOUT */
  147. {DISP_MODULE_DITHER0,
  148. {{DISP_MODULE_RDMA0, 1 << 0}, {DISP_PATH0, 1 << 1}, {DISP_MODULE_WDMA0, 1 << 2},
  149. {-1, 0} },
  150. 0, 0},
  151. {DISP_MODULE_DITHER1,
  152. {{DISP_MODULE_RDMA1, 1 << 0}, {DISP_PATH1, 1 << 1}, {DISP_MODULE_WDMA1, 1 << 2},
  153. {-1, 0} },
  154. 0, 0},
  155. /* UFOE_MOUT */
  156. {DISP_MODULE_UFOE,
  157. {{DISP_MODULE_DSI0, 1 << 0}, {DISP_MODULE_SPLIT0, 1 << 1},
  158. {DISP_MODULE_DPI, 1 << 2}, {DISP_MODULE_WDMA0, 1 << 3},
  159. {DISP_MODULE_DSI1, 1 << 4}, {-1, 0} },
  160. 0, 0},
  161. /* DSC_MOUT */
  162. {DISP_MODULE_DSC,
  163. {{DISP_MODULE_DSI0, 1 << 0}, {DISP_MODULE_DSI1, 1 << 1},
  164. {DISP_MODULE_DPI, 1 << 2}, {DISP_MODULE_WDMA1, 1 << 3},
  165. {-1, 0} },
  166. 0, 0}
  167. };
  168. static sel_t sel_out_map[DDP_SEL_OUT_NUM] = {
  169. /* DISP_PATH_SOUT */
  170. {DISP_PATH0, {DISP_MODULE_UFOE, DISP_MODULE_DSC, -1}, 0, 0},
  171. {DISP_PATH1, {DISP_MODULE_DSC, DISP_MODULE_UFOE, -1}, 0, 0},
  172. /* RDMA0_SOUT */
  173. {DISP_MODULE_RDMA0, {DISP_PATH0, DISP_MODULE_COLOR0, DISP_MODULE_DSI0,
  174. DISP_MODULE_DSI1, DISP_MODULE_DPI}, 0, 0},
  175. /* RDMA1_SOUT */
  176. {DISP_MODULE_RDMA1, {DISP_PATH1, DISP_MODULE_COLOR1, DISP_MODULE_DSI0,
  177. DISP_MODULE_DSI1, DISP_MODULE_DPI}, 0, 0},
  178. /* OVL0_SOUT */
  179. {DISP_MODULE_OVL0_2L, {DISP_MODULE_OVL0_VIRTUAL, DISP_MODULE_OVL1, DISP_MODULE_OVL1_2L, -1}, 0, 0},
  180. };
  181. /* 1st para is sout's output, 2nd para is sout's input */
  182. static sel_t sel_in_map[DDP_SEL_IN_NUM] = {
  183. /* COLOR_SEL */
  184. {DISP_MODULE_COLOR0, {DISP_MODULE_RDMA0, DISP_MODULE_OVL0_VIRTUAL, -1}, 0, 0},
  185. {DISP_MODULE_COLOR1, {DISP_MODULE_RDMA1, DISP_MODULE_OVL1_2L, DISP_MODULE_OVL1, -1}, 0, 0},
  186. /* WDMA_SEL */
  187. {DISP_MODULE_WDMA0, {DISP_MODULE_OVL0_VIRTUAL, DISP_MODULE_DITHER0, DISP_MODULE_UFOE, DISP_MODULE_OVL0, -1}, 0, 0},
  188. {DISP_MODULE_WDMA1, {DISP_MODULE_OVL1_2L, DISP_MODULE_DITHER1, DISP_MODULE_DSC, DISP_MODULE_OVL1, -1}, 0, 0},
  189. /* UFOE_SEL */
  190. {DISP_MODULE_UFOE, {DISP_PATH0, DISP_PATH1, -1}, 0, 0},
  191. /* DSC_SEL */
  192. {DISP_MODULE_DSC, {DISP_PATH0, DISP_PATH1, -1}, 0, 0},
  193. /* DSI_SEL */
  194. {DISP_MODULE_DSI0, {DISP_MODULE_UFOE, DISP_MODULE_SPLIT0, DISP_MODULE_RDMA0, DISP_MODULE_DSC, DISP_MODULE_RDMA1, -1}, 0, 0},
  195. {DISP_MODULE_DSI1, {DISP_MODULE_SPLIT0, DISP_MODULE_RDMA0, DISP_MODULE_DSC, DISP_MODULE_RDMA1, DISP_MODULE_UFOE, -1}, 0, 0},
  196. {DISP_MODULE_DSIDUAL, {DISP_MODULE_UFOE, DISP_MODULE_SPLIT0, -1}, 0, 0},
  197. {DISP_MODULE_DSIDUAL, {DISP_MODULE_SPLIT0, -1}, 0, 0},
  198. /* DPI0_SEL */
  199. {DISP_MODULE_DPI, {DISP_MODULE_UFOE, DISP_MODULE_RDMA0, DISP_MODULE_DSC, DISP_MODULE_RDMA1, DISP_MODULE_RDMA2, -1}, 0, 0},
  200. /* DISP_PATH0_SEL */
  201. {DISP_PATH0, {DISP_MODULE_RDMA0, DISP_MODULE_DITHER0, -1}, 0, 0},
  202. {DISP_PATH1, {DISP_MODULE_RDMA1, DISP_MODULE_DITHER1, -1}, 0, 0},
  203. /* OVL0_SEL */
  204. {DISP_MODULE_OVL0_VIRTUAL, {DISP_MODULE_OVL0_2L, DISP_MODULE_OVL1_2L, DISP_MODULE_OVL1, -1}, 0, 0},
  205. {DISP_MODULE_OVL1_2L, {DISP_MODULE_OVL0_2L, DISP_MODULE_OVL1, -1}, 0, 0},
  206. };
  207. int ddp_path_init(void)
  208. {
  209. /* mout */
  210. mout_map[0].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_OVL0_MOUT_EN;
  211. mout_map[1].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_OVL0_PQ_MOUT_EN;
  212. mout_map[2].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_OVL1_MOUT_EN;
  213. mout_map[3].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_OVL1_PQ_MOUT_EN;
  214. mout_map[4].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_DITHER_MOUT_EN;
  215. mout_map[5].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_DITHER1_MOUT_EN;
  216. mout_map[6].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_UFOE_MOUT_EN;
  217. mout_map[7].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_DSC_MOUT_EN;
  218. /* sel_out */
  219. sel_out_map[0].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_PATH0_SOUT_SEL_IN;
  220. sel_out_map[1].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_PATH1_SOUT_SEL_IN;
  221. sel_out_map[2].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_RDMA0_SOUT_SEL_IN;
  222. sel_out_map[3].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_RDMA1_SOUT_SEL_IN;
  223. sel_out_map[4].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_OVL0_SOUT_SEL_IN;
  224. /* sel_in */
  225. sel_in_map[0].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_COLOR0_SEL_IN;
  226. sel_in_map[1].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_COLOR1_SEL_IN;
  227. sel_in_map[2].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_WDMA0_SEL_IN;
  228. sel_in_map[3].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_WDMA1_SEL_IN;
  229. sel_in_map[4].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_UFOE_SEL_IN;
  230. sel_in_map[5].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_DSC_SEL_IN;
  231. sel_in_map[6].reg = (volatile unsigned long *)DISP_REG_CONFIG_DSI0_SEL_IN;
  232. sel_in_map[7].reg = (volatile unsigned long *)DISP_REG_CONFIG_DSI1_SEL_IN;
  233. sel_in_map[8].reg = (volatile unsigned long *)DISP_REG_CONFIG_DSI0_SEL_IN; /* DISDUAL for DSI0 */
  234. sel_in_map[9].reg = (volatile unsigned long *)DISP_REG_CONFIG_DSI1_SEL_IN; /* DISDUAL for DSI1 */
  235. sel_in_map[10].reg = (volatile unsigned long *)DISP_REG_CONFIG_DPI0_SEL_IN;
  236. sel_in_map[11].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_PATH0_SEL_IN;
  237. sel_in_map[12].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_PATH1_SEL_IN;
  238. sel_in_map[13].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_OVL0_SEL_IN;
  239. sel_in_map[14].reg = (volatile unsigned long *)DISP_REG_CONFIG_DISP_OVL1_2L_SEL_IN;
  240. return 0;
  241. }
  242. static module_map_t module_mutex_map[DISP_MODULE_NUM] = {
  243. {DISP_MODULE_OVL0, 13, 0},
  244. {DISP_MODULE_OVL1, 14, 0},
  245. {DISP_MODULE_OVL0_2L, 15, 0},
  246. {DISP_MODULE_OVL1_2L, 16, 0},
  247. {DISP_MODULE_OVL0_VIRTUAL, -1, 0},
  248. {DISP_MODULE_RDMA0, 0, 0},
  249. {DISP_MODULE_RDMA1, 1, 0},
  250. {DISP_MODULE_RDMA2, -1, 0},
  251. {DISP_MODULE_WDMA0, 17, 0},
  252. {DISP_MODULE_WDMA1, 18, 0},
  253. {DISP_MODULE_COLOR0, 19, 0},
  254. {DISP_MODULE_COLOR1, 20, 0},
  255. {DISP_MODULE_CCORR0, 21, 0},
  256. {DISP_MODULE_CCORR1, -1, 0},
  257. {DISP_MODULE_AAL0, 23, 0},
  258. {DISP_MODULE_AAL1, -1, 0},
  259. {DISP_MODULE_GAMMA0, 25, 0},
  260. {DISP_MODULE_GAMMA1, -1, 0},
  261. {DISP_MODULE_OD, -1, 0},
  262. {DISP_MODULE_DITHER0, 28, 0},
  263. {DISP_MODULE_DITHER1, -1, 0},
  264. {DISP_PATH0, -1, 0},
  265. {DISP_PATH1, -1, 0},
  266. {DISP_MODULE_UFOE, 30, 0},
  267. {DISP_MODULE_DSC, -1, 0},
  268. {DISP_MODULE_SPLIT0, -1, 0},
  269. {DISP_MODULE_DPI, -1, 0},
  270. {DISP_MODULE_DSI0, 1, 1},
  271. {DISP_MODULE_DSI1, 2, 1},
  272. {DISP_MODULE_DSIDUAL, 1, 1},
  273. {DISP_MODULE_PWM0, 0, 1},
  274. {DISP_MODULE_CONFIG, -1, 0},
  275. {DISP_MODULE_MUTEX, -1, 0},
  276. {DISP_MODULE_SMI_COMMON, -1, 0},
  277. {DISP_MODULE_SMI_LARB0, -1, 0},
  278. {DISP_MODULE_SMI_LARB4, -1, 0},
  279. {DISP_MODULE_MIPI0, -1, 0},
  280. {DISP_MODULE_MIPI1, -1, 0},
  281. {DISP_MODULE_UNKNOWN, -1, 0},
  282. };
  283. /* module can be connect if 1 */
  284. static module_map_t module_can_connect[DISP_MODULE_NUM] = {
  285. {DISP_MODULE_OVL0, 1, 0},
  286. {DISP_MODULE_OVL1, 1, 0},
  287. {DISP_MODULE_OVL0_2L, 1, 0},
  288. {DISP_MODULE_OVL1_2L, 1, 0},
  289. {DISP_MODULE_OVL0_VIRTUAL, 1, 0},
  290. {DISP_MODULE_RDMA0, 1, 0},
  291. {DISP_MODULE_RDMA1, 1, 0},
  292. {DISP_MODULE_RDMA2, 0, 0},
  293. {DISP_MODULE_WDMA0, 1, 0},
  294. {DISP_MODULE_WDMA1, 1, 0},
  295. {DISP_MODULE_COLOR0, 1, 0},
  296. {DISP_MODULE_COLOR1, 0, 0},
  297. {DISP_MODULE_CCORR0, 1, 0},
  298. {DISP_MODULE_CCORR0, 0, 0},
  299. {DISP_MODULE_AAL0, 1, 0},
  300. {DISP_MODULE_AAL1, 0, 0},
  301. {DISP_MODULE_GAMMA0, 1, 0},
  302. {DISP_MODULE_GAMMA1, 0, 0},
  303. {DISP_MODULE_OD, 1, 0},
  304. {DISP_MODULE_DITHER0, 1, 0},
  305. {DISP_MODULE_DITHER1, 0, 0},
  306. {DISP_PATH0, 1, 0},
  307. {DISP_PATH1, 1, 0},
  308. {DISP_MODULE_UFOE, 1, 0},
  309. {DISP_MODULE_DSC, 1, 0},
  310. {DISP_MODULE_SPLIT0, 1, 0},
  311. {DISP_MODULE_DPI, 1, 0},
  312. {DISP_MODULE_DSI0, 1, 0},
  313. {DISP_MODULE_DSI1, 1, 0},
  314. {DISP_MODULE_DSIDUAL, 0, 0},
  315. {DISP_MODULE_PWM0, 0, 0},
  316. {DISP_MODULE_CONFIG, 0, 0},
  317. {DISP_MODULE_MUTEX, 0, 0},
  318. {DISP_MODULE_SMI_COMMON, 0, 0},
  319. {DISP_MODULE_SMI_LARB0, 0, 0},
  320. {DISP_MODULE_SMI_LARB4, 0, 0},
  321. {DISP_MODULE_MIPI0, 0, 0},
  322. {DISP_MODULE_MIPI1, 0, 0},
  323. {DISP_MODULE_UNKNOWN, 0, 0},
  324. };
  325. char *ddp_get_scenario_name(DDP_SCENARIO_ENUM scenario)
  326. {
  327. switch (scenario) {
  328. case DDP_SCENARIO_PRIMARY_DISP:
  329. return "primary_disp";
  330. case DDP_SCENARIO_PRIMARY_RDMA0_COLOR0_DISP:
  331. return "primary_rdma0_color0_disp";
  332. case DDP_SCENARIO_PRIMARY_RDMA0_DISP:
  333. return "primary_rdma0_disp";
  334. case DDP_SCENARIO_PRIMARY_BYPASS_RDMA:
  335. return "primary_bypass_rdma";
  336. case DDP_SCENARIO_PRIMARY_OVL_MEMOUT:
  337. return "primary_ovl_memout";
  338. case DDP_SCENARIO_PRIMARY_DITHER_MEMOUT:
  339. return "primary_dither_memout";
  340. case DDP_SCENARIO_PRIMARY_UFOE_MEMOUT:
  341. return "primary_ufoe_memout";
  342. case DDP_SCENARIO_SUB_DISP:
  343. return "sub_disp";
  344. case DDP_SCENARIO_SUB_RDMA1_DISP:
  345. return "sub_rdma1_disp";
  346. case DDP_SCENARIO_SUB_OVL_MEMOUT:
  347. return "sub_ovl_memout";
  348. case DDP_SCENARIO_PRIMARY_ALL:
  349. return "primary_all";
  350. case DDP_SCENARIO_SUB_ALL:
  351. return "sub_all";
  352. case DDP_SCENARIO_DITHER_1TO2:
  353. return "dither_1to2";
  354. case DDP_SCENARIO_UFOE_1TO2:
  355. return "ufoe_1to2";
  356. default:
  357. DDPMSG("invalid scenario id=%d\n", scenario);
  358. return "unknown";
  359. }
  360. }
  361. int ddp_is_scenario_on_primary(DDP_SCENARIO_ENUM scenario)
  362. {
  363. int on_primary = 0;
  364. switch (scenario) {
  365. case DDP_SCENARIO_PRIMARY_DISP:
  366. case DDP_SCENARIO_PRIMARY_RDMA0_COLOR0_DISP:
  367. case DDP_SCENARIO_PRIMARY_RDMA0_DISP:
  368. case DDP_SCENARIO_PRIMARY_BYPASS_RDMA:
  369. case DDP_SCENARIO_PRIMARY_OVL_MEMOUT:
  370. case DDP_SCENARIO_PRIMARY_DITHER_MEMOUT:
  371. case DDP_SCENARIO_PRIMARY_UFOE_MEMOUT:
  372. case DDP_SCENARIO_PRIMARY_ALL:
  373. case DDP_SCENARIO_DITHER_1TO2:
  374. case DDP_SCENARIO_UFOE_1TO2:
  375. on_primary = 1;
  376. break;
  377. case DDP_SCENARIO_SUB_DISP:
  378. case DDP_SCENARIO_SUB_RDMA1_DISP:
  379. case DDP_SCENARIO_SUB_OVL_MEMOUT:
  380. case DDP_SCENARIO_SUB_ALL:
  381. on_primary = 0;
  382. break;
  383. default:
  384. DDPMSG("invalid scenario id=%d\n", scenario);
  385. }
  386. return on_primary;
  387. }
  388. char *ddp_get_mutex_sof_name(unsigned int regval)
  389. {
  390. if (regval == SOF_VAL_MUTEX0_SOF_SINGLE_MODE)
  391. return "single";
  392. else if (regval == SOF_VAL_MUTEX0_SOF_FROM_DSI0)
  393. return "dsi0";
  394. else if (regval == SOF_VAL_MUTEX0_SOF_FROM_DPI)
  395. return "dpi";
  396. DDPDUMP("%s, unknown reg=%d\n", __func__, regval);
  397. return "unknown";
  398. }
  399. char *ddp_get_mode_name(DDP_MODE ddp_mode)
  400. {
  401. switch (ddp_mode) {
  402. case DDP_VIDEO_MODE:
  403. return "vido_mode";
  404. case DDP_CMD_MODE:
  405. return "cmd_mode";
  406. default:
  407. DDPMSG("invalid ddp mode =%d\n", ddp_mode);
  408. return "unknown";
  409. }
  410. }
  411. static int ddp_get_module_num_l(int *module_list)
  412. {
  413. unsigned int num = 0;
  414. while (*(module_list + num) != -1) {
  415. num++;
  416. if (num == DDP_ENING_NUM)
  417. break;
  418. }
  419. return num;
  420. }
  421. /* config mout/msel to creat a compelte path */
  422. static void ddp_connect_path_l(int *module_list, void *handle)
  423. {
  424. unsigned int i, j, k;
  425. int step = 0;
  426. unsigned int mout = 0;
  427. unsigned int reg_mout = 0;
  428. unsigned int mout_idx = 0;
  429. unsigned int module_num = ddp_get_module_num_l(module_list);
  430. DDPDBG("connect_path: %s to %s\n", ddp_get_module_name(module_list[0]),
  431. ddp_get_module_name(module_list[module_num - 1]));
  432. /* connect mout */
  433. for (i = 0; i < module_num - 1; i++) {
  434. for (j = 0; j < DDP_MOUT_NUM; j++) {
  435. if (module_list[i] == mout_map[j].id) {
  436. /* find next module which can be connected */
  437. step = i + 1;
  438. while (module_can_connect[module_list[step]].bit == 0
  439. && step < module_num) {
  440. step++;
  441. }
  442. ASSERT(step < module_num);
  443. mout = mout_map[j].reg_val;
  444. for (k = 0; k < 5; k++) {
  445. if (mout_map[j].out_id_bit_map[k].m == -1)
  446. break;
  447. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  448. mout |= mout_map[j].out_id_bit_map[k].v;
  449. reg_mout |= mout;
  450. mout_idx = j;
  451. DDPDBG("connect mout %s to %s bits 0x%x\n",
  452. ddp_get_module_name(module_list[i]),
  453. ddp_get_module_name(module_list[step]),
  454. reg_mout);
  455. break;
  456. }
  457. }
  458. mout_map[j].reg_val = mout;
  459. mout = 0;
  460. }
  461. }
  462. if (reg_mout) {
  463. DISP_REG_SET(handle, mout_map[mout_idx].reg, reg_mout);
  464. reg_mout = 0;
  465. mout_idx = 0;
  466. }
  467. }
  468. /* connect out select */
  469. for (i = 0; i < module_num - 1; i++) {
  470. for (j = 0; j < DDP_SEL_OUT_NUM; j++) {
  471. if (module_list[i] == sel_out_map[j].id) {
  472. step = i + 1;
  473. /* find next module which can be connected */
  474. while (module_can_connect[module_list[step]].bit == 0
  475. && step < module_num) {
  476. step++;
  477. }
  478. ASSERT(step < module_num);
  479. for (k = 0; k < 4; k++) {
  480. if (sel_out_map[j].id_bit_map[k] == -1)
  481. break;
  482. if (sel_out_map[j].id_bit_map[k] == module_list[step]) {
  483. DDPDBG("connect out_s %s to %s, value=%d\n",
  484. ddp_get_module_name(module_list[i]),
  485. ddp_get_module_name(module_list[step]), k);
  486. DISP_REG_SET(handle, sel_out_map[j].reg,
  487. (uint16_t) k);
  488. break;
  489. }
  490. }
  491. }
  492. }
  493. }
  494. /* connect input select */
  495. for (i = 1; i < module_num; i++) {
  496. for (j = 0; j < DDP_SEL_IN_NUM; j++) {
  497. if (module_list[i] == sel_in_map[j].id) {
  498. int found = 0;
  499. step = i - 1;
  500. /* find next module which can be connected */
  501. while (module_can_connect[module_list[step]].bit == 0 && step > 0)
  502. step--;
  503. ASSERT(step >= 0);
  504. for (k = 0; k < 4; k++) {
  505. if (sel_in_map[j].id_bit_map[k] == -1)
  506. break;
  507. if (sel_in_map[j].id_bit_map[k] == module_list[step]) {
  508. DDPDBG("connect in_s %s to %s, value=%d\n",
  509. ddp_get_module_name(module_list[step]),
  510. ddp_get_module_name(module_list[i]), k);
  511. DISP_REG_SET(handle, sel_in_map[j].reg,
  512. (uint16_t) k);
  513. found = 1;
  514. break;
  515. }
  516. }
  517. if (!found)
  518. DDPERR("%s error: %s sel_in not set\n", __func__,
  519. ddp_get_module_name(module_list[i]));
  520. }
  521. }
  522. }
  523. }
  524. static void ddp_check_path_l(int *module_list)
  525. {
  526. unsigned int i, j, k;
  527. int step = 0;
  528. int valid = 0;
  529. unsigned int mout;
  530. unsigned int path_error = 0;
  531. unsigned int module_num = ddp_get_module_num_l(module_list);
  532. DDPDUMP("check_path: %s to %s\n", ddp_get_module_name(module_list[0])
  533. , ddp_get_module_name(module_list[module_num - 1]));
  534. /* check mout */
  535. for (i = 0; i < module_num - 1; i++) {
  536. for (j = 0; j < DDP_MOUT_NUM; j++) {
  537. if (module_list[i] == mout_map[j].id) {
  538. mout = 0;
  539. /* find next module which can be connected */
  540. step = i + 1;
  541. while (module_can_connect[module_list[step]].bit == 0
  542. && step < module_num) {
  543. step++;
  544. }
  545. ASSERT(step < module_num);
  546. for (k = 0; k < 5; k++) {
  547. if (mout_map[j].out_id_bit_map[k].m == -1)
  548. break;
  549. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  550. mout |= mout_map[j].out_id_bit_map[k].v;
  551. valid = 1;
  552. break;
  553. }
  554. }
  555. if (valid) {
  556. valid = 0;
  557. if ((DISP_REG_GET(mout_map[j].reg) & mout) == 0) {
  558. path_error += 1;
  559. DDPDUMP("error:%s mout, expect=0x%x, real=0x%x\n",
  560. ddp_get_module_name(module_list[i]),
  561. mout, DISP_REG_GET(mout_map[j].reg));
  562. } else if (DISP_REG_GET(mout_map[j].reg) != mout) {
  563. DDPDUMP
  564. ("warning: %s mout expect=0x%x, real=0x%x\n",
  565. ddp_get_module_name(module_list[i]), mout,
  566. DISP_REG_GET(mout_map[j].reg));
  567. }
  568. }
  569. break;
  570. }
  571. }
  572. }
  573. /* check out select */
  574. for (i = 0; i < module_num - 1; i++) {
  575. for (j = 0; j < DDP_SEL_OUT_NUM; j++) {
  576. if (module_list[i] != sel_out_map[j].id)
  577. continue;
  578. /* find next module which can be connected */
  579. step = i + 1;
  580. while (module_can_connect[module_list[step]].bit == 0
  581. && step < module_num) {
  582. step++;
  583. }
  584. ASSERT(step < module_num);
  585. for (k = 0; k < 4; k++) {
  586. if (sel_out_map[j].id_bit_map[k] == -1)
  587. break;
  588. if (sel_out_map[j].id_bit_map[k] == module_list[step]) {
  589. if (DISP_REG_GET(sel_out_map[j].reg) != k) {
  590. path_error += 1;
  591. DDPDUMP
  592. ("error:out_s %s not connect to %s, expect=0x%x, real=0x%x\n",
  593. ddp_get_module_name(module_list[i]),
  594. ddp_get_module_name(module_list[step]),
  595. k, DISP_REG_GET(sel_out_map[j].reg));
  596. }
  597. break;
  598. }
  599. }
  600. }
  601. }
  602. /* check input select */
  603. for (i = 1; i < module_num; i++) {
  604. for (j = 0; j < DDP_SEL_IN_NUM; j++) {
  605. if (module_list[i] != sel_in_map[j].id)
  606. continue;
  607. /* find next module which can be connected */
  608. step = i - 1;
  609. while (module_can_connect[module_list[step]].bit == 0 && step > 0)
  610. step--;
  611. ASSERT(step >= 0);
  612. for (k = 0; k < 4; k++) {
  613. if (sel_in_map[j].id_bit_map[k] == -1)
  614. break;
  615. if (sel_in_map[j].id_bit_map[k] == module_list[step]) {
  616. if (DISP_REG_GET(sel_in_map[j].reg) != k) {
  617. path_error += 1;
  618. DDPDUMP("error:in_s %s not conn to %s,expect0x%x,real0x%x\n",
  619. ddp_get_module_name(module_list[step]),
  620. ddp_get_module_name(module_list[i]), k,
  621. DISP_REG_GET(sel_in_map[j].reg));
  622. }
  623. break;
  624. }
  625. }
  626. }
  627. }
  628. if (path_error == 0) {
  629. DDPDUMP("path: %s to %s is connected\n", ddp_get_module_name(module_list[0]),
  630. ddp_get_module_name(module_list[module_num - 1]));
  631. } else {
  632. DDPDUMP("path: %s to %s not connected!!!\n", ddp_get_module_name(module_list[0]),
  633. ddp_get_module_name(module_list[module_num - 1]));
  634. }
  635. }
  636. static void ddp_disconnect_path_l(int *module_list, void *handle)
  637. {
  638. unsigned int i, j, k;
  639. int step = 0;
  640. unsigned int mout = 0;
  641. unsigned int reg_mout = 0;
  642. unsigned int mout_idx = 0;
  643. unsigned int module_num = ddp_get_module_num_l(module_list);
  644. DDPDBG("disconnect_path: %s to %s\n", ddp_get_module_name(module_list[0]),
  645. ddp_get_module_name(module_list[module_num - 1]));
  646. for (i = 0; i < module_num - 1; i++) {
  647. for (j = 0; j < DDP_MOUT_NUM; j++) {
  648. if (module_list[i] == mout_map[j].id) {
  649. /* find next module which can be connected */
  650. step = i + 1;
  651. while (module_can_connect[module_list[step]].bit == 0
  652. && step < module_num) {
  653. step++;
  654. }
  655. ASSERT(step < module_num);
  656. for (k = 0; k < 5; k++) {
  657. if (mout_map[j].out_id_bit_map[k].m == -1)
  658. break;
  659. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  660. mout |= mout_map[j].out_id_bit_map[k].v;
  661. reg_mout |= mout;
  662. mout_idx = j;
  663. DDPDBG("disconnect mout %s to %s\n",
  664. ddp_get_module_name(module_list[i]),
  665. ddp_get_module_name(module_list[step]));
  666. break;
  667. }
  668. }
  669. /* update mout_value */
  670. mout_map[j].reg_val &= ~mout;
  671. mout = 0;
  672. }
  673. }
  674. if (reg_mout) {
  675. DISP_REG_SET(handle, mout_map[mout_idx].reg, mout_map[mout_idx].reg_val);
  676. reg_mout = 0;
  677. mout_idx = 0;
  678. }
  679. }
  680. }
  681. static int ddp_get_mutex_src(DISP_MODULE_ENUM dest_module, DDP_MODE ddp_mode,
  682. unsigned int *SOF_src, unsigned int *EOF_src)
  683. {
  684. unsigned int src_from_dst_module = 0;
  685. if (dest_module == DISP_MODULE_WDMA0 || dest_module == DISP_MODULE_WDMA1) {
  686. if (ddp_mode == DDP_VIDEO_MODE)
  687. DISP_LOG_W("%s: dst_mode=%s, but is video mode !!\n", __func__,
  688. ddp_get_module_name(dest_module));
  689. *SOF_src = *EOF_src = SOF_VAL_MUTEX0_SOF_SINGLE_MODE;
  690. return 0;
  691. }
  692. if (dest_module == DISP_MODULE_DSI0 || dest_module == DISP_MODULE_DSIDUAL) {
  693. src_from_dst_module = SOF_VAL_MUTEX0_SOF_FROM_DSI0;
  694. } else if (dest_module == DISP_MODULE_DPI) {
  695. src_from_dst_module = SOF_VAL_MUTEX0_SOF_FROM_DPI;
  696. } else {
  697. DDPERR("get mutex sof, invalid param dst module = %s(%d), dis mode %s\n",
  698. ddp_get_module_name(dest_module), dest_module, ddp_get_mode_name(ddp_mode));
  699. ASSERT(0);
  700. }
  701. if (ddp_mode == DDP_CMD_MODE) {
  702. *SOF_src = SOF_VAL_MUTEX0_SOF_SINGLE_MODE;
  703. if (0/*disp_helper_get_option(DISP_OPT_MUTEX_EOF_EN_FOR_CMD_MODE)*/)
  704. *EOF_src = src_from_dst_module;
  705. else
  706. *EOF_src = SOF_VAL_MUTEX0_EOF_SINGLE_MODE;
  707. } else {
  708. *SOF_src = *EOF_src = src_from_dst_module;
  709. }
  710. return 0;
  711. }
  712. /* id: mutex ID, 0~5 */
  713. static int ddp_mutex_set_l(int mutex_id, int *module_list, DDP_MODE ddp_mode, void *handle)
  714. {
  715. int i = 0;
  716. unsigned int value0 = 0;
  717. unsigned int value1 = 0;
  718. unsigned int sof_val;
  719. unsigned int sof_src, eof_src;
  720. int module_num = ddp_get_module_num_l(module_list);
  721. ddp_get_mutex_src(module_list[module_num - 1], ddp_mode, &sof_src, &eof_src);
  722. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  723. DDPERR("exceed mutex max (0 ~ %d)\n", DISP_MUTEX_DDP_LAST);
  724. return -1;
  725. }
  726. for (i = 0; i < module_num; i++) {
  727. if (module_mutex_map[module_list[i]].bit != -1) {
  728. DDPDBG("module %s added to mutex %d\n", ddp_get_module_name(module_list[i]),
  729. mutex_id);
  730. if (module_mutex_map[module_list[i]].mod_num == 0) {
  731. value0 |= (1 << module_mutex_map[module_list[i]].bit);
  732. } else if (module_mutex_map[module_list[i]].mod_num == 1) {
  733. /* DISP_MODULE_DSIDUAL is special */
  734. if (DISP_MODULE_DSIDUAL == module_mutex_map[module_list[i]].module) {
  735. value1 |= (1 << module_mutex_map[DISP_MODULE_DSI0].bit); /* DISP MODULE enum must start from 0 */
  736. value1 |= (1 << module_mutex_map[DISP_MODULE_DSI1].bit);
  737. } else {
  738. value1 |= (1 << module_mutex_map[module_list[i]].bit);
  739. }
  740. }
  741. } else {
  742. DDPDBG("module %s not added to mutex %d\n",
  743. ddp_get_module_name(module_list[i]), mutex_id);
  744. }
  745. }
  746. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_MOD0(mutex_id), value0);
  747. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_MOD1(mutex_id), value1);
  748. sof_val = REG_FLD_VAL(SOF_FLD_MUTEX0_SOF, sof_src);
  749. sof_val |= REG_FLD_VAL(SOF_FLD_MUTEX0_EOF, eof_src);
  750. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_SOF(mutex_id), sof_val);
  751. DDPDBG("mutex %d value=0x%x, sof=%s, eof=%s\n", mutex_id,
  752. value0, ddp_get_mutex_sof_name(sof_src), ddp_get_mutex_sof_name(eof_src));
  753. return 0;
  754. }
  755. static void ddp_check_mutex_l(int mutex_id, int *module_list, DDP_MODE ddp_mode)
  756. {
  757. int i = 0;
  758. uint32_t real_value0 = 0;
  759. uint32_t real_value1 = 0;
  760. uint32_t expect_value0 = 0;
  761. uint32_t expect_value1 = 0;
  762. unsigned int real_sof, real_eof, val;
  763. unsigned int expect_sof, expect_eof;
  764. int module_num = ddp_get_module_num_l(module_list);
  765. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  766. DDPDUMP("error:check mutex fail:exceed mutex max (0 ~ %d)\n", DISP_MUTEX_DDP_LAST);
  767. return;
  768. }
  769. real_value0 = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_MOD0(mutex_id));
  770. real_value1 = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_MOD1(mutex_id));
  771. for (i = 0; i < module_num; i++) {
  772. if (module_mutex_map[module_list[i]].bit != -1) {
  773. if (module_mutex_map[module_list[i]].mod_num == 0) {
  774. expect_value0 |= (1 << module_mutex_map[module_list[i]].bit);
  775. } else if (module_mutex_map[module_list[i]].mod_num == 1) {
  776. if (DISP_MODULE_DSIDUAL == module_mutex_map[module_list[i]].module) {
  777. expect_value1 |= (1 << module_mutex_map[DISP_MODULE_DSI0].bit); /* DISP MODULE enum must start from 0 */
  778. expect_value1 |= (1 << module_mutex_map[DISP_MODULE_DSI1].bit);
  779. } else {
  780. expect_value1 |= (1 << module_mutex_map[module_list[i]].bit);
  781. }
  782. }
  783. }
  784. }
  785. if (expect_value0 != real_value0)
  786. DDPDUMP("error:mutex %d error: expect0 0x%x, real0 0x%x\n", mutex_id, expect_value0,
  787. real_value0);
  788. if (expect_value1 != real_value1)
  789. DDPDUMP("error:mutex %d error: expect1 0x%x, real1 0x%x\n", mutex_id, expect_value1,
  790. real_value1);
  791. val = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_SOF(mutex_id));
  792. real_sof = REG_FLD_VAL_GET(SOF_FLD_MUTEX0_SOF, val);
  793. real_eof = REG_FLD_VAL_GET(SOF_FLD_MUTEX0_EOF, val);
  794. ddp_get_mutex_src(module_list[module_num - 1], ddp_mode, &expect_sof, &expect_eof);
  795. if (expect_sof != real_sof)
  796. DDPDUMP("error:mutex %d sof error: expect %s, real %s\n", mutex_id,
  797. ddp_get_mutex_sof_name(expect_sof), ddp_get_mutex_sof_name(real_sof));
  798. if (expect_eof != real_eof)
  799. DDPDUMP("error:mutex %d eof error: expect %s, real %s\n", mutex_id,
  800. ddp_get_mutex_sof_name(expect_eof), ddp_get_mutex_sof_name(real_eof));
  801. }
  802. static int ddp_mutex_enable_l(int mutex_idx, void *handle)
  803. {
  804. DDPDBG("mutex %d enable\n", mutex_idx);
  805. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_EN(mutex_idx), 1);
  806. return 0;
  807. }
  808. int ddp_get_module_num(DDP_SCENARIO_ENUM scenario)
  809. {
  810. return ddp_get_module_num_l(module_list_scenario[scenario]);
  811. }
  812. static void ddp_print_scenario(DDP_SCENARIO_ENUM scenario)
  813. {
  814. int i =0;
  815. char path[512]= {'\0'};
  816. int num = ddp_get_module_num(scenario);
  817. for (i = 0; i < num; i++)
  818. strncat(path, ddp_get_module_name(module_list_scenario[scenario][i]), sizeof(path));
  819. DDPMSG("scenario %s have modules: %s\n",ddp_get_scenario_name(scenario),path);
  820. }
  821. static int ddp_find_module_index(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM module)
  822. {
  823. int i = 0;
  824. for (i = 0; i < DDP_ENING_NUM; i++) {
  825. if (module_list_scenario[ddp_scenario][i] == module)
  826. return i;
  827. }
  828. DDPDBG("find module: can not find module %s on scenario %s\n", ddp_get_module_name(module),
  829. ddp_get_scenario_name(ddp_scenario));
  830. return -1;
  831. }
  832. /* set display interface when kernel init */
  833. int ddp_set_dst_module(DDP_SCENARIO_ENUM scenario, DISP_MODULE_ENUM dst_module)
  834. {
  835. int i = 0;
  836. DDPMSG("ddp_set_dst_module, scenario=%s, dst_module=%s\n",
  837. ddp_get_scenario_name(scenario), ddp_get_module_name(dst_module));
  838. if (ddp_find_module_index(scenario, dst_module) > 0) {
  839. DDPDBG("%s is already on path\n", ddp_get_module_name(dst_module));
  840. return 0;
  841. }
  842. i = ddp_get_module_num_l(module_list_scenario[scenario]) - 1;
  843. ASSERT(i >= 0);
  844. if (dst_module == DISP_MODULE_DSIDUAL) {
  845. if (i < (DDP_ENING_NUM - 1)) {
  846. module_list_scenario[scenario][i++] = DISP_MODULE_SPLIT0;
  847. } else {
  848. DDPERR("set dst module over up bound\n");
  849. return -1;
  850. }
  851. } else {
  852. if (ddp_get_dst_module(scenario) == DISP_MODULE_DSIDUAL) {
  853. if (i >= 1) {
  854. module_list_scenario[scenario][i--] = -1;
  855. } else {
  856. DDPERR("set dst module over low bound\n");
  857. return -1;
  858. }
  859. }
  860. }
  861. module_list_scenario[scenario][i] = dst_module;
  862. if (scenario == DDP_SCENARIO_PRIMARY_ALL)
  863. ddp_set_dst_module(DDP_SCENARIO_PRIMARY_DISP, dst_module);
  864. else if (scenario == DDP_SCENARIO_SUB_ALL)
  865. ddp_set_dst_module(DDP_SCENARIO_SUB_RDMA1_DISP, dst_module);
  866. else if (scenario == DDP_SCENARIO_DITHER_1TO2)
  867. ddp_set_dst_module(DDP_SCENARIO_PRIMARY_DISP, dst_module);
  868. else if (scenario == DDP_SCENARIO_UFOE_1TO2)
  869. ddp_set_dst_module(DDP_SCENARIO_PRIMARY_DISP, dst_module);
  870. ddp_print_scenario(scenario);
  871. return 0;
  872. }
  873. DISP_MODULE_ENUM ddp_get_dst_module(DDP_SCENARIO_ENUM ddp_scenario)
  874. {
  875. DISP_MODULE_ENUM module_name = DISP_MODULE_UNKNOWN;
  876. int module_num = ddp_get_module_num_l(module_list_scenario[ddp_scenario]) - 1;
  877. if (module_num >= 0)
  878. module_name = module_list_scenario[ddp_scenario][module_num];
  879. return module_name;
  880. }
  881. int *ddp_get_scenario_list(DDP_SCENARIO_ENUM ddp_scenario)
  882. {
  883. return module_list_scenario[ddp_scenario];
  884. }
  885. int ddp_is_module_in_scenario(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM module)
  886. {
  887. int i = 0;
  888. for (i = 0; i < DDP_ENING_NUM; i++) {
  889. if (module_list_scenario[ddp_scenario][i] == module)
  890. return 1;
  891. }
  892. return 0;
  893. }
  894. int ddp_insert_module(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM place,
  895. DISP_MODULE_ENUM module)
  896. {
  897. int i = DDP_ENING_NUM - 1;
  898. int idx = ddp_find_module_index(ddp_scenario, place);
  899. if (idx < 0) {
  900. DDPERR("error: ddp_insert_module , place=%s is not in scenario %s!\n",
  901. ddp_get_module_name(place), ddp_get_scenario_name(ddp_scenario));
  902. return -1;
  903. }
  904. for (i = 0; i < DDP_ENING_NUM; i++) {
  905. if (module_list_scenario[ddp_scenario][i] == module) {
  906. DDPERR("error: ddp_insert_module , module=%s is already in scenario %s!\n",
  907. ddp_get_module_name(module), ddp_get_scenario_name(ddp_scenario));
  908. return -1;
  909. }
  910. }
  911. /* should have empty room for insert */
  912. ASSERT(module_list_scenario[ddp_scenario][DDP_ENING_NUM - 1] == -1);
  913. for (i = DDP_ENING_NUM - 2; i >= idx; i--)
  914. module_list_scenario[ddp_scenario][i + 1] = module_list_scenario[ddp_scenario][i];
  915. module_list_scenario[ddp_scenario][idx] = module;
  916. {
  917. int *modules = ddp_get_scenario_list(ddp_scenario);
  918. int module_num = ddp_get_module_num(ddp_scenario);
  919. DDPMSG("after insert module, module list is:\n");
  920. for (i = 0; i < module_num; i++)
  921. DDPMSG("%s-", ddp_get_module_name(modules[i]));
  922. }
  923. return 0;
  924. }
  925. int ddp_remove_module(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM module)
  926. {
  927. int i = 0;
  928. int idx = ddp_find_module_index(ddp_scenario, module);
  929. if (idx < 0) {
  930. DDPERR("ddp_remove_module, can not find module %s in scenario %s\n",
  931. ddp_get_module_name(module), ddp_get_scenario_name(ddp_scenario));
  932. return -1;
  933. }
  934. for (i = idx; i < DDP_ENING_NUM - 1; i++)
  935. module_list_scenario[ddp_scenario][i] = module_list_scenario[ddp_scenario][i + 1];
  936. module_list_scenario[ddp_scenario][DDP_ENING_NUM - 1] = -1;
  937. {
  938. int *modules = ddp_get_scenario_list(ddp_scenario);
  939. int module_num = ddp_get_module_num(ddp_scenario);
  940. DDPMSG("after remove module, module list is:\n");
  941. for (i = 0; i < module_num; i++)
  942. DDPMSG("%s-", ddp_get_module_name(modules[i]));
  943. }
  944. return 0;
  945. }
  946. void ddp_connect_path(DDP_SCENARIO_ENUM scenario, void *handle)
  947. {
  948. DDPDBG("path connect on scenario %s\n", ddp_get_scenario_name(scenario));
  949. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  950. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  951. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT], handle);
  952. } else if (scenario == DDP_SCENARIO_SUB_ALL) {
  953. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_SUB_DISP], handle);
  954. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_SUB_OVL_MEMOUT], handle);
  955. } else if (scenario == DDP_SCENARIO_DITHER_1TO2) {
  956. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  957. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DITHER_MEMOUT], handle);
  958. } else if (scenario == DDP_SCENARIO_UFOE_1TO2) {
  959. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  960. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_UFOE_MEMOUT], handle);
  961. } else {
  962. ddp_connect_path_l(module_list_scenario[scenario], handle);
  963. }
  964. return;
  965. }
  966. void ddp_disconnect_path(DDP_SCENARIO_ENUM scenario, void *handle)
  967. {
  968. DDPDBG("path disconnect on scenario %s\n", ddp_get_scenario_name(scenario));
  969. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  970. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  971. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT],
  972. handle);
  973. } else if (scenario == DDP_SCENARIO_SUB_ALL) {
  974. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_SUB_DISP], handle);
  975. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_SUB_OVL_MEMOUT], handle);
  976. } else if (scenario == DDP_SCENARIO_DITHER_1TO2) {
  977. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  978. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DITHER_MEMOUT], handle);
  979. } else if (scenario == DDP_SCENARIO_UFOE_1TO2) {
  980. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  981. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_UFOE_MEMOUT], handle);
  982. } else {
  983. ddp_disconnect_path_l(module_list_scenario[scenario], handle);
  984. }
  985. return;
  986. }
  987. void ddp_check_path(DDP_SCENARIO_ENUM scenario)
  988. {
  989. DDPDBG("path check path on scenario %s\n", ddp_get_scenario_name(scenario));
  990. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  991. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP]);
  992. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT]);
  993. } else if (scenario == DDP_SCENARIO_SUB_ALL) {
  994. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_SUB_DISP]);
  995. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_SUB_OVL_MEMOUT]);
  996. } else if (scenario == DDP_SCENARIO_DITHER_1TO2) {
  997. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP]);
  998. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DITHER_MEMOUT]);
  999. } else if (scenario == DDP_SCENARIO_UFOE_1TO2) {
  1000. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP]);
  1001. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_UFOE_MEMOUT]);
  1002. } else {
  1003. ddp_check_path_l(module_list_scenario[scenario]);
  1004. }
  1005. return;
  1006. }
  1007. void ddp_check_mutex(int mutex_id, DDP_SCENARIO_ENUM scenario, DDP_MODE mode)
  1008. {
  1009. DDPDBG("check mutex %d on scenario %s\n", mutex_id, ddp_get_scenario_name(scenario));
  1010. ddp_check_mutex_l(mutex_id, module_list_scenario[scenario], mode);
  1011. return;
  1012. }
  1013. int ddp_mutex_set(int mutex_id, DDP_SCENARIO_ENUM scenario, DDP_MODE mode, void *handle)
  1014. {
  1015. if (scenario < DDP_SCENARIO_MAX) {
  1016. return ddp_mutex_set_l(mutex_id, module_list_scenario[scenario], mode, handle);
  1017. } else {
  1018. DDPERR("Invalid scenario %d when setting mutex\n", scenario);
  1019. return -1;
  1020. }
  1021. return 0;
  1022. }
  1023. int ddp_mutex_Interrupt_enable(int mutex_id, void *handle)
  1024. {
  1025. DDPDBG("mutex %d interrupt enable\n", mutex_id);
  1026. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_INTEN, 0x1 << mutex_id, 0x1 << mutex_id);
  1027. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_INTEN, 1 << (mutex_id + DISP_MUTEX_TOTAL),
  1028. 0x1 << (mutex_id + DISP_MUTEX_TOTAL));
  1029. return 0;
  1030. }
  1031. int ddp_mutex_Interrupt_disable(int mutex_id, void *handle)
  1032. {
  1033. DDPDBG("mutex %d interrupt disenable\n", mutex_id);
  1034. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_INTEN, 0, 0x1 << mutex_id);
  1035. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_INTEN, 0, 0x1 << (mutex_id + DISP_MUTEX_TOTAL));
  1036. return 0;
  1037. }
  1038. int ddp_mutex_reset(int mutex_id, void *handle)
  1039. {
  1040. DDPDBG("mutex %d reset\n", mutex_id);
  1041. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_RST(mutex_id), 1);
  1042. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_RST(mutex_id), 0);
  1043. return 0;
  1044. }
  1045. int ddp_is_moudule_in_mutex(int mutex_id, DISP_MODULE_ENUM module)
  1046. {
  1047. int ret = 0;
  1048. uint32_t real_value = 0;
  1049. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  1050. DDPDUMP("error:check_moudule_in_mute fail:exceed mutex max (0 ~ %d)\n",
  1051. DISP_MUTEX_DDP_LAST);
  1052. return ret;
  1053. }
  1054. if (module_mutex_map[module].mod_num == 0) {
  1055. real_value = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_MOD0(mutex_id));
  1056. } else if (module_mutex_map[module].mod_num == 1) {
  1057. real_value = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_MOD1(mutex_id));
  1058. }
  1059. if (1 == ((real_value >> module_mutex_map[module].bit) & 0x01))
  1060. ret = 1;
  1061. return ret;
  1062. }
  1063. int ddp_mutex_add_module(int mutex_id, DISP_MODULE_ENUM module, void *handle)
  1064. {
  1065. int value = 0;
  1066. if (module < DISP_MODULE_UNKNOWN) {
  1067. if (module_mutex_map[module].bit != -1) {
  1068. DDPDBG("module %s added to mutex %d\n", ddp_get_module_name(module),
  1069. mutex_id);
  1070. value |= (1 << module_mutex_map[module].bit);
  1071. if (module_mutex_map[module].mod_num == 0) {
  1072. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_MOD0(mutex_id), value, value);
  1073. } else if (module_mutex_map[module].mod_num == 1) {
  1074. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_MOD1(mutex_id), value, value);
  1075. }
  1076. }
  1077. }
  1078. return 0;
  1079. }
  1080. int ddp_mutex_remove_module(int mutex_id, DISP_MODULE_ENUM module, void *handle)
  1081. {
  1082. int value = 0;
  1083. if (module < DISP_MODULE_UNKNOWN) {
  1084. if (module_mutex_map[module].bit != -1) {
  1085. DDPDBG("module %s added to mutex %d\n", ddp_get_module_name(module),
  1086. mutex_id);
  1087. value |= (1 << module_mutex_map[module].bit);
  1088. if (module_mutex_map[module].mod_num == 0) {
  1089. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_MOD0(mutex_id), 0, value);
  1090. } else if (module_mutex_map[module].mod_num == 1) {
  1091. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_MOD1(mutex_id), 0, value);
  1092. }
  1093. }
  1094. }
  1095. return 0;
  1096. }
  1097. int ddp_mutex_clear(int mutex_id, void *handle)
  1098. {
  1099. DDPDBG("mutex %d clear\n", mutex_id);
  1100. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_MOD0(mutex_id), 0);
  1101. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_MOD1(mutex_id), 0);
  1102. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_SOF(mutex_id), 0);
  1103. /* enough or not */
  1104. /*reset mutex */
  1105. ddp_mutex_reset(mutex_id, handle);
  1106. return 0;
  1107. }
  1108. int ddp_mutex_enable(int mutex_id, DDP_SCENARIO_ENUM scenario, void *handle)
  1109. {
  1110. return ddp_mutex_enable_l(mutex_id, handle);
  1111. }
  1112. int ddp_mutex_disable(int mutex_id, DDP_SCENARIO_ENUM scenario, void *handle)
  1113. {
  1114. DDPDBG("mutex %d disable\n", mutex_id);
  1115. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_EN(mutex_id), 0);
  1116. return 0;
  1117. }
  1118. int ddp_mutex_get(int mutex_id, DDP_SCENARIO_ENUM scenario, void *handle)
  1119. {
  1120. DDPDBG("mutex %d get\n", mutex_id);
  1121. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_GET(mutex_id), 1);
  1122. return 0;
  1123. }
  1124. int ddp_mutex_release(int mutex_id, DDP_SCENARIO_ENUM scenario, void *handle)
  1125. {
  1126. DDPDBG("mutex %d release\n", mutex_id);
  1127. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_GET(mutex_id), 0);
  1128. return 0;
  1129. }
  1130. int ddp_mutex_set_sof_wait(int mutex_id, cmdqRecHandle handle, int wait)
  1131. {
  1132. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  1133. DDPERR("exceed mutex max (0 ~ %d)\n", DISP_MUTEX_DDP_LAST);
  1134. return -1;
  1135. }
  1136. DISP_REG_SET_FIELD(handle, SOF_FLD_MUTEX0_SOF_WAIT, DISP_REG_CONFIG_MUTEX_SOF(mutex_id), wait);
  1137. return 0;
  1138. }
  1139. int ddp_check_engine_status(int mutexID)
  1140. {
  1141. /* check engines' clock bit & enable bit & status bit before unlock mutex */
  1142. /* should not needed, in comdq do? */
  1143. int result = 0;
  1144. return result;
  1145. }
  1146. int ddp_path_top_clock_on(void)
  1147. {
  1148. DDPMSG("ddp path top clock on\n");
  1149. ddp_enable_module_clock(DISP_MODULE_SMI_COMMON);
  1150. ddp_enable_module_clock(DISP_MODULE_SMI_LARB0);
  1151. ddp_enable_module_clock(DISP_MODULE_SMI_LARB4);
  1152. ddp_enable_module_clock(DISP_MODULE_MUTEX);
  1153. DDPMSG("ddp CG:%x\n", DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0));
  1154. return 0;
  1155. }
  1156. int ddp_path_top_clock_off(void)
  1157. {
  1158. DDPMSG("ddp path top clock off\n");
  1159. ddp_disable_module_clock(DISP_MODULE_MUTEX);
  1160. ddp_disable_module_clock(DISP_MODULE_SMI_LARB4);
  1161. ddp_disable_module_clock(DISP_MODULE_SMI_LARB0);
  1162. ddp_disable_module_clock(DISP_MODULE_SMI_COMMON);
  1163. return 0;
  1164. }
  1165. int ddp_path_m4u_off(void)
  1166. {
  1167. int i;
  1168. DDPMSG("ddp path m4u off\n");
  1169. #ifdef MTKFB_NO_M4U
  1170. /* display ports bypass m4u.
  1171. ==== FBI WARNING: ==========
  1172. This function is hard code of m4u port setting !!!
  1173. Please ask M4U owner about it for new chip porting !!!
  1174. */
  1175. /*
  1176. M4U_PORT_DISP_OVL0,
  1177. M4U_PORT_DISP_2L_OVL0_LARB0,
  1178. M4U_PORT_DISP_RDMA0,
  1179. */
  1180. for (i=0; i<2; i++)
  1181. DISP_REG_SET_FIELD(0, REG_FLD_MMU_EN, DISP_REG_SMI_LARB0_MMU_EN + i*4, 0);
  1182. /*
  1183. M4U_PORT_DISP_OVL1,
  1184. M4U_PORT_DISP_2L_OVL1,
  1185. */
  1186. for (i=0; i<1; i++)
  1187. DISP_REG_SET_FIELD(0, REG_FLD_MMU_EN, DISP_REG_SMI_LARB4_MMU_EN + i*4, 0);
  1188. /*
  1189. M4U_PORT_DISP_2L_OVL0_LARB4,
  1190. */
  1191. DISP_REG_SET_FIELD(0, REG_FLD_MMU_EN, DISP_REG_SMI_LARB4_MMU_EN + 7*4, 0);
  1192. #endif
  1193. return 0;
  1194. }