ddp_path.c 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  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. * The following software/firmware and/or related documentation ("MediaTek Software")
  32. * have been modified by MediaTek Inc. All revisions are subject to any receiver\'s
  33. * applicable license agreements with MediaTek Inc.
  34. */
  35. #define LOG_TAG "ddp_path"
  36. #include <string.h>
  37. #include "platform/mt_irq.h"
  38. #include "platform/mt_irq.h"
  39. #include "platform/disp_drv_platform.h"
  40. #include "platform/ddp_reg.h"
  41. #include "platform/ddp_path.h"
  42. #include "platform/ddp_info.h"
  43. #include "platform/ddp_log.h"
  44. #if defined(MACH_TYPE_MT6735)
  45. static int module_list_scenario[DDP_SCENARIO_MAX][DDP_ENING_NUM] = {
  46. /*PRIMARY_DISP */ {
  47. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR, DISP_MODULE_AAL,
  48. DISP_MODULE_GAMMA, DISP_MODULE_DITHER, DISP_MODULE_RDMA0,
  49. DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1
  50. },
  51. /*PRIMARY_RDMA0_COLOR0_DISP */ {
  52. DISP_MODULE_RDMA0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  53. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  54. DISP_MODULE_UFOE, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1,
  55. -1, -1
  56. },
  57. /*PRIMARY_RDMA0_DISP */ {
  58. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1,
  59. -1, -1, -1, -1, -1, -1
  60. },
  61. /*PRIMARY_BYPASS_RDMA */ {
  62. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  63. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  64. DISP_MODULE_UFOE, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1
  65. },
  66. /*PRIMARY_OVL_MEMOUT */ {
  67. DISP_MODULE_OVL0, DISP_MODULE_WDMA0, -1, -1, -1, -1, -1, -1, -1,
  68. -1, -1, -1
  69. },
  70. /*PRIMARY_DITHER_MEMOUT */ {
  71. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  72. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  73. DISP_MODULE_WDMA0, -1, -1, -1, -1, -1
  74. },
  75. /*PRIMARY_UFOE_MEMOUT */ {
  76. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  77. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  78. DISP_MODULE_RDMA0, DISP_MODULE_UFOE, DISP_MODULE_WDMA0, -1, -1,
  79. -1
  80. },
  81. /*SUB_DISP */ {
  82. DISP_MODULE_OVL1, DISP_MODULE_RDMA1, DISP_MODULE_DPI, -1, -1, -1, -1, -1, -1,
  83. -1, -1, -1
  84. },
  85. /*SUB_RDMA1_DISP */ {
  86. DISP_MODULE_RDMA1, DISP_MODULE_DSI0, -1, -1, -1, -1, -1, -1, -1, -1,
  87. -1, -1
  88. },
  89. /*SUB_RDMA2_DISP */ {
  90. DISP_MODULE_RDMA1, DISP_MODULE_DSI0, -1, -1, -1, -1, -1, -1, -1, -1,
  91. -1, -1
  92. },
  93. /*SUB_OVL_MEMOUT */ {
  94. DISP_MODULE_OVL1, DISP_MODULE_WDMA1, -1, -1, -1, -1, -1, -1, -1 - 1,
  95. -1, -1
  96. },
  97. /*SUB_GAMMA_MEMOUT */ {
  98. DISP_MODULE_OVL1, DISP_MODULE_WDMA1, -1, -1, -1, -1, -1, -1, -1 - 1,
  99. -1, -1
  100. },
  101. /*DISPLAY_INTERFACE */ {
  102. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  103. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  104. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1
  105. },
  106. /*PRIMARY_RDMA0_DUAL_DISP */ {
  107. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1,
  108. -1, -1, -1, -1, -1, -1, -1
  109. },
  110. /*PRIMARY_ALL */ {
  111. DISP_MODULE_OVL0, DISP_MODULE_WDMA0, DISP_MODULE_COLOR0,
  112. DISP_MODULE_CCORR, DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  113. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1
  114. },
  115. /*SUB_ALL */ {
  116. DISP_MODULE_OVL1, DISP_MODULE_WDMA1, DISP_MODULE_RDMA1, DISP_MODULE_DPI, -1,
  117. -1, -1, -1, -1, -1, -1, -1
  118. },
  119. /*MULTIPLE_OVL */ {
  120. DISP_MODULE_OVL1, DISP_MODULE_OVL0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  121. -1
  122. },
  123. };
  124. /* 1st para is mout's input, 2nd para is mout's output */
  125. static mout_t mout_map[DDP_MOUT_NUM] = {
  126. /* OVL_MOUT */
  127. {
  128. DISP_MODULE_OVL0, {{DISP_MODULE_COLOR0, 1 << 0}, {DISP_MODULE_WDMA0, 1 << 1}, {-1, 0} },
  129. DISP_REG_CONFIG_DISP_OVL0_MOUT_EN, 0
  130. },
  131. #if defined(MTKFB_OVL1_SUPPORT)
  132. {
  133. DISP_MODULE_OVL1,
  134. { {DISP_MODULE_RDMA1, 1 << 0}, {DISP_MODULE_WDMA1, 1 << 1}, {DISP_MODULE_OVL0, 1 << 2},
  135. {-1, 0}
  136. }, 0
  137. },
  138. #endif
  139. /* DITHER0_MOUT */
  140. {
  141. DISP_MODULE_DITHER,
  142. { {DISP_MODULE_RDMA0, 1 << 0}, {DISP_MODULE_UFOE, 1 << 1}, {DISP_MODULE_WDMA0, 1 << 2},
  143. {-1, 0}
  144. }, DISP_REG_CONFIG_DISP_DITHER_MOUT_EN, 0
  145. },
  146. /* UFOE_MOUT */
  147. {
  148. DISP_MODULE_UFOE,
  149. { {DISP_MODULE_DSI0, 1 << 0}, {DISP_MODULE_DPI, 1 << 1}, {DISP_MODULE_WDMA0, 1 << 2},
  150. {-1, 0}
  151. }, DISP_REG_CONFIG_DISP_UFOE_MOUT_EN, 0
  152. },
  153. };
  154. static sel_t sel_out_map[DDP_SEL_OUT_NUM] = {
  155. /* RDMA_SOUT */
  156. {
  157. DISP_MODULE_RDMA0,
  158. {DISP_MODULE_UFOE, DISP_MODULE_COLOR0, DISP_MODULE_DSI0, DISP_MODULE_DPI, -1},
  159. DISP_REG_CONFIG_DISP_RDMA0_SOUT_SEL_IN, 0
  160. },
  161. {
  162. DISP_MODULE_RDMA1, {DISP_MODULE_DSI0, DISP_MODULE_DPI, -1},
  163. DISP_REG_CONFIG_DISP_RDMA1_SOUT_SEL_IN, 0
  164. },
  165. };
  166. /* 1st para is sout's output, 2nd para is sout's input */
  167. static sel_t sel_in_map[DDP_SEL_IN_NUM] = {
  168. /* COLOR_SEL */
  169. {
  170. DISP_MODULE_COLOR0, {DISP_MODULE_RDMA0, DISP_MODULE_OVL0, -1},
  171. DISP_REG_CONFIG_DISP_COLOR0_SEL_IN, 0
  172. },
  173. /* UFOE_SEL */
  174. {
  175. DISP_MODULE_UFOE, {DISP_MODULE_RDMA0, DISP_MODULE_DITHER, -1},
  176. DISP_REG_CONFIG_DISP_UFOE_SEL_IN, 0
  177. },
  178. /* DSI0_SEL */
  179. {
  180. DISP_MODULE_DSI0, {DISP_MODULE_UFOE, DISP_MODULE_RDMA0, DISP_MODULE_RDMA1, -1},
  181. DISP_REG_CONFIG_DSI0_SEL_IN, 0
  182. },
  183. /* DPI0_SEL */
  184. {
  185. DISP_MODULE_DPI, {DISP_MODULE_UFOE, DISP_MODULE_RDMA0, DISP_MODULE_RDMA1, -1},
  186. DISP_REG_CONFIG_DPI0_SEL_IN, 0
  187. },
  188. /* WDMA_SEL */
  189. {
  190. DISP_MODULE_WDMA0, {DISP_MODULE_OVL0, DISP_MODULE_DITHER, DISP_MODULE_UFOE, -1},
  191. DISP_REG_CONFIG_DISP_WDMA0_SEL_IN, 0
  192. },
  193. };
  194. /* module bit in mutex */
  195. static module_map_t module_mutex_map[DISP_MODULE_NUM] = {
  196. {DISP_MODULE_OVL0, 6},
  197. {DISP_MODULE_OVL1, -1},
  198. {DISP_MODULE_RDMA0, 7},
  199. {DISP_MODULE_RDMA1, 8},
  200. {DISP_MODULE_WDMA0, 9},
  201. {DISP_MODULE_COLOR0, 11},
  202. {DISP_MODULE_CCORR, 10},
  203. {DISP_MODULE_AAL, 12},
  204. {DISP_MODULE_GAMMA, 13},
  205. {DISP_MODULE_DITHER, 14},
  206. {DISP_MODULE_UFOE, -1},
  207. {DISP_MODULE_PWM0, 16},
  208. {DISP_MODULE_WDMA1, -1},
  209. {DISP_MODULE_DSI0, -1},
  210. {DISP_MODULE_DPI, -1},
  211. {DISP_MODULE_SMI, -1},
  212. {DISP_MODULE_CONFIG, -1},
  213. {DISP_MODULE_CMDQ, -1},
  214. {DISP_MODULE_MUTEX, -1},
  215. };
  216. /* module can be connect if 1 */
  217. static module_map_t module_can_connect[DISP_MODULE_NUM] = {
  218. {DISP_MODULE_OVL0, 1},
  219. {DISP_MODULE_OVL1, 0},
  220. {DISP_MODULE_RDMA0, 1},
  221. {DISP_MODULE_RDMA1, 1},
  222. {DISP_MODULE_WDMA0, 1},
  223. {DISP_MODULE_COLOR0, 1},
  224. {DISP_MODULE_CCORR, 1},
  225. {DISP_MODULE_AAL, 1},
  226. {DISP_MODULE_GAMMA, 1},
  227. {DISP_MODULE_DITHER, 1},
  228. {DISP_MODULE_UFOE, 1},
  229. {DISP_MODULE_PWM0, 0},
  230. {DISP_MODULE_WDMA1, 0},
  231. {DISP_MODULE_DSI0, 1},
  232. {DISP_MODULE_DPI, 1},
  233. {DISP_MODULE_SMI, 0},
  234. {DISP_MODULE_CONFIG, 0},
  235. {DISP_MODULE_CMDQ, 0},
  236. {DISP_MODULE_MUTEX, 0},
  237. {DISP_MODULE_COLOR1, 0},
  238. {DISP_MODULE_RDMA2, 0},
  239. {DISP_MODULE_PWM1, 0},
  240. {DISP_MODULE_OD, 0},
  241. {DISP_MODULE_MERGE, 0},
  242. {DISP_MODULE_SPLIT0, 0},
  243. {DISP_MODULE_SPLIT1, 0},
  244. {DISP_MODULE_DSI1, 0},
  245. {DISP_MODULE_DSIDUAL, 0},
  246. {DISP_MODULE_SMI_LARB0, 0},
  247. {DISP_MODULE_SMI_COMMON, 0},
  248. {DISP_MODULE_UNKNOWN, 0},
  249. };
  250. #elif defined(MACH_TYPE_MT6735M)
  251. static int module_list_scenario[DDP_SCENARIO_MAX][DDP_ENING_NUM] = {
  252. /*PRIMARY_DISP */ {
  253. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR, DISP_MODULE_AAL,
  254. DISP_MODULE_GAMMA, DISP_MODULE_DITHER, DISP_MODULE_RDMA0,
  255. DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1
  256. },
  257. /*PRIMARY_RDMA0_COLOR0_DISP */ {
  258. DISP_MODULE_RDMA0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  259. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  260. DISP_MODULE_UFOE, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1,
  261. -1, -1
  262. },
  263. /*PRIMARY_RDMA0_DISP */ {
  264. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1,
  265. -1, -1, -1, -1, -1, -1
  266. },
  267. /*PRIMARY_BYPASS_RDMA */ {
  268. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  269. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  270. DISP_MODULE_UFOE, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1
  271. },
  272. /*PRIMARY_OVL_MEMOUT */ {
  273. DISP_MODULE_OVL0, DISP_MODULE_WDMA0, -1, -1, -1, -1, -1, -1, -1,
  274. -1, -1, -1
  275. },
  276. /*PRIMARY_DITHER_MEMOUT */ {
  277. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  278. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  279. DISP_MODULE_WDMA0, -1, -1, -1, -1, -1
  280. },
  281. /*PRIMARY_UFOE_MEMOUT */ {
  282. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  283. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  284. DISP_MODULE_RDMA0, DISP_MODULE_UFOE, DISP_MODULE_WDMA0, -1, -1,
  285. -1
  286. },
  287. /*SUB_DISP */ {
  288. DISP_MODULE_OVL1, DISP_MODULE_RDMA1, DISP_MODULE_DPI, -1, -1, -1, -1, -1, -1,
  289. -1, -1, -1
  290. },
  291. /*SUB_RDMA1_DISP */ {
  292. DISP_MODULE_RDMA1, DISP_MODULE_DSI0, -1, -1, -1, -1, -1, -1, -1, -1,
  293. -1, -1
  294. },
  295. /*SUB_RDMA2_DISP */ {
  296. DISP_MODULE_RDMA1, DISP_MODULE_DSI0, -1, -1, -1, -1, -1, -1, -1, -1,
  297. -1, -1
  298. },
  299. /*SUB_OVL_MEMOUT */ {
  300. DISP_MODULE_OVL1, DISP_MODULE_WDMA1, -1, -1, -1, -1, -1, -1, -1 - 1,
  301. -1, -1
  302. },
  303. /*SUB_GAMMA_MEMOUT */ {
  304. DISP_MODULE_OVL1, DISP_MODULE_WDMA1, -1, -1, -1, -1, -1, -1, -1 - 1,
  305. -1, -1
  306. },
  307. /*DISPLAY_INTERFACE */ {
  308. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  309. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  310. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1
  311. },
  312. /*PRIMARY_RDMA0_DUAL_DISP */ {
  313. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1,
  314. -1, -1, -1, -1, -1, -1, -1
  315. },
  316. /*PRIMARY_ALL */ {
  317. DISP_MODULE_OVL0, DISP_MODULE_WDMA0, DISP_MODULE_COLOR0,
  318. DISP_MODULE_CCORR, DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_DITHER,
  319. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1
  320. },
  321. /*SUB_ALL */ {
  322. DISP_MODULE_OVL1, DISP_MODULE_WDMA1, DISP_MODULE_RDMA1, DISP_MODULE_DPI, -1,
  323. -1, -1, -1, -1, -1, -1, -1
  324. },
  325. /*MULTIPLE_OVL */ {
  326. DISP_MODULE_OVL1, DISP_MODULE_OVL0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  327. -1
  328. },
  329. };
  330. /* 1st para is mout's input, 2nd para is mout's output */
  331. static mout_t mout_map[DDP_MOUT_NUM] = {
  332. /* OVL_MOUT */
  333. {
  334. DISP_MODULE_OVL0, {{DISP_MODULE_COLOR0, 1 << 0}, {DISP_MODULE_WDMA0, 1 << 1}, {-1, 0} },
  335. DISP_REG_CONFIG_DISP_OVL0_MOUT_EN, 0
  336. },
  337. #if defined(MTKFB_OVL1_SUPPORT)
  338. {
  339. DISP_MODULE_OVL1,
  340. { {DISP_MODULE_RDMA1, 1 << 0}, {DISP_MODULE_WDMA1, 1 << 1}, {DISP_MODULE_OVL0, 1 << 2},
  341. {-1, 0}
  342. }, 0
  343. },
  344. #endif
  345. /* DITHER0_MOUT */
  346. {
  347. DISP_MODULE_DITHER,
  348. { {DISP_MODULE_RDMA0, 1 << 0}, {DISP_MODULE_UFOE, 1 << 1}, {DISP_MODULE_WDMA0, 1 << 2},
  349. {-1, 0}
  350. }, DISP_REG_CONFIG_DISP_DITHER_MOUT_EN, 0
  351. },
  352. /* UFOE_MOUT */
  353. {
  354. DISP_MODULE_UFOE,
  355. { {DISP_MODULE_DSI0, 1 << 0}, {DISP_MODULE_DPI, 1 << 1}, {DISP_MODULE_WDMA0, 1 << 2},
  356. {-1, 0}
  357. }, DISP_REG_CONFIG_DISP_UFOE_MOUT_EN, 0
  358. },
  359. };
  360. static sel_t sel_out_map[DDP_SEL_OUT_NUM] = {
  361. /* RDMA_SOUT */
  362. {
  363. DISP_MODULE_RDMA0,
  364. {DISP_MODULE_UFOE, DISP_MODULE_COLOR0, DISP_MODULE_DSI0, DISP_MODULE_DPI, -1},
  365. DISP_REG_CONFIG_DISP_RDMA0_SOUT_SEL_IN, 0
  366. },
  367. {
  368. DISP_MODULE_RDMA1, {DISP_MODULE_DSI0, DISP_MODULE_DPI, -1},
  369. DISP_REG_CONFIG_DISP_RDMA1_SOUT_SEL_IN, 0
  370. },
  371. };
  372. /* 1st para is sout's output, 2nd para is sout's input */
  373. static sel_t sel_in_map[DDP_SEL_IN_NUM] = {
  374. /* COLOR_SEL */
  375. {
  376. DISP_MODULE_COLOR0, {DISP_MODULE_RDMA0, DISP_MODULE_OVL0, -1},
  377. DISP_REG_CONFIG_DISP_COLOR0_SEL_IN, 0
  378. },
  379. /* UFOE_SEL */
  380. {
  381. DISP_MODULE_UFOE, {DISP_MODULE_RDMA0, DISP_MODULE_DITHER, -1},
  382. DISP_REG_CONFIG_DISP_UFOE_SEL_IN, 0
  383. },
  384. /* DSI0_SEL */
  385. {
  386. DISP_MODULE_DSI0, {DISP_MODULE_UFOE, DISP_MODULE_RDMA0, DISP_MODULE_RDMA1, -1},
  387. DISP_REG_CONFIG_DSI0_SEL_IN, 0
  388. },
  389. /* DPI0_SEL */
  390. {
  391. DISP_MODULE_DPI, {DISP_MODULE_UFOE, DISP_MODULE_RDMA0, DISP_MODULE_RDMA1, -1},
  392. DISP_REG_CONFIG_DPI0_SEL_IN, 0
  393. },
  394. /* WDMA_SEL */
  395. {
  396. DISP_MODULE_WDMA0, {DISP_MODULE_OVL0, DISP_MODULE_DITHER, DISP_MODULE_UFOE, -1},
  397. DISP_REG_CONFIG_DISP_WDMA0_SEL_IN, 0
  398. },
  399. };
  400. /* module bit in mutex */
  401. static module_map_t module_mutex_map[DISP_MODULE_NUM] = {
  402. {DISP_MODULE_OVL0, 6},
  403. {DISP_MODULE_OVL1, -1},
  404. {DISP_MODULE_RDMA0, 8},
  405. {DISP_MODULE_RDMA1, 9},
  406. {DISP_MODULE_WDMA0, 10},
  407. {DISP_MODULE_COLOR0, 12},
  408. {DISP_MODULE_CCORR, 11},
  409. {DISP_MODULE_AAL, 13},
  410. {DISP_MODULE_GAMMA, 14},
  411. {DISP_MODULE_DITHER, 15},
  412. {DISP_MODULE_UFOE, -1},
  413. {DISP_MODULE_PWM0, 17},
  414. {DISP_MODULE_WDMA1, -1},
  415. {DISP_MODULE_DSI0, -1},
  416. {DISP_MODULE_DPI, -1},
  417. {DISP_MODULE_SMI, -1},
  418. {DISP_MODULE_CONFIG, -1},
  419. {DISP_MODULE_CMDQ, -1},
  420. {DISP_MODULE_MUTEX, -1},
  421. };
  422. /* module can be connect if 1 */
  423. static module_map_t module_can_connect[DISP_MODULE_NUM] = {
  424. {DISP_MODULE_OVL0, 1},
  425. {DISP_MODULE_OVL1, 0},
  426. {DISP_MODULE_RDMA0, 1},
  427. {DISP_MODULE_RDMA1, 0},
  428. {DISP_MODULE_WDMA0, 1},
  429. {DISP_MODULE_COLOR0, 1},
  430. {DISP_MODULE_CCORR, 1},
  431. {DISP_MODULE_AAL, 1},
  432. {DISP_MODULE_GAMMA, 1},
  433. {DISP_MODULE_DITHER, 1},
  434. {DISP_MODULE_UFOE, 1},
  435. {DISP_MODULE_PWM0, 0},
  436. {DISP_MODULE_WDMA1, 0},
  437. {DISP_MODULE_DSI0, 1},
  438. {DISP_MODULE_DPI, 1},
  439. {DISP_MODULE_SMI, 0},
  440. {DISP_MODULE_CONFIG, 0},
  441. {DISP_MODULE_CMDQ, 0},
  442. {DISP_MODULE_MUTEX, 0},
  443. {DISP_MODULE_COLOR1, 0},
  444. {DISP_MODULE_RDMA2, 0},
  445. {DISP_MODULE_PWM1, 0},
  446. {DISP_MODULE_OD, 0},
  447. {DISP_MODULE_MERGE, 0},
  448. {DISP_MODULE_SPLIT0, 0},
  449. {DISP_MODULE_SPLIT1, 0},
  450. {DISP_MODULE_DSI1, 0},
  451. {DISP_MODULE_DSIDUAL, 0},
  452. {DISP_MODULE_SMI_LARB0, 0},
  453. {DISP_MODULE_SMI_COMMON, 0},
  454. {DISP_MODULE_UNKNOWN, 0},
  455. };
  456. #elif defined(MACH_TYPE_MT6753)
  457. static int module_list_scenario[DDP_SCENARIO_MAX][DDP_ENING_NUM] = {
  458. /*PRIMARY_DISP */ {
  459. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR, DISP_MODULE_AAL,
  460. DISP_MODULE_GAMMA, DISP_MODULE_OD, DISP_MODULE_DITHER, DISP_MODULE_RDMA0,
  461. DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1
  462. },
  463. /*PRIMARY_RDMA0_COLOR0_DISP */ {
  464. DISP_MODULE_RDMA0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  465. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_OD,
  466. DISP_MODULE_DITHER, DISP_MODULE_UFOE, DISP_MODULE_PWM0,
  467. DISP_MODULE_DSI0, -1, -1
  468. },
  469. /*PRIMARY_RDMA0_DISP */ {
  470. DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0, -1, -1, -1,
  471. -1, -1, -1, -1, -1, -1
  472. },
  473. /*PRIMARY_BYPASS_RDMA */ {
  474. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  475. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_OD,
  476. DISP_MODULE_DITHER, DISP_MODULE_UFOE, DISP_MODULE_PWM0,
  477. DISP_MODULE_DSI0, -1, -1
  478. },
  479. /*PRIMARY_OVL_MEMOUT */ {
  480. DISP_MODULE_OVL0, DISP_MODULE_WDMA0, -1, -1, -1, -1, -1, -1, -1,
  481. -1, -1, -1
  482. },
  483. /*PRIMARY_DITHER_MEMOUT */ {
  484. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  485. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_OD,
  486. DISP_MODULE_DITHER, DISP_MODULE_WDMA0, -1, -1, -1, -1
  487. },
  488. /*PRIMARY_UFOE_MEMOUT */ {
  489. DISP_MODULE_OVL0, DISP_MODULE_COLOR0, DISP_MODULE_CCORR,
  490. DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_OD,
  491. DISP_MODULE_DITHER, DISP_MODULE_RDMA0, DISP_MODULE_UFOE,
  492. DISP_MODULE_WDMA0, -1, -1
  493. },
  494. /*SUB_DISP */ {
  495. DISP_MODULE_OVL1, DISP_MODULE_RDMA1, DISP_MODULE_DPI, -1, -1, -1, -1, -1, -1,
  496. -1, -1, -1
  497. },
  498. #ifndef CONFIG_FPGA_EARLY_PORTING
  499. /*SUB_RDMA1_DISP */ {
  500. DISP_MODULE_RDMA1, DISP_MODULE_DPI, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  501. -1
  502. },
  503. #else
  504. /*SUB_RDMA1_DISP */ {
  505. DISP_MODULE_RDMA1, DISP_MODULE_DSI0, -1, -1, -1, -1, -1, -1, -1, -1,
  506. -1, -1
  507. },
  508. #endif
  509. /*SUB_OVL_MEMOUT */ {
  510. DISP_MODULE_OVL1, DISP_MODULE_WDMA1, -1, -1, -1, -1, -1, -1, -1 - 1,
  511. -1, -1
  512. },
  513. /*PRIMARY_ALL */ {
  514. DISP_MODULE_OVL0, DISP_MODULE_WDMA0, DISP_MODULE_COLOR0,
  515. DISP_MODULE_CCORR, DISP_MODULE_AAL, DISP_MODULE_GAMMA, DISP_MODULE_OD,
  516. DISP_MODULE_DITHER, DISP_MODULE_RDMA0, DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  517. -1
  518. },
  519. /*SUB_ALL */ {
  520. DISP_MODULE_OVL1, DISP_MODULE_WDMA1, DISP_MODULE_RDMA1, DISP_MODULE_DPI, -1,
  521. -1, -1, -1, -1, -1, -1, -1
  522. },
  523. /*MULTIPLE_OVL */ {
  524. DISP_MODULE_OVL1, DISP_MODULE_OVL0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  525. -1
  526. },
  527. };
  528. /* 1st para is mout's input, 2nd para is mout's output */
  529. static mout_t mout_map[DDP_MOUT_NUM] = {
  530. /* OVL_MOUT */
  531. {
  532. DISP_MODULE_OVL0, {{DISP_MODULE_COLOR0, 1 << 0}, {DISP_MODULE_WDMA0, 1 << 1}, {-1, 0} },
  533. DISP_REG_CONFIG_DISP_OVL0_MOUT_EN, 0
  534. },
  535. {DISP_MODULE_OVL1, {{DISP_MODULE_RDMA1, 1 << 0}, {DISP_MODULE_OVL0, 1 << 1}, {-1, 0} }, 0},
  536. /* DITHER0_MOUT */
  537. {
  538. DISP_MODULE_DITHER,
  539. { {DISP_MODULE_RDMA0, 1 << 0}, {DISP_MODULE_UFOE, 1 << 1}, {DISP_MODULE_WDMA0, 1 << 2},
  540. {-1, 0}
  541. }, DISP_REG_CONFIG_DISP_DITHER_MOUT_EN, 0
  542. },
  543. /* UFOE_MOUT */
  544. {
  545. DISP_MODULE_UFOE,
  546. { {DISP_MODULE_DSI0, 1 << 0}, {DISP_MODULE_DPI, 1 << 1}, {DISP_MODULE_WDMA0, 1 << 2},
  547. {-1, 0}
  548. }, DISP_REG_CONFIG_DISP_UFOE_MOUT_EN, 0
  549. },
  550. };
  551. static sel_t sel_out_map[DDP_SEL_OUT_NUM] = {
  552. /* RDMA_SOUT */
  553. {
  554. DISP_MODULE_RDMA0,
  555. {DISP_MODULE_UFOE, DISP_MODULE_COLOR0, DISP_MODULE_DSI0, DISP_MODULE_DPI, -1},
  556. DISP_REG_CONFIG_DISP_RDMA0_SOUT_SEL_IN, 0
  557. },
  558. {
  559. DISP_MODULE_RDMA1, {DISP_MODULE_DSI0, DISP_MODULE_DPI, -1},
  560. DISP_REG_CONFIG_DISP_RDMA1_SOUT_SEL_IN, 0
  561. },
  562. };
  563. /* 1st para is sout's output, 2nd para is sout's input */
  564. static sel_t sel_in_map[DDP_SEL_IN_NUM] = {
  565. /* COLOR_SEL */
  566. {
  567. DISP_MODULE_COLOR0, {DISP_MODULE_RDMA0, DISP_MODULE_OVL0, -1},
  568. DISP_REG_CONFIG_DISP_COLOR0_SEL_IN, 0
  569. },
  570. /* UFOE_SEL */
  571. {
  572. DISP_MODULE_UFOE, {DISP_MODULE_RDMA0, DISP_MODULE_DITHER, -1},
  573. DISP_REG_CONFIG_DISP_UFOE_SEL_IN, 0
  574. },
  575. /* DSI0_SEL */
  576. {
  577. DISP_MODULE_DSI0, {DISP_MODULE_UFOE, DISP_MODULE_RDMA0, DISP_MODULE_RDMA1, -1},
  578. DISP_REG_CONFIG_DSI0_SEL_IN, 0
  579. },
  580. /* DPI0_SEL */
  581. {
  582. DISP_MODULE_DPI, {DISP_MODULE_UFOE, DISP_MODULE_RDMA0, DISP_MODULE_RDMA1, -1},
  583. DISP_REG_CONFIG_DPI0_SEL_IN, 0
  584. },
  585. /* WDMA_SEL */
  586. {
  587. DISP_MODULE_WDMA0, {DISP_MODULE_OVL0, DISP_MODULE_DITHER, DISP_MODULE_UFOE, -1},
  588. DISP_REG_CONFIG_DISP_WDMA0_SEL_IN, 0
  589. },
  590. };
  591. /* module bit in mutex */
  592. static module_map_t module_mutex_map[DISP_MODULE_NUM] = {
  593. {DISP_MODULE_OVL0, 6},
  594. {DISP_MODULE_OVL1, -1},
  595. {DISP_MODULE_RDMA0, 8},
  596. {DISP_MODULE_RDMA1, 9},
  597. {DISP_MODULE_WDMA0, 10},
  598. {DISP_MODULE_COLOR0, 12},
  599. {DISP_MODULE_CCORR, 11},
  600. {DISP_MODULE_AAL, 13},
  601. {DISP_MODULE_GAMMA, 14},
  602. {DISP_MODULE_DITHER, 15},
  603. {DISP_MODULE_UFOE, -1},
  604. {DISP_MODULE_PWM0, 17},
  605. {DISP_MODULE_WDMA1, -1},
  606. {DISP_MODULE_DSI0, -1},
  607. {DISP_MODULE_DPI, -1},
  608. {DISP_MODULE_SMI, -1},
  609. {DISP_MODULE_CONFIG, -1},
  610. {DISP_MODULE_CMDQ, -1},
  611. {DISP_MODULE_MUTEX, -1},
  612. {DISP_MODULE_COLOR1, -1},
  613. {DISP_MODULE_RDMA2, -1},
  614. {DISP_MODULE_PWM1, -1},
  615. {DISP_MODULE_OD, 18},
  616. };
  617. /* module can be connect if 1 */
  618. static module_map_t module_can_connect[DISP_MODULE_NUM] = {
  619. {DISP_MODULE_OVL0, 1},
  620. {DISP_MODULE_OVL1, 0},
  621. {DISP_MODULE_RDMA0, 1},
  622. {DISP_MODULE_RDMA1, 1},
  623. {DISP_MODULE_WDMA0, 1},
  624. {DISP_MODULE_COLOR0, 1},
  625. {DISP_MODULE_CCORR, 1},
  626. {DISP_MODULE_AAL, 1},
  627. {DISP_MODULE_GAMMA, 1},
  628. {DISP_MODULE_DITHER, 1},
  629. {DISP_MODULE_UFOE, 1},
  630. {DISP_MODULE_PWM0, 0},
  631. {DISP_MODULE_WDMA1, 0},
  632. {DISP_MODULE_DSI0, 1},
  633. {DISP_MODULE_DPI, 1},
  634. {DISP_MODULE_SMI, 0},
  635. {DISP_MODULE_CONFIG, 0},
  636. {DISP_MODULE_CMDQ, 0},
  637. {DISP_MODULE_MUTEX, 0},
  638. {DISP_MODULE_COLOR1, 0},
  639. {DISP_MODULE_RDMA2, 0},
  640. {DISP_MODULE_PWM1, 0},
  641. {DISP_MODULE_OD, 1},
  642. {DISP_MODULE_MERGE, 0},
  643. {DISP_MODULE_SPLIT0, 0},
  644. {DISP_MODULE_SPLIT1, 0},
  645. {DISP_MODULE_DSI1, 0},
  646. {DISP_MODULE_DSIDUAL, 0},
  647. {DISP_MODULE_SMI_LARB0, 0},
  648. {DISP_MODULE_SMI_COMMON, 0},
  649. {DISP_MODULE_UNKNOWN, 0},
  650. };
  651. #endif
  652. int ddp_path_init()
  653. {
  654. int index = 0;
  655. // mout
  656. mout_map[index++].reg = DISP_REG_CONFIG_DISP_OVL0_MOUT_EN;
  657. #if defined(MTK_FB_OVL1_SUPPORT)
  658. mout_map[index++].reg = DISP_REG_CONFIG_DISP_OVL1_MOUT_EN;
  659. #endif
  660. mout_map[index++].reg = DISP_REG_CONFIG_DISP_DITHER_MOUT_EN;
  661. mout_map[index++].reg = DISP_REG_CONFIG_DISP_UFOE_MOUT_EN;
  662. // sel_out
  663. sel_out_map[0].reg = DISP_REG_CONFIG_DISP_RDMA0_SOUT_SEL_IN;
  664. sel_out_map[1].reg = DISP_REG_CONFIG_DISP_RDMA1_SOUT_SEL_IN;
  665. // sel_in
  666. sel_in_map[0].reg = DISP_REG_CONFIG_DISP_COLOR0_SEL_IN; // COLOR_SEL
  667. sel_in_map[1].reg = DISP_REG_CONFIG_DISP_UFOE_SEL_IN; //UFOE_SEL
  668. sel_in_map[2].reg = DISP_REG_CONFIG_DSI0_SEL_IN; //DSI0_SEL
  669. sel_in_map[3].reg = DISP_REG_CONFIG_DPI0_SEL_IN; //DPI0_SEL
  670. sel_in_map[4].reg = DISP_REG_CONFIG_DISP_WDMA0_SEL_IN; // WDMA_SEL
  671. return 0;
  672. }
  673. char* ddp_get_scenario_name(DDP_SCENARIO_ENUM scenario)
  674. {
  675. switch (scenario) {
  676. case DDP_SCENARIO_PRIMARY_DISP :
  677. return "primary_disp";
  678. case DDP_SCENARIO_PRIMARY_RDMA0_COLOR0_DISP :
  679. return "primary_rdma0_color_disp";
  680. case DDP_SCENARIO_PRIMARY_RDMA0_DISP :
  681. return "primary_rdma0_disp";
  682. case DDP_SCENARIO_PRIMARY_BYPASS_RDMA :
  683. return "primary_bypass_rdma";
  684. case DDP_SCENARIO_PRIMARY_OVL_MEMOUT :
  685. return "primary_ovl_memout";
  686. case DDP_SCENARIO_PRIMARY_OD_MEMOUT :
  687. return "primary_od_memout";
  688. case DDP_SCENARIO_PRIMARY_UFOE_MEMOUT :
  689. return "primary_ufoe_memout";
  690. case DDP_SCENARIO_SUB_DISP :
  691. return "sub_disp";
  692. case DDP_SCENARIO_SUB_RDMA1_DISP :
  693. return "sub_rdma1_disp";
  694. case DDP_SCENARIO_SUB_RDMA2_DISP :
  695. return "sub_rdma2_disp";
  696. case DDP_SCENARIO_SUB_OVL_MEMOUT :
  697. return "sub_ovl_memout";
  698. case DDP_SCENARIO_SUB_GAMMA_MEMOUT :
  699. return "sub_gamma_memout";
  700. case DDP_SCENARIO_DISPLAY_INTERFACE:
  701. return "display_interface";
  702. case DDP_SCENARIO_RDMA0_DUAL_DISP :
  703. return "rmda0_dual_disp";
  704. case DDP_SCENARIO_PRIMARY_ALL :
  705. return "primary_all";
  706. case DDP_SCENARIO_SUB_ALL :
  707. return "sub_all";
  708. case DDP_SCENARIO_MULTIPLE_OVL:
  709. return "multi_ovl";
  710. default:
  711. DDPMSG("invalid scenario id=%d", scenario);
  712. return "unknown";
  713. }
  714. }
  715. int ddp_is_scenario_on_primary(DDP_SCENARIO_ENUM scenario)
  716. {
  717. int on_primary = 0;
  718. switch (scenario) {
  719. case DDP_SCENARIO_PRIMARY_DISP:
  720. case DDP_SCENARIO_PRIMARY_RDMA0_COLOR0_DISP:
  721. case DDP_SCENARIO_PRIMARY_RDMA0_DISP:
  722. case DDP_SCENARIO_PRIMARY_BYPASS_RDMA:
  723. case DDP_SCENARIO_PRIMARY_OVL_MEMOUT:
  724. case DDP_SCENARIO_PRIMARY_OD_MEMOUT:
  725. case DDP_SCENARIO_PRIMARY_UFOE_MEMOUT:
  726. case DDP_SCENARIO_RDMA0_DUAL_DISP:
  727. case DDP_SCENARIO_PRIMARY_ALL:
  728. case DDP_SCENARIO_MULTIPLE_OVL:
  729. on_primary = 1;
  730. break;
  731. case DDP_SCENARIO_SUB_DISP:
  732. case DDP_SCENARIO_SUB_RDMA1_DISP:
  733. case DDP_SCENARIO_SUB_RDMA2_DISP:
  734. case DDP_SCENARIO_SUB_OVL_MEMOUT:
  735. case DDP_SCENARIO_SUB_GAMMA_MEMOUT:
  736. case DDP_SCENARIO_SUB_ALL:
  737. on_primary = 0;
  738. break;
  739. default:
  740. DDPMSG("invalid scenario id=%d", scenario);
  741. }
  742. return on_primary;
  743. }
  744. char* ddp_get_mutex_sof_name(MUTEX_SOF mode)
  745. {
  746. switch (mode) {
  747. case SOF_SINGLE :
  748. return "single";
  749. case SOF_DSI0 :
  750. return "dsi0";
  751. case SOF_DSI1 :
  752. return "dsi1";
  753. case SOF_DPI0 :
  754. return "dpi0";
  755. default:
  756. DDPMSG("invalid sof =%d", mode);
  757. return "unknown";
  758. }
  759. }
  760. char* ddp_get_mode_name(DDP_MODE ddp_mode)
  761. {
  762. switch (ddp_mode) {
  763. case DDP_VIDEO_MODE :
  764. return "vido_mode";
  765. case DDP_CMD_MODE :
  766. return "cmd_mode";
  767. default:
  768. DDPMSG("invalid ddp mode =%d", ddp_mode);
  769. return "unknown";
  770. }
  771. }
  772. static int ddp_get_module_num_l(int* module_list)
  773. {
  774. unsigned int num = 0;
  775. while (*(module_list+num)!=-1) {
  776. num++;
  777. }
  778. return num;
  779. }
  780. // config mout/msel to creat a compelte path
  781. static void ddp_connect_path_l(int *module_list, void * handle)
  782. {
  783. int i, j;
  784. unsigned int k;
  785. int step=0;
  786. unsigned int mout=0;
  787. unsigned int reg_mout = 0;
  788. unsigned int mout_idx = 0;
  789. int module_num = ddp_get_module_num_l(module_list);
  790. ASSERT(module_num>=1);
  791. DDPDBG("connect_path: %s to %s\n",ddp_get_module_name(module_list[0]),
  792. ddp_get_module_name(module_list[module_num-1]));
  793. // connect mout
  794. for (i = 0 ; i < module_num - 1 ; i++) {
  795. for (j = 0 ; j < DDP_MOUT_NUM ; j++) {
  796. if (module_list[i] == mout_map[j].id) {
  797. //find next module which can be connected
  798. step = i+1;
  799. while ((step<module_num) && (module_can_connect[module_list[step]].bit==0)) {
  800. step++;
  801. }
  802. ASSERT(step<module_num);
  803. mout = mout_map[j].reg_val;
  804. for (k = 0 ; k < 5 ; k++) {
  805. if (mout_map[j].out_id_bit_map[k].m == -1)
  806. break;
  807. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  808. mout |= mout_map[j].out_id_bit_map[k].v;
  809. reg_mout |= mout;
  810. mout_idx = j;
  811. DDPDBG("connect mout %s to %s value 0x%x\n", ddp_get_module_name(module_list[i]),
  812. ddp_get_module_name(module_list[step]),reg_mout);
  813. break;
  814. }
  815. }
  816. mout_map[j].reg_val = mout;
  817. mout = 0;
  818. }
  819. }
  820. if (reg_mout) {
  821. DISP_REG_SET(handle,mout_map[mout_idx].reg, reg_mout);
  822. reg_mout = 0;
  823. mout_idx = 0;
  824. }
  825. }
  826. // connect out select
  827. for (i = 0 ; i < module_num - 1 ; i++) {
  828. for (j = 0 ; j < DDP_SEL_OUT_NUM ; j++) {
  829. if (module_list[i] == sel_out_map[j].id) {
  830. step = i+1;
  831. //find next module which can be connected
  832. while ((step<module_num) && (module_can_connect[module_list[step]].bit==0)) {
  833. step++;
  834. }
  835. ASSERT(step<module_num);
  836. for (k = 0 ; k < 4 ; k++) {
  837. if (sel_out_map[j].id_bit_map[k] == -1)
  838. break;
  839. if (sel_out_map[j].id_bit_map[k] == module_list[step]) {
  840. DDPDBG("connect out_s %s to %s, bits=0x%x\n", ddp_get_module_name(module_list[i]),
  841. ddp_get_module_name(module_list[step]), k);
  842. DISP_REG_SET(handle,sel_out_map[j].reg, k);
  843. break;
  844. }
  845. }
  846. }
  847. }
  848. }
  849. // connect input select
  850. for (i = 1 ; i < module_num ; i++) {
  851. for (j = 0 ; j < DDP_SEL_IN_NUM ; j++) {
  852. if (module_list[i] == sel_in_map[j].id) {
  853. step = i-1;
  854. //find next module which can be connected
  855. while ((step>0) && (module_can_connect[module_list[step]].bit==0)) {
  856. step--;
  857. }
  858. ASSERT(step>=0);
  859. for (k = 0 ; k < 4 ; k++) {
  860. if (sel_in_map[j].id_bit_map[k] == -1)
  861. break;
  862. if (sel_in_map[j].id_bit_map[k] == module_list[step]) {
  863. DDPDBG("connect in_s %s to %s, bits=0x%x\n", ddp_get_module_name(module_list[step]),
  864. ddp_get_module_name(module_list[i]), k);
  865. DISP_REG_SET(handle,sel_in_map[j].reg, k);
  866. break;
  867. }
  868. }
  869. }
  870. }
  871. }
  872. }
  873. static void ddp_check_path_l(int *module_list)
  874. {
  875. int i, j;
  876. unsigned int k;
  877. int step = 0;
  878. int valid =0;
  879. unsigned int mout;
  880. unsigned int path_error = 0;
  881. int module_num = ddp_get_module_num_l(module_list);
  882. ASSERT(module_num>=1);
  883. DDPDBG("check_path: %s to %s\n",ddp_get_module_name(module_list[0])
  884. ,ddp_get_module_name(module_list[module_num-1]));
  885. // check mout
  886. for (i = 0 ; i < module_num - 1 ; i++) {
  887. for (j = 0 ; j < DDP_MOUT_NUM ; j++) {
  888. if (module_list[i] == mout_map[j].id) {
  889. mout = 0;
  890. //find next module which can be connected
  891. step = i+1;
  892. while ((step<module_num) && (module_can_connect[module_list[step]].bit==0)) {
  893. step++;
  894. }
  895. ASSERT(step<module_num);
  896. for (k = 0 ; k < 5 ; k++) {
  897. if (mout_map[j].out_id_bit_map[k].m == -1)
  898. break;
  899. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  900. mout |= mout_map[j].out_id_bit_map[k].v;
  901. valid =1;
  902. break;
  903. }
  904. }
  905. if (valid) {
  906. valid =0;
  907. if ((DISP_REG_GET(mout_map[j].reg) & mout)==0) {
  908. path_error += 1;
  909. DDPERR("%s mout, expect=0x%x, real=0x%x \n",
  910. ddp_get_module_name(module_list[i]),
  911. mout,
  912. DISP_REG_GET(mout_map[j].reg));
  913. } else if (DISP_REG_GET(mout_map[j].reg) != mout) {
  914. DDPMSG("warning: %s mout expect=0x%x, real=0x%x \n",
  915. ddp_get_module_name(module_list[i]),
  916. mout,
  917. DISP_REG_GET(mout_map[j].reg));
  918. }
  919. }
  920. break;
  921. }
  922. }
  923. }
  924. // check out select
  925. for (i = 0 ; i < module_num - 1 ; i++) {
  926. for (j = 0 ; j < DDP_SEL_OUT_NUM ; j++) {
  927. if (module_list[i] == sel_out_map[j].id) {
  928. //find next module which can be connected
  929. step = i+1;
  930. while ((step<module_num) && (module_can_connect[module_list[step]].bit==0)) {
  931. step++;
  932. }
  933. ASSERT(step<module_num);
  934. for (k = 0 ; k < 4 ; k++) {
  935. if (sel_out_map[j].id_bit_map[k] == -1)
  936. break;
  937. if (sel_out_map[j].id_bit_map[k] == module_list[step]) {
  938. if (DISP_REG_GET(sel_out_map[j].reg) != k) {
  939. path_error += 1;
  940. DDPERR("out_s %s not connect to %s, expect=0x%x, real=0x%x \n",
  941. ddp_get_module_name(module_list[i]),ddp_get_module_name(module_list[step]),
  942. k,
  943. DISP_REG_GET(sel_out_map[j].reg));
  944. }
  945. break;
  946. }
  947. }
  948. }
  949. }
  950. }
  951. // check input select
  952. for (i = 1 ; i < module_num ; i++) {
  953. for (j = 0 ; j < DDP_SEL_IN_NUM ; j++) {
  954. if (module_list[i] == sel_in_map[j].id) {
  955. //find next module which can be connected
  956. step = i-1;
  957. while ((step>0) && (module_can_connect[module_list[step]].bit==0)) {
  958. step--;
  959. }
  960. ASSERT(step>=0);
  961. for (k = 0 ; k < 4 ; k++) {
  962. if (sel_in_map[j].id_bit_map[k] == -1)
  963. break;
  964. if (sel_in_map[j].id_bit_map[k] == module_list[step]) {
  965. if (DISP_REG_GET(sel_in_map[j].reg) != k) {
  966. path_error += 1;
  967. DDPERR("in_s %s not connect to %s, expect=0x%x, real=0x%x \n",
  968. ddp_get_module_name(module_list[step]),ddp_get_module_name(module_list[i]),
  969. k,
  970. DISP_REG_GET(sel_in_map[j].reg));
  971. }
  972. break;
  973. }
  974. }
  975. }
  976. }
  977. }
  978. if (path_error == 0) {
  979. DDPMSG("path: %s to %s is connected\n",ddp_get_module_name(module_list[0]),
  980. ddp_get_module_name(module_list[module_num - 1]));
  981. } else {
  982. DDPERR("path: %s to %s not connected!!!\n",ddp_get_module_name(module_list[0]),
  983. ddp_get_module_name(module_list[module_num - 1]));
  984. }
  985. }
  986. static void ddp_disconnect_path_l(int *module_list,void * handle)
  987. {
  988. int i, j;
  989. unsigned int k;
  990. int step = 0;
  991. unsigned int mout = 0;
  992. unsigned int reg_mout = 0;
  993. unsigned int mout_idx = 0;
  994. int module_num = ddp_get_module_num_l(module_list);
  995. ASSERT(module_num>=1);
  996. DDPDBG("disconnect_path: %s to %s\n",ddp_get_module_name(module_list[0]),
  997. ddp_get_module_name(module_list[module_num-1]));
  998. for (i = 0 ; i < module_num - 1 ; i++) {
  999. for (j = 0 ; j < DDP_MOUT_NUM ; j++) {
  1000. if (module_list[i] == mout_map[j].id) {
  1001. //find next module which can be connected
  1002. step = i+1;
  1003. while ((step<module_num) && (module_can_connect[module_list[step]].bit==0)) {
  1004. step++;
  1005. }
  1006. ASSERT(step<module_num);
  1007. for (k = 0 ; k < 5 ; k++) {
  1008. if (mout_map[j].out_id_bit_map[k].m == -1)
  1009. break;
  1010. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  1011. mout |= mout_map[j].out_id_bit_map[k].v;
  1012. reg_mout |= mout;
  1013. mout_idx = j;
  1014. DDPDBG("disconnect mout %s to %s \n", ddp_get_module_name(module_list[i]),
  1015. ddp_get_module_name(module_list[step]));
  1016. break;
  1017. }
  1018. }
  1019. //update mout_value
  1020. mout_map[j].reg_val &= ~mout;
  1021. mout = 0;
  1022. }
  1023. }
  1024. if (reg_mout) {
  1025. DISP_REG_SET(handle,mout_map[mout_idx].reg, mout_map[mout_idx].reg_val);
  1026. reg_mout = 0;
  1027. mout_idx = 0;
  1028. }
  1029. }
  1030. }
  1031. static MUTEX_SOF ddp_get_mutex_sof(DISP_MODULE_ENUM dest_module, DDP_MODE ddp_mode)
  1032. {
  1033. MUTEX_SOF mode = SOF_SINGLE;
  1034. switch (dest_module) {
  1035. case DISP_MODULE_DSI0: {
  1036. mode = (ddp_mode==DDP_VIDEO_MODE ? SOF_DSI0 : SOF_SINGLE);
  1037. break;
  1038. }
  1039. case DISP_MODULE_DSI1: {
  1040. mode = (ddp_mode==DDP_VIDEO_MODE ? SOF_DSI1 : SOF_SINGLE);
  1041. break;
  1042. }
  1043. case DISP_MODULE_DSIDUAL: {
  1044. mode = (ddp_mode==DDP_VIDEO_MODE ? SOF_DSI0 : SOF_SINGLE);
  1045. break;
  1046. }
  1047. case DISP_MODULE_DPI: {
  1048. mode = SOF_DPI0;
  1049. break;
  1050. }
  1051. case DISP_MODULE_WDMA0:
  1052. case DISP_MODULE_WDMA1:
  1053. mode = SOF_SINGLE;
  1054. break;
  1055. default:
  1056. DDPERR("get mutex sof, invalid param dst module = %s(%d), dis mode %s\n",
  1057. ddp_get_module_name(dest_module), dest_module,ddp_get_mode_name(ddp_mode));
  1058. }
  1059. DDPDBG("mutex sof: %s dst module %s:%s\n",
  1060. ddp_get_mutex_sof_name(mode), ddp_get_module_name(dest_module),ddp_get_mode_name(ddp_mode));
  1061. return mode;
  1062. }
  1063. // id: mutex ID, 0~5
  1064. static int ddp_mutex_set_l(int mutex_id, int* module_list, DDP_MODE ddp_mode, void * handle)
  1065. {
  1066. int i=0;
  1067. kal_uint32 value = 0;
  1068. int module_num = ddp_get_module_num_l(module_list);
  1069. MUTEX_SOF mode = ddp_get_mutex_sof(module_list[module_num-1],ddp_mode);
  1070. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  1071. DDPERR("exceed mutex max (0 ~ %d)\n",DISP_MUTEX_DDP_LAST);
  1072. return -1;
  1073. }
  1074. for (i = 0 ; i < module_num ; i++) {
  1075. if (module_mutex_map[module_list[i]].bit != -1)
  1076. DDPDBG("module %s added to mutex %d\n",ddp_get_module_name(module_list[i]),mutex_id);
  1077. value |= (1 << module_mutex_map[module_list[i]].bit);
  1078. }
  1079. DISP_REG_SET(handle,DISP_REG_CONFIG_MUTEX_MOD(mutex_id),value);
  1080. DISP_REG_SET(handle,DISP_REG_CONFIG_MUTEX_SOF(mutex_id),mode);
  1081. DDPMSG("mutex %d value=0x%x, sof=%s\n",mutex_id, value, ddp_get_mutex_sof_name(mode));
  1082. return 0;
  1083. }
  1084. static void ddp_check_mutex_l(int mutex_id, int* module_list, DDP_MODE ddp_mode)
  1085. {
  1086. int i=0;
  1087. kal_uint32 real_value = 0;
  1088. kal_uint32 expect_value = 0;
  1089. kal_uint32 real_sof = 0;
  1090. MUTEX_SOF expect_sof = SOF_SINGLE;
  1091. int module_num = ddp_get_module_num_l(module_list);
  1092. if ((mutex_id < DISP_MUTEX_DDP_FIRST) || (mutex_id > DISP_MUTEX_DDP_LAST)) {
  1093. DDPERR("check mutex fail:exceed mutex max (0 ~ %d)\n",DISP_MUTEX_DDP_LAST);
  1094. return;
  1095. }
  1096. real_value = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_MOD(mutex_id));
  1097. for (i = 0 ; i < module_num ; i++) {
  1098. if (module_mutex_map[module_list[i]].bit != -1)
  1099. expect_value |= (1 << module_mutex_map[module_list[i]].bit);
  1100. }
  1101. if ( expect_value != real_value ) {
  1102. DDPERR("mutex %d module error expect 0x%x, real 0x%x\n",mutex_id,expect_value,real_value);
  1103. }
  1104. real_sof = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_SOF(mutex_id));
  1105. expect_sof = ddp_get_mutex_sof(module_list[module_num-1],ddp_mode);
  1106. if ((kal_uint32)expect_sof != real_sof) {
  1107. DDPERR("mutex %d sof error expect %s, real %s\n", mutex_id,
  1108. ddp_get_mutex_sof_name(expect_sof),
  1109. ddp_get_mutex_sof_name((MUTEX_SOF)real_sof));
  1110. }
  1111. }
  1112. static int ddp_mutex_enable_l(int mutex_idx,void * handle)
  1113. {
  1114. DDPDBG("mutex %d enable\n", mutex_idx);
  1115. DISP_REG_SET(handle,DISP_REG_CONFIG_MUTEX_EN(mutex_idx),1);
  1116. return 0;
  1117. }
  1118. int ddp_get_module_num(DDP_SCENARIO_ENUM scenario)
  1119. {
  1120. return ddp_get_module_num_l(module_list_scenario[scenario]);
  1121. }
  1122. static void ddp_print_scenario(DDP_SCENARIO_ENUM scenario)
  1123. {
  1124. int i =0;
  1125. char path[512]= {'\0'};
  1126. int num = ddp_get_module_num(scenario);
  1127. for (i=0; i< num; i++) {
  1128. strncat(path, ddp_get_module_name(module_list_scenario[scenario][i]), sizeof(path)-strlen(path)-1);
  1129. }
  1130. DDPMSG("scenario %s have modules: %s\n",ddp_get_scenario_name(scenario),path);
  1131. }
  1132. static int ddp_find_module_index(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM module)
  1133. {
  1134. int i=0;
  1135. for (i=0; i< DDP_ENING_NUM-1; i++) {
  1136. if (module_list_scenario[ddp_scenario][i] == (int)module) {
  1137. return i;
  1138. }
  1139. }
  1140. DDPDBG("find module: can not find module %s on scenario %s\n",ddp_get_module_name(module),
  1141. ddp_get_scenario_name(ddp_scenario));
  1142. return -1;
  1143. }
  1144. // set display interface when kernel init
  1145. int ddp_set_dst_module(DDP_SCENARIO_ENUM scenario, DISP_MODULE_ENUM dst_module)
  1146. {
  1147. int i = 0;
  1148. DDPMSG("ddp_set_dst_module, scenario=%s, dst_module=%s \n",
  1149. ddp_get_scenario_name(scenario), ddp_get_module_name(dst_module));
  1150. if (ddp_find_module_index(scenario,dst_module) > 0) {
  1151. DDPDBG("%s is already on path\n",ddp_get_module_name(dst_module));
  1152. return 0;
  1153. }
  1154. i = ddp_get_module_num_l(module_list_scenario[scenario])-1;
  1155. if (dst_module == DISP_MODULE_DSIDUAL) {
  1156. module_list_scenario[scenario][i++] = DISP_MODULE_SPLIT1;
  1157. ASSERT(i<DDP_ENING_NUM);
  1158. } else {
  1159. if (ddp_get_dst_module(scenario)==DISP_MODULE_DSIDUAL) {
  1160. module_list_scenario[scenario][i--] = -1;
  1161. }
  1162. }
  1163. module_list_scenario[scenario][i] = dst_module;
  1164. if (scenario == DDP_SCENARIO_PRIMARY_ALL) { //primary display
  1165. ddp_set_dst_module(DDP_SCENARIO_PRIMARY_DISP,dst_module);
  1166. ddp_set_dst_module(DDP_SCENARIO_PRIMARY_OVL_MEMOUT,dst_module);
  1167. } else if (scenario==DDP_SCENARIO_SUB_ALL) { //sub display
  1168. ddp_set_dst_module(DDP_SCENARIO_SUB_DISP,dst_module);
  1169. ddp_set_dst_module(DDP_SCENARIO_SUB_OVL_MEMOUT,dst_module);
  1170. }
  1171. ddp_print_scenario(scenario);
  1172. return 0;
  1173. }
  1174. DISP_MODULE_ENUM ddp_get_dst_module(DDP_SCENARIO_ENUM ddp_scenario)
  1175. {
  1176. DDPMSG("ddp_get_dst_module, scneario=%s, dst_module=%s \n",
  1177. ddp_get_scenario_name(ddp_scenario),
  1178. ddp_get_module_name(module_list_scenario[ddp_scenario][ddp_get_module_num_l(module_list_scenario[ddp_scenario])-1]));
  1179. return module_list_scenario[ddp_scenario][ddp_get_module_num_l(module_list_scenario[ddp_scenario])-1];
  1180. }
  1181. int * ddp_get_scenario_list(DDP_SCENARIO_ENUM ddp_scenario)
  1182. {
  1183. return module_list_scenario[ddp_scenario];
  1184. }
  1185. int ddp_insert_module(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM place, DISP_MODULE_ENUM module)
  1186. {
  1187. int i = DDP_ENING_NUM-1;
  1188. int idx = ddp_find_module_index(ddp_scenario,place);
  1189. if ( idx < 0) {
  1190. return -1;
  1191. }
  1192. //should not over load
  1193. ASSERT(module_list_scenario[ddp_scenario][i] == -1);
  1194. for (i=DDP_ENING_NUM-2; i>idx; i--) {
  1195. module_list_scenario[ddp_scenario][i+1] = module_list_scenario[ddp_scenario][i];
  1196. }
  1197. module_list_scenario[ddp_scenario][i] = module;
  1198. return 0;
  1199. }
  1200. int ddp_remove_module(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM module)
  1201. {
  1202. int i = 0;
  1203. int idx = ddp_find_module_index(ddp_scenario,module);
  1204. if ( idx < 0) {
  1205. return -1;
  1206. }
  1207. //should not over load
  1208. ASSERT(module_list_scenario[ddp_scenario][i] == -1);
  1209. for (i=idx; i<DDP_ENING_NUM-1; i++) {
  1210. module_list_scenario[ddp_scenario][i] = module_list_scenario[ddp_scenario][i+1];
  1211. }
  1212. module_list_scenario[ddp_scenario][i] = -1;
  1213. return 0;
  1214. }
  1215. void ddp_connect_path(DDP_SCENARIO_ENUM scenario, void * handle)
  1216. {
  1217. DDPDBG("path connect on scenario %s\n", ddp_get_scenario_name(scenario));
  1218. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  1219. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  1220. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT],handle);
  1221. } else if (scenario == DDP_SCENARIO_SUB_ALL) {
  1222. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_SUB_DISP], handle);
  1223. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_SUB_OVL_MEMOUT], handle);
  1224. } else if (scenario == DDP_SCENARIO_RDMA0_DUAL_DISP) {
  1225. ddp_set_dst_module(scenario,DISP_MODULE_DSI0);
  1226. ddp_connect_path_l(module_list_scenario[scenario], handle);
  1227. ddp_set_dst_module(scenario,DISP_MODULE_DSI1);
  1228. ddp_connect_path_l(module_list_scenario[scenario], handle);
  1229. ddp_set_dst_module(scenario,DISP_MODULE_DSIDUAL);
  1230. } else {
  1231. ddp_connect_path_l(module_list_scenario[scenario], handle);
  1232. }
  1233. return ;
  1234. }
  1235. void ddp_disconnect_path(DDP_SCENARIO_ENUM scenario,void * handle)
  1236. {
  1237. DDPDBG("path disconnect on scenario %s\n", ddp_get_scenario_name(scenario));
  1238. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  1239. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  1240. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT], handle);
  1241. } else if (scenario == DDP_SCENARIO_SUB_ALL) {
  1242. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_SUB_DISP], handle);
  1243. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_SUB_OVL_MEMOUT], handle);
  1244. } else if (scenario == DDP_SCENARIO_RDMA0_DUAL_DISP) {
  1245. ddp_set_dst_module(scenario,DISP_MODULE_DSI0);
  1246. ddp_disconnect_path_l(module_list_scenario[scenario], handle);
  1247. ddp_set_dst_module(scenario,DISP_MODULE_DSI1);
  1248. ddp_disconnect_path_l(module_list_scenario[scenario], handle);
  1249. ddp_set_dst_module(scenario,DISP_MODULE_DSIDUAL);
  1250. } else {
  1251. ddp_disconnect_path_l(module_list_scenario[scenario], handle);
  1252. }
  1253. return ;
  1254. }
  1255. void ddp_check_path(DDP_SCENARIO_ENUM scenario)
  1256. {
  1257. DDPDBG("path check path on scenario %s\n", ddp_get_scenario_name(scenario));
  1258. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  1259. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP]);
  1260. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT]);
  1261. } else if (scenario == DDP_SCENARIO_SUB_ALL) {
  1262. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_SUB_DISP]);
  1263. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_SUB_OVL_MEMOUT]);
  1264. } else if (scenario == DDP_SCENARIO_RDMA0_DUAL_DISP) {
  1265. ddp_set_dst_module(scenario,DISP_MODULE_DSI0);
  1266. ddp_check_path_l(module_list_scenario[scenario]);
  1267. ddp_set_dst_module(scenario,DISP_MODULE_DSI1);
  1268. ddp_check_path_l(module_list_scenario[scenario]);
  1269. ddp_set_dst_module(scenario,DISP_MODULE_DSIDUAL);
  1270. } else {
  1271. ddp_check_path_l(module_list_scenario[scenario]);
  1272. }
  1273. return ;
  1274. }
  1275. void ddp_check_mutex(int mutex_id, DDP_SCENARIO_ENUM scenario, DDP_MODE mode)
  1276. {
  1277. DDPDBG("check mutex %d on scenario %s\n",mutex_id,
  1278. ddp_get_scenario_name(scenario));
  1279. ddp_check_mutex_l(mutex_id,module_list_scenario[scenario],mode);
  1280. return ;
  1281. }
  1282. int ddp_mutex_set(int mutex_id,DDP_SCENARIO_ENUM scenario,DDP_MODE mode, void * handle)
  1283. {
  1284. return ddp_mutex_set_l(mutex_id, module_list_scenario[scenario],mode, handle);
  1285. }
  1286. int ddp_mutex_clear(int mutex_id, void * handle)
  1287. {
  1288. DDPDBG("mutex %d clear\n", mutex_id);
  1289. DISP_REG_SET(handle,DISP_REG_CONFIG_MUTEX_MOD(mutex_id),0);
  1290. DISP_REG_SET(handle,DISP_REG_CONFIG_MUTEX_SOF(mutex_id),0);
  1291. return 0;
  1292. }
  1293. int ddp_mutex_enable(int mutex_id,DDP_SCENARIO_ENUM scenario,void * handle)
  1294. {
  1295. return ddp_mutex_enable_l(mutex_id, handle);
  1296. }
  1297. int ddp_mutex_disenable(int mutex_id,DDP_SCENARIO_ENUM scenario,void * handle)
  1298. {
  1299. DDPDBG("mutex %d disable\n", mutex_id);
  1300. DISP_REG_SET(handle,DISP_REG_CONFIG_MUTEX_EN(mutex_id),0);
  1301. return 0;
  1302. }
  1303. int ddp_check_engine_status(int mutexID)
  1304. {
  1305. // check engines' clock bit & enable bit & status bit before unlock mutex
  1306. // should not needed, in comdq do?
  1307. int result = 0;
  1308. return result;
  1309. }
  1310. int ddp_path_top_clock_on(void)
  1311. {
  1312. DDPMSG("ddp path top clock on\n");
  1313. DISP_REG_SET(NULL,DISP_REG_CONFIG_MMSYS_DUMMY,0xFFFFFFFF);
  1314. ddp_enable_module_clock(DISP_MODULE_SMI);
  1315. ddp_enable_module_clock(DISP_MODULE_MUTEX);
  1316. DDPMSG("ddp CG:%x\n", DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0));
  1317. return 0;
  1318. }
  1319. int ddp_path_top_clock_off(void)
  1320. {
  1321. DDPMSG("ddp path top clock off\n");
  1322. ddp_disable_module_clock(DISP_MODULE_MUTEX);
  1323. ddp_disable_module_clock(DISP_MODULE_SMI);
  1324. return 0;
  1325. }
  1326. int ddp_path_m4u_off(void)
  1327. {
  1328. DDPMSG("ddp path m4u off\n");
  1329. #ifdef MTKFB_NO_M4U
  1330. DISP_REG_SET(0,DISP_REG_SMI_LARB_MMU_EN,0x0);//m4u disable
  1331. #endif
  1332. return 0;
  1333. }