ddp_path.c 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695
  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_reg_pq.h"
  37. #include "platform/ddp_path.h"
  38. #include "platform/ddp_info.h"
  39. #include "platform/ddp_log.h"
  40. #include "platform/spm.h"
  41. extern ddp_module ddp_modules[DISP_MODULE_NUM];
  42. #define DDP_ENING_NUM (20) /* max module num of path */
  43. #define DDP_MOUT_MAX 8
  44. #define DDP_SOUT_MAX 8
  45. #define DDP_MUTEX_MAX 4
  46. /* struct for mutex mod */
  47. typedef struct module_map_s {
  48. DISP_MODULE_ENUM module;
  49. int bit;
  50. int mod_num;
  51. } module_map_t;
  52. typedef struct {
  53. int m;
  54. int v;
  55. } m_to_b;
  56. typedef struct mout_s {
  57. int id;
  58. m_to_b out_id_bit_map[DDP_MOUT_MAX];
  59. volatile unsigned long *reg;
  60. unsigned int reg_val;
  61. } mout_t;
  62. typedef struct selection_s {
  63. int id;
  64. int id_bit_map[DDP_SOUT_MAX];
  65. volatile unsigned long *reg;
  66. unsigned int reg_val;
  67. } sel_t;
  68. int primary_disp_dsc_module_list[DDP_ENING_NUM] = {
  69. DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0, DISP_MODULE_OVL0_VIRTUAL0,
  70. DISP_MODULE_RDMA0, DISP_MODULE_RDMA0_VIRTUAL0,
  71. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0,
  72. #ifdef MTK_DRE30_SUPPORT
  73. DISP_MODULE_MDP_AAL4,
  74. #endif
  75. DISP_MODULE_AAL0, DISP_MODULE_GAMMA0,
  76. DISP_MODULE_POSTMASK0, DISP_MODULE_DITHER0,
  77. DISP_MODULE_DITHER0_VIRTUAL0, DISP_MODULE_DSC_VIRTUAL0, DISP_MODULE_DSC,
  78. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  79. -1,
  80. };
  81. int module_list_scenario[DDP_SCENARIO_MAX][DDP_ENING_NUM] = {
  82. /* DDP_SCENARIO_PRIMARY_DISP */
  83. {
  84. DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0, DISP_MODULE_OVL0_VIRTUAL0,
  85. DISP_MODULE_RDMA0, DISP_MODULE_RDMA0_VIRTUAL0,
  86. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0,
  87. #ifdef MTK_DRE30_SUPPORT
  88. DISP_MODULE_MDP_AAL4,
  89. #endif
  90. DISP_MODULE_AAL0, DISP_MODULE_GAMMA0,
  91. DISP_MODULE_POSTMASK0, DISP_MODULE_DITHER0,
  92. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  93. -1,
  94. },
  95. /* DDP_SCENARIO_PRIMARY_BYPASS_PQ_DISP */
  96. {
  97. DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0,
  98. DISP_MODULE_OVL0_VIRTUAL0,
  99. DISP_MODULE_RDMA0, DISP_MODULE_RDMA0_VIRTUAL0,
  100. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  101. -1,
  102. },
  103. /* DDP_SCENARIO_PRIMARY_RDMA0_COLOR0_DISP0 */
  104. {
  105. DISP_MODULE_RDMA0, DISP_MODULE_RDMA0_VIRTUAL0,
  106. #ifdef DISP_COLOR_ON
  107. DISP_MODULE_COLOR0,
  108. #endif
  109. DISP_MODULE_CCORR0, DISP_MODULE_MDP_AAL4,
  110. DISP_MODULE_AAL0, DISP_MODULE_GAMMA0,
  111. DISP_MODULE_POSTMASK0, DISP_MODULE_DITHER0,
  112. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  113. -1,
  114. },
  115. /* DDP_SCENARIO_PRIMARY_RDMA0_DISP */
  116. {
  117. DISP_MODULE_RDMA0, DISP_MODULE_RDMA0_VIRTUAL0,
  118. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  119. -1,
  120. },
  121. /* DDP_SCENARIO_PRIMARY_OVL_MEMOUT */
  122. {
  123. DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0,
  124. DISP_MODULE_OVL0_VIRTUAL0,
  125. DISP_MODULE_WDMA0,
  126. -1,
  127. },
  128. /* DDP_SCENARIO_PRIMARY0_DISP0_MDP_AAL4 */
  129. {
  130. DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0,
  131. DISP_MODULE_OVL0_VIRTUAL0,
  132. DISP_MODULE_RDMA0, DISP_MODULE_RDMA0_VIRTUAL0,
  133. #ifdef DISP_COLOR_ON
  134. DISP_MODULE_COLOR0,
  135. #endif
  136. DISP_MODULE_CCORR0, DISP_MODULE_MDP_AAL4,
  137. DISP_MODULE_AAL0, DISP_MODULE_GAMMA0,
  138. DISP_MODULE_POSTMASK0, DISP_MODULE_DITHER0,
  139. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  140. -1,
  141. },
  142. /* DDP_SCENARIO_PRIMARY0_OVL_PQ_MEMOUT */
  143. {
  144. DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0,
  145. DISP_MODULE_OVL0_VIRTUAL0,
  146. DISP_MODULE_RDMA0, DISP_MODULE_RDMA0_VIRTUAL0,
  147. #ifdef DISP_COLOR_ON
  148. DISP_MODULE_COLOR0,
  149. #endif
  150. DISP_MODULE_CCORR0, DISP_MODULE_MDP_AAL4,
  151. DISP_MODULE_AAL0, DISP_MODULE_GAMMA0,
  152. DISP_MODULE_POSTMASK0, DISP_MODULE_DITHER0,
  153. DISP_MODULE_WDMA0, -1,
  154. },
  155. /* DDP_SCENARIO_PRIMARY_ALL */
  156. {
  157. DISP_MODULE_OVL0_2L, DISP_MODULE_OVL0,
  158. DISP_MODULE_OVL0_VIRTUAL0,
  159. DISP_MODULE_WDMA0,
  160. DISP_MODULE_RDMA0, DISP_MODULE_RDMA0_VIRTUAL0,
  161. #ifdef DISP_COLOR_ON
  162. DISP_MODULE_COLOR0,
  163. #endif
  164. DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0,
  165. DISP_MODULE_POSTMASK0, DISP_MODULE_DITHER0,
  166. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  167. -1,
  168. },
  169. /* DDP_SCENARIO_SUB_DISP */
  170. {
  171. DISP_MODULE_OVL0_2L, DISP_MODULE_DPI,
  172. -1,
  173. },
  174. /* DDP_SCENARIO_SUB_RDMA1_DISP */
  175. {
  176. DISP_MODULE_DPI,
  177. -1,
  178. },
  179. /* DDP_SCENARIO_SUB_OVL2_2L_MEMOUT */
  180. {
  181. DISP_MODULE_OVL2_2L, DISP_MODULE_WDMA0,
  182. -1,
  183. },
  184. /* DDP_SCENARIO_SUB_ALL */
  185. {
  186. DISP_MODULE_OVL0_2L, DISP_MODULE_WDMA0,
  187. DISP_MODULE_DPI,
  188. -1,
  189. },
  190. /* DDP_SCENARIO_PRIMARY1_DISP */
  191. {
  192. DISP_MODULE_OVL1, DISP_MODULE_OVL1_2L,
  193. DISP_MODULE_OVL1_VIRTUAL0,
  194. DISP_MODULE_RDMA1, DISP_MODULE_RDMA1_VIRTUAL0,
  195. #if 0
  196. #ifdef DISP_COLOR_ON
  197. DISP_MODULE_COLOR0,
  198. #endif
  199. DISP_MODULE_CCORR0, DISP_MODULE_AAL0, DISP_MODULE_GAMMA0,
  200. DISP_MODULE_POSTMASK0, DISP_MODULE_DITHER0,
  201. #endif
  202. DISP_MODULE_PWM0, DISP_MODULE_DSI1,
  203. -1,
  204. },
  205. /* DDP_SCENARIO_PRIMARY_RDMA1_COLOR1_DISP1 */
  206. {
  207. DISP_MODULE_RDMA1, DISP_MODULE_RDMA1_VIRTUAL0,
  208. #ifdef DISP_COLOR_ON
  209. DISP_MODULE_COLOR1,
  210. #endif
  211. DISP_MODULE_CCORR1, DISP_MODULE_MDP_AAL5,
  212. DISP_MODULE_AAL1, DISP_MODULE_GAMMA1,
  213. DISP_MODULE_POSTMASK1, DISP_MODULE_DITHER1,
  214. DISP_MODULE_PWM0, DISP_MODULE_DSI1,
  215. -1,
  216. },
  217. /* DDP_SCENARIO_PRIMARY_RDMA1_COLOR1_DISP0 */
  218. {
  219. DISP_MODULE_RDMA1, DISP_MODULE_RDMA1_VIRTUAL0,
  220. #ifdef DISP_COLOR_ON
  221. DISP_MODULE_COLOR1,
  222. #endif
  223. DISP_MODULE_CCORR1, DISP_MODULE_MDP_AAL5,
  224. DISP_MODULE_AAL1, DISP_MODULE_GAMMA1,
  225. DISP_MODULE_POSTMASK1, DISP_MODULE_DITHER1,
  226. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  227. -1,
  228. },
  229. /* DDP_SCENARIO_PRIMARY1_OVL_MEMOUT */
  230. {
  231. DISP_MODULE_OVL1, DISP_MODULE_OVL1_2L,
  232. DISP_MODULE_OVL1_VIRTUAL0,
  233. DISP_MODULE_WDMA1,
  234. -1,
  235. },
  236. /* DDP_SCENARIO_PRIMARY1_DISP0_MDP_AAL5 */
  237. {
  238. DISP_MODULE_OVL1, DISP_MODULE_OVL1_2L,
  239. DISP_MODULE_OVL1_VIRTUAL0,
  240. DISP_MODULE_RDMA1, DISP_MODULE_RDMA1_VIRTUAL0,
  241. #ifdef DISP_COLOR_ON
  242. DISP_MODULE_COLOR1,
  243. #endif
  244. DISP_MODULE_CCORR1, DISP_MODULE_MDP_AAL5,
  245. DISP_MODULE_AAL1, DISP_MODULE_GAMMA1,
  246. DISP_MODULE_POSTMASK1, DISP_MODULE_DITHER1,
  247. DISP_MODULE_PWM0, DISP_MODULE_DSI0,
  248. -1,
  249. },
  250. /* DDP_SCENARIO_PRIMARY1_ALL */
  251. {
  252. DISP_MODULE_OVL1, DISP_MODULE_OVL1_2L,
  253. DISP_MODULE_OVL1_VIRTUAL0,
  254. DISP_MODULE_WDMA1,
  255. DISP_MODULE_RDMA1, DISP_MODULE_RDMA1_VIRTUAL0,
  256. #ifdef DISP_COLOR_ON
  257. DISP_MODULE_COLOR1,
  258. #endif
  259. DISP_MODULE_CCORR1, DISP_MODULE_AAL1, DISP_MODULE_GAMMA1,
  260. DISP_MODULE_POSTMASK1, DISP_MODULE_DITHER1,
  261. DISP_MODULE_PWM0, DISP_MODULE_DSI1,
  262. -1,
  263. },
  264. };
  265. /* 1st para is mout's input, 2nd para is mout's output */
  266. static mout_t mout_map[] = {
  267. /* DISP_TOVL0_OUT0_MOUT_EN */
  268. {DISP_MODULE_OVL0_2L_VIRTUAL0,
  269. {{DISP_MODULE_WDMA0, 1 << 0},
  270. {DISP_MODULE_RSZ0, 1 << 1}, {-1, 0} },
  271. 0, 0},
  272. /* DISP_TOVL0_OUT1_MOUT_EN */
  273. {DISP_MODULE_OVL0_VIRTUAL0,
  274. {{DISP_MODULE_RDMA0, 1 << 0},
  275. {DISP_MODULE_RSZ0, 1 << 1},
  276. {DISP_MODULE_WDMA0, 1 << 2}, {-1, 0} },
  277. 0, 0},
  278. /* DISP_RSZ0_MOUT_EN */
  279. {DISP_MODULE_RSZ0,
  280. {{DISP_MODULE_RDMA0, 1 << 0},
  281. {DISP_MODULE_WDMA0, 1 << 1},
  282. {DISP_MODULE_RDMA0_VIRTUAL0, 1 << 2}, {-1, 0} },
  283. 0, 0},
  284. /* DISP_DITHER0_MOUT_EN */
  285. {DISP_MODULE_DITHER0,
  286. {{DISP_MODULE_DSI0, 1 << 0},
  287. {DISP_MODULE_WDMA0, 1 << 1},
  288. {DISP_MODULE_DSI1, 1 << 2},
  289. {DISP_MODULE_DITHER0_VIRTUAL0, 1 << 3}, {-1, 0} },
  290. 0, 0},
  291. /* DISP_TOVL1_OUT0_MOUT_EN */
  292. {DISP_MODULE_OVL1_2L_VIRTUAL0,
  293. {{DISP_MODULE_WDMA1, 1 << 0},
  294. {DISP_MODULE_RSZ1, 1 << 1}, {-1, 0} },
  295. 0, 0},
  296. /* DISP_TOVL1_OUT1_MOUT_EN */
  297. {DISP_MODULE_OVL1_VIRTUAL0,
  298. {{DISP_MODULE_RDMA1, 1 << 0},
  299. {DISP_MODULE_RSZ1, 1 << 1},
  300. {DISP_MODULE_WDMA1, 1 << 2}, {-1, 0} },
  301. 0, 0},
  302. /* DISP_RSZ1_MOUT_EN */
  303. {DISP_MODULE_RSZ1,
  304. {{DISP_MODULE_RDMA1, 1 << 0},
  305. {DISP_MODULE_WDMA1, 1 << 1},
  306. {DISP_MODULE_RDMA1_VIRTUAL0, 1 << 2}, {-1, 0} },
  307. 0, 0},
  308. /* DISP_DITHER1_MOUT_EN */
  309. {DISP_MODULE_DITHER1,
  310. {{DISP_MODULE_DSI1, 1 << 0},
  311. {DISP_MODULE_WDMA1, 1 << 1}, {-1, 0} },
  312. 0, 0},
  313. /* DISP_OVL2_2L_OUT0_MOUT_EN */
  314. {DISP_MODULE_OVL2_2L,
  315. {{DISP_MODULE_RDMA4, 1 << 0},
  316. {DISP_MODULE_WDMA0, 1 << 1}, {-1, 0} },
  317. 0, 0},
  318. /* DISP_OVL3_2L_OUT0_MOUT_EN */
  319. {DISP_MODULE_OVL3_2L,
  320. {{DISP_MODULE_RDMA5, 1 << 0},
  321. {DISP_MODULE_WDMA1, 1 << 1}, {-1, 0} },
  322. 0, 0},
  323. };
  324. static sel_t sel_out_map[] = {
  325. /* DISP_OVL0_2L_BLENDOUT_SOUT_SEL */
  326. {DISP_MODULE_OVL0_2L, {DISP_MODULE_OVL0_2L_VIRTUAL0,
  327. DISP_MODULE_OVL0_VIRTUAL0, -1}, 0, 0},
  328. /* DISP_OVL0_BLENDOUT_SOUT_SEL */
  329. {DISP_MODULE_OVL0, {DISP_MODULE_OVL0_2L_VIRTUAL0,
  330. DISP_MODULE_OVL0_VIRTUAL0, -1}, 0, 0},
  331. /* DISP_RDMA0_SOUT_SEL */
  332. {DISP_MODULE_RDMA0, {DISP_MODULE_RDMA0_VIRTUAL0,
  333. DISP_MODULE_RSZ0, -1}, 0, 0},
  334. /* DISP_RDMA0_RSZ0_SOUT_SEL */
  335. {DISP_MODULE_RDMA0_VIRTUAL0, {DISP_MODULE_DSI0,
  336. DISP_MODULE_COLOR0, DISP_MODULE_CCORR0, -1}, 0, 0},
  337. /* DISP_CCORR0_SOUT_SEL */
  338. {DISP_MODULE_CCORR0, {DISP_MODULE_MDP_AAL4,
  339. DISP_MODULE_AAL0, -1}, 0, 0},
  340. /* DISP_MDP_AAL4_SOUT_SEL */
  341. {DISP_MODULE_MDP_AAL4, {DISP_MODULE_AAL0,
  342. -1}, 0, 0},
  343. /* DISP_OVL1_2L_BLENDOUT_SOUT_SEL */
  344. {DISP_MODULE_OVL1_2L, {DISP_MODULE_OVL1_2L_VIRTUAL0,
  345. DISP_MODULE_OVL1_VIRTUAL0, -1}, 0, 0},
  346. /* DISP_OVL1_BLENDOUT_SOUT_SEL */
  347. {DISP_MODULE_OVL1, {DISP_MODULE_OVL1_2L_VIRTUAL0,
  348. DISP_MODULE_OVL1_VIRTUAL0, -1}, 0, 0},
  349. /* DISP_RDMA1_SOUT_SEL */
  350. {DISP_MODULE_RDMA1, {DISP_MODULE_RDMA1_VIRTUAL0,
  351. DISP_MODULE_RSZ1, -1}, 0, 0},
  352. /* DISP_RDMA1_RSZ1_SOUT_SEL */
  353. {DISP_MODULE_RDMA1_VIRTUAL0, {DISP_MODULE_DSI1,
  354. DISP_MODULE_COLOR1, DISP_MODULE_CCORR1, -1}, 0, 0},
  355. /* DISP_CCORR1_SOUT_SEL */
  356. {DISP_MODULE_CCORR1, {DISP_MODULE_MDP_AAL5,
  357. DISP_MODULE_AAL1, -1}, 0, 0},
  358. /* DISP_MDP_AAL5_SOUT_SEL */
  359. {DISP_MODULE_MDP_AAL5, {DISP_MODULE_AAL1,
  360. -1}, 0, 0},
  361. /* DISP_DSC_WRAP_SOUT_SEL */
  362. {DISP_MODULE_DSC, {DISP_MODULE_DSI0, -1}, 0, 0},
  363. /* DISP_DSI0_DSC_WRAP_SOUT_SEL */
  364. {DISP_MODULE_DSC_VIRTUAL0, {DISP_MODULE_UNKNOWN,
  365. DISP_MODULE_DSC, -1}, 0, 0},
  366. /* DISP_DSI0_DSC_WRAP_SOUT_SEL */
  367. {DISP_MODULE_DITHER0_VIRTUAL0, {DISP_MODULE_UNKNOWN,
  368. DISP_MODULE_DSC_VIRTUAL0, -1}, 0, 0},
  369. };
  370. /* 1st para is sout's output, 2nd para is sout's input */
  371. static sel_t sel_in_map[] = {
  372. /* DISP_OVL0_OVL1_OVL1_2L_BGOUT_SEL_IN */
  373. {DISP_MODULE_OVL0_2L, {DISP_MODULE_UNKNOWN, DISP_MODULE_OVL0,
  374. -1},
  375. 0, 0},
  376. /* DISP_OVL0_2L_OVL1_OVL1_2L_BGOUT_SEL_IN */
  377. {DISP_MODULE_OVL0, {DISP_MODULE_UNKNOWN, DISP_MODULE_OVL0_2L,
  378. -1}, 0, 0},
  379. /* DISP_TOVL0_OUT0_SEL_IN */
  380. {DISP_MODULE_OVL0_2L_VIRTUAL0, {DISP_MODULE_OVL0_2L,
  381. DISP_MODULE_OVL0, -1}, 0, 0},
  382. /* DISP_TOVL0_OUT1_SEL_IN */
  383. {DISP_MODULE_OVL0_VIRTUAL0, {DISP_MODULE_OVL0_2L,
  384. DISP_MODULE_OVL0, -1}, 0, 0},
  385. /* DISP_RDMA0_SEL_IN */
  386. {DISP_MODULE_RDMA0, {DISP_MODULE_OVL0_VIRTUAL0,
  387. DISP_MODULE_RSZ0, -1},
  388. 0, 0},
  389. /* DISP_RSZ0_SEL_IN */
  390. {DISP_MODULE_RSZ0, {DISP_MODULE_OVL0_2L_VIRTUAL0,
  391. DISP_MODULE_OVL0_VIRTUAL0, DISP_MODULE_RDMA0, -1}, 0, 0},
  392. /* DISP_RDMA0_RSZ0_SEL_IN */
  393. {DISP_MODULE_RDMA0_VIRTUAL0, {DISP_MODULE_RDMA0,
  394. DISP_MODULE_RSZ0, -1}, 0, 0},
  395. /* DISP_COLOR0_OUT_SEL_IN */
  396. {DISP_MODULE_CCORR0, {DISP_MODULE_COLOR0,
  397. DISP_MODULE_RDMA0_VIRTUAL0, -1}, 0, 0},
  398. /* DISP_MDP_AAL4_SEL_IN */
  399. {DISP_MODULE_MDP_AAL4, {DISP_MODULE_CCORR0,
  400. -1}, 0, 0},
  401. /* DISP_AAL0_SEL_IN */
  402. {DISP_MODULE_AAL0, {DISP_MODULE_MDP_AAL4,
  403. DISP_MODULE_CCORR0, -1}, 0, 0},
  404. /* DSI0_SEL_IN */
  405. {DISP_MODULE_DSI0, {DISP_MODULE_RDMA0_VIRTUAL0,
  406. DISP_MODULE_DITHER0, DISP_MODULE_UNKNOWN, DISP_MODULE_DSC, -1}, 0, 0},
  407. /* DISP_WDMA0_SEL_IN */
  408. {DISP_MODULE_WDMA0, {DISP_MODULE_DITHER0,
  409. DISP_MODULE_RSZ0, DISP_MODULE_OVL0_2L_VIRTUAL0,
  410. DISP_MODULE_OVL0_VIRTUAL0, DISP_MODULE_OVL2_2L, -1}, 0, 0},
  411. /* DISP_OVL1_OVL1_OVL1_2L_BGOUT_SEL_IN */
  412. {DISP_MODULE_OVL1_2L, {DISP_MODULE_UNKNOWN, DISP_MODULE_OVL1,
  413. -1},
  414. 0, 0},
  415. /* DISP_OVL0_2L_OVL1_OVL1_2L_BGOUT_SEL_IN */
  416. {DISP_MODULE_OVL1, {DISP_MODULE_UNKNOWN, DISP_MODULE_OVL1_2L,
  417. -1}, 0, 0},
  418. /* DISP_TOVL1_OUT0_SEL_IN */
  419. {DISP_MODULE_OVL1_2L_VIRTUAL0, {DISP_MODULE_OVL1_2L,
  420. DISP_MODULE_OVL1, -1}, 0, 0},
  421. /* DISP_TOVL1_OUT1_SEL_IN */
  422. {DISP_MODULE_OVL1_VIRTUAL0, {DISP_MODULE_OVL1_2L,
  423. DISP_MODULE_OVL1, -1}, 0, 0},
  424. /* DISP_RDMA1_SEL_IN */
  425. {DISP_MODULE_RDMA1, {DISP_MODULE_OVL1_VIRTUAL0,
  426. DISP_MODULE_RSZ1, -1},
  427. 0, 0},
  428. /* DISP_RSZ1_SEL_IN */
  429. {DISP_MODULE_RSZ1, {DISP_MODULE_OVL1_2L_VIRTUAL0,
  430. DISP_MODULE_OVL1_VIRTUAL0, DISP_MODULE_RDMA1, -1}, 0, 0},
  431. /* DISP_RDMA0_RSZ1_SEL_IN */
  432. {DISP_MODULE_RDMA1_VIRTUAL0, {DISP_MODULE_RDMA1,
  433. DISP_MODULE_RSZ1, -1}, 0, 0},
  434. /* DISP_COLOR0_OUT_SEL_IN */
  435. {DISP_MODULE_CCORR1, {DISP_MODULE_COLOR1,
  436. DISP_MODULE_RDMA1_VIRTUAL0, -1}, 0, 0},
  437. /* DISP_MDP_AAL5_SEL_IN */
  438. {DISP_MODULE_MDP_AAL5, {DISP_MODULE_CCORR1,
  439. -1}, 0, 0},
  440. /* DISP_AAL1_SEL_IN */
  441. {DISP_MODULE_AAL1, {DISP_MODULE_MDP_AAL5,
  442. DISP_MODULE_CCORR1, -1}, 0, 0},
  443. /* DSI1_SEL_IN */
  444. {DISP_MODULE_DSI1, {DISP_MODULE_RDMA1_VIRTUAL0,
  445. DISP_MODULE_DITHER1, -1}, 0, 0},
  446. /* DISP_WDMA1_SEL_IN */
  447. {DISP_MODULE_WDMA1, {DISP_MODULE_DITHER1,
  448. DISP_MODULE_RSZ1, DISP_MODULE_OVL1_2L_VIRTUAL0,
  449. DISP_MODULE_OVL1_VIRTUAL0, -1}, 0, 0},
  450. /* DISP_RDMA4_PQ0_MERGE0_SEL_IN */
  451. {DISP_MODULE_DSC_VIRTUAL0, {DISP_MODULE_RDMA4,
  452. DISP_MODULE_DITHER0_VIRTUAL0, -1}, 0, 0},
  453. };
  454. int ddp_path_init(void)
  455. {
  456. int i;
  457. /* mout */
  458. mout_map[0].reg = (unsigned long *)DISP_REG_CONFIG_DISP_TOVL0_OUT0_MOUT_EN;
  459. mout_map[1].reg = (unsigned long *)DISP_REG_CONFIG_DISP_TOVL0_OUT1_MOUT_EN;
  460. mout_map[2].reg = (unsigned long *)DISP_REG_CONFIG_DISP_RSZ0_MOUT_EN;
  461. mout_map[3].reg = (unsigned long *)DISP_REG_CONFIG_DISP_DITHER0_MOUT_EN;
  462. mout_map[4].reg = (unsigned long *)DISP_REG_CONFIG_DISP_TOVL1_OUT0_MOUT_EN;
  463. mout_map[5].reg = (unsigned long *)DISP_REG_CONFIG_DISP_TOVL1_OUT1_MOUT_EN;
  464. mout_map[6].reg = (unsigned long *)DISP_REG_CONFIG_DISP_RSZ1_MOUT_EN;
  465. mout_map[7].reg = (unsigned long *)DISP_REG_CONFIG_DISP_DITHER1_MOUT_EN;
  466. mout_map[8].reg = (unsigned long *)DISP_REG_CONFIG_DISP_OVL2_2L_OUT0_MOUT_EN;
  467. mout_map[9].reg = (unsigned long *)DISP_REG_CONFIG_DISP_OVL3_2L_OUT0_MOUT_EN;
  468. /* sel_out */
  469. sel_out_map[0].reg =
  470. (unsigned long *)DISP_REG_CONFIG_DISP_OVL0_2L_BLENDOUT_SOUT_SEL;
  471. sel_out_map[1].reg =
  472. (unsigned long *)DISP_REG_CONFIG_DISP_OVL0_BLENDOUT_SOUT_SEL;
  473. sel_out_map[2].reg =
  474. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA0_SOUT_SEL;
  475. sel_out_map[3].reg =
  476. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA0_RSZ0_SOUT_SEL;
  477. sel_out_map[4].reg =
  478. (unsigned long *)DISP_REG_CONFIG_DISP_CCORR0_SOUT_SEL;
  479. sel_out_map[5].reg =
  480. (unsigned long *)DISP_REG_CONFIG_DISP_MDP_AAL4_SOUT_SEL;
  481. sel_out_map[6].reg =
  482. (unsigned long *)DISP_REG_CONFIG_DISP_OVL1_2L_BLENDOUT_SOUT_SEL;
  483. sel_out_map[7].reg =
  484. (unsigned long *)DISP_REG_CONFIG_DISP_OVL1_BLENDOUT_SOUT_SEL;
  485. sel_out_map[8].reg =
  486. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA1_SOUT_SEL;
  487. sel_out_map[9].reg =
  488. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA1_RSZ1_SOUT_SEL;
  489. sel_out_map[10].reg =
  490. (unsigned long *)DISP_REG_CONFIG_DISP_CCORR1_SOUT_SEL;
  491. sel_out_map[11].reg =
  492. (unsigned long *)DISP_REG_CONFIG_DISP_MDP_AAL5_SOUT_SEL;
  493. sel_out_map[12].reg =
  494. (unsigned long *)DISP_REG_CONFIG_DISP_DSC_WRAP_SOUT_SEL;
  495. sel_out_map[13].reg =
  496. (unsigned long *)DISP_REG_CONFIG_DISP_DSI0_DSC_WRAP_SOUT_SEL;
  497. sel_out_map[14].reg =
  498. (unsigned long *)DISP_REG_CONFIG_DISP_PQ0_SOUT_SEL;
  499. /* sel_in */
  500. sel_in_map[0].reg =
  501. (unsigned long *)DISP_REG_CONFIG_DISP_O0_O1_OVL1_2L_BG_SEL;
  502. sel_in_map[1].reg =
  503. (unsigned long *)DISP_REG_CONFIG_DISP_O0_2L_O1_OVL1_2L_BG_SEL;
  504. sel_in_map[2].reg =
  505. (unsigned long *)DISP_REG_CONFIG_DISP_TOVL0_OUT0_SEL_IN;
  506. sel_in_map[3].reg =
  507. (unsigned long *)DISP_REG_CONFIG_DISP_TOVL0_OUT1_SEL_IN;
  508. sel_in_map[4].reg =
  509. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA0_SEL_IN;
  510. sel_in_map[5].reg =
  511. (unsigned long *)DISP_REG_CONFIG_DISP_RSZ0_SEL_IN;
  512. sel_in_map[6].reg =
  513. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA0_RSZ0_SEL_IN;
  514. sel_in_map[7].reg =
  515. (unsigned long *)DISP_REG_CONFIG_DISP_COLOR0_OUT_SEL_IN;
  516. sel_in_map[8].reg =
  517. (unsigned long *)DISP_REG_CONFIG_DISP_MDP_AAL4_SEL_IN;
  518. sel_in_map[9].reg =
  519. (unsigned long *)DISP_REG_CONFIG_DISP_AAL0_SEL_IN;
  520. sel_in_map[10].reg =
  521. (unsigned long *)DISP_REG_CONFIG_DSI0_SEL_IN;
  522. sel_in_map[11].reg =
  523. (unsigned long *)DISP_REG_CONFIG_DISP_WDMA0_SEL_IN;
  524. sel_in_map[12].reg =
  525. (unsigned long *)DISP_REG_CONFIG_DISP_OVL1_BGOUT_SOUT_SEL;
  526. sel_in_map[13].reg =
  527. (unsigned long *)DISP_REG_CONFIG_DISP_OVL1_OVL1_2L_BGOUT_SEL_IN;
  528. sel_in_map[14].reg =
  529. (unsigned long *)DISP_REG_CONFIG_DISP_TOVL1_OUT0_SEL_IN;
  530. sel_in_map[15].reg =
  531. (unsigned long *)DISP_REG_CONFIG_DISP_TOVL1_OUT1_SEL_IN;
  532. sel_in_map[16].reg =
  533. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA1_SEL_IN;
  534. sel_in_map[17].reg =
  535. (unsigned long *)DISP_REG_CONFIG_DISP_RSZ1_SEL_IN;
  536. sel_in_map[18].reg =
  537. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA1_RSZ1_SEL_IN;
  538. sel_in_map[19].reg =
  539. (unsigned long *)DISP_REG_CONFIG_DISP_COLOR1_OUT_SEL_IN;
  540. sel_in_map[20].reg =
  541. (unsigned long *)DISP_REG_CONFIG_DISP_MDP_AAL5_SEL_IN;
  542. sel_in_map[21].reg =
  543. (unsigned long *)DISP_REG_CONFIG_MDP_AAL1_SEL_IN;
  544. sel_in_map[22].reg =
  545. (unsigned long *)DISP_REG_CONFIG_DSI1_SEL_IN;
  546. sel_in_map[23].reg =
  547. (unsigned long *)DISP_REG_CONFIG_DISP_WDMA1_SEL_IN;
  548. sel_in_map[24].reg =
  549. (unsigned long *)DISP_REG_CONFIG_DISP_RDMA4_PQ0_MERGE0_SEL_IN;
  550. for (i = 0; i < 16; i++) {
  551. DISP_REG_SET_FIELD(NULL, REG_FLD_MMU_EN,
  552. DISP_REG_SMI_LARB0_NON_SEC_CON + i * 4, 0x0);
  553. DISP_REG_SET_FIELD(NULL, REG_FLD_MMU_EN,
  554. DISP_REG_SMI_LARB1_NON_SEC_CON + i * 4, 0x0);
  555. }
  556. return 0;
  557. }
  558. static module_map_t module_mutex_map[DISP_MODULE_NUM] = {
  559. {DISP_MODULE_OVL0, 0, 0},
  560. {DISP_MODULE_OVL0_2L, 1, 0},
  561. {DISP_MODULE_OVL0_2L_VIRTUAL0, -1, 0},
  562. {DISP_MODULE_OVL0_VIRTUAL0, -1, 0},
  563. {DISP_MODULE_RSZ0, 10, 0},
  564. {DISP_MODULE_OVL1, 12, 0},
  565. {DISP_MODULE_OVL1_2L, 13, 0},
  566. {DISP_MODULE_OVL1_2L_VIRTUAL0, -1, 0},
  567. {DISP_MODULE_OVL1_VIRTUAL0, -1, 0},
  568. {DISP_MODULE_RSZ1, 22, 0},
  569. {DISP_MODULE_RDMA0, 2, 0},
  570. {DISP_MODULE_RDMA0_VIRTUAL0, -1, 0},
  571. {DISP_MODULE_WDMA0, 3, 0},
  572. {DISP_MODULE_COLOR0, 4, 0},
  573. {DISP_MODULE_CCORR0, 5, 0},
  574. {DISP_MODULE_RDMA1, 14, 0},
  575. {DISP_MODULE_RDMA1_VIRTUAL0, -1, 0},
  576. {DISP_MODULE_WDMA1, 15, 0},
  577. {DISP_MODULE_COLOR1, 16, 0},
  578. {DISP_MODULE_CCORR1, 17, 0},
  579. {DISP_MODULE_AAL0, 6, 0},
  580. {DISP_MODULE_MDP_AAL4, 0, 1},
  581. {DISP_MODULE_GAMMA0, 7, 0},
  582. {DISP_MODULE_POSTMASK0, 25, 0},
  583. {DISP_MODULE_DITHER0, 8, 0},
  584. {DISP_MODULE_DITHER0_VIRTUAL0, -1, 0},
  585. {DISP_MODULE_AAL1, 18, 0},
  586. {DISP_MODULE_MDP_AAL5, 1, 1},
  587. {DISP_MODULE_GAMMA1, 19, 0},
  588. {DISP_MODULE_POSTMASK1, 26, 0},
  589. {DISP_MODULE_DITHER1, 20, 0},
  590. {DISP_MODULE_SPLIT0, -1, 0},
  591. {DISP_MODULE_DSI0, 9, 0},
  592. {DISP_MODULE_DSI1, 21, 0},
  593. {DISP_MODULE_DSIDUAL, -1, 0},
  594. {DISP_MODULE_PWM0, 11, 0},
  595. {DISP_MODULE_CONFIG, -1, 0},
  596. {DISP_MODULE_MUTEX, -1, 0},
  597. {DISP_MODULE_SMI_COMMON, -1, 0},
  598. {DISP_MODULE_SMI_LARB0, -1, 0},
  599. {DISP_MODULE_SMI_LARB1, -1, 0},
  600. {DISP_MODULE_MIPI0, -1, 0},
  601. {DISP_MODULE_MIPI1, -1, 0},
  602. {DISP_MODULE_DPI, -1, 0},
  603. {DISP_MODULE_OVL2_2L, 23, 0},
  604. {DISP_MODULE_OVL3_2L, 24, 0},
  605. {DISP_MODULE_RDMA4, 10, 1},
  606. {DISP_MODULE_RDMA5, 11, 1},
  607. {DISP_MODULE_MDP_RDMA4, 2, 1},
  608. {DISP_MODULE_MDP_RDMA5, 3, 1},
  609. {DISP_MODULE_MDP_RSZ4, 6, 1},
  610. {DISP_MODULE_MDP_RSZ5, 7, 1},
  611. {DISP_MODULE_MERGE0, 27, 0},
  612. {DISP_MODULE_MERGE1, 28, 0},
  613. {DISP_MODULE_DP_INTF, 31, 0},
  614. {DISP_MODULE_DSC, 29, 0},
  615. {DISP_MODULE_DSC_VIRTUAL0, -1, 0},
  616. {DISP_MODULE_UNKNOWN, -1, 0},
  617. };
  618. char *ddp_get_scenario_name(DDP_SCENARIO_ENUM scenario)
  619. {
  620. switch (scenario) {
  621. /* primary display */
  622. case DDP_SCENARIO_PRIMARY_DISP:
  623. return "primary_disp";
  624. case DDP_SCENARIO_PRIMARY_BYPASS_PQ_DISP:
  625. return "primary_bypass_pq";
  626. case DDP_SCENARIO_PRIMARY_RDMA0_COLOR0_DISP0:
  627. return "primary_rdma0_color0_disp0";
  628. case DDP_SCENARIO_PRIMARY_RDMA0_DISP:
  629. return "primary_rdma0_disp";
  630. case DDP_SCENARIO_PRIMARY_OVL_MEMOUT:
  631. return "primary_ovl_memout";
  632. case DDP_SCENARIO_PRIMARY_ALL:
  633. return "primary_all";
  634. /* sub display */
  635. case DDP_SCENARIO_SUB_DISP:
  636. return "sub_disp";
  637. case DDP_SCENARIO_SUB_RDMA1_DISP:
  638. return "sub_rdma1_disp";
  639. case DDP_SCENARIO_SUB_OVL2_2L_MEMOUT:
  640. return "sub_ovl2_2l_memout";
  641. case DDP_SCENARIO_SUB_ALL:
  642. return "sub_all";
  643. case DDP_SCENARIO_PRIMARY1_ALL:
  644. return "primary_disp1";
  645. case DDP_SCENARIO_PRIMARY_RDMA1_COLOR1_DISP1:
  646. return "primary_rdma1_color1_disp1";
  647. case DDP_SCENARIO_PRIMARY_RDMA1_COLOR1_DISP0:
  648. return "primary_rdma1_color1_disp0";
  649. /* others */
  650. default:
  651. DDPMSG("invalid scenario id=%d\n", scenario);
  652. return "unknown";
  653. }
  654. }
  655. int ddp_is_scenario_on_primary(DDP_SCENARIO_ENUM scenario)
  656. {
  657. int on_primary = 0;
  658. switch (scenario) {
  659. case DDP_SCENARIO_PRIMARY_DISP:
  660. case DDP_SCENARIO_PRIMARY_RDMA0_DISP:
  661. case DDP_SCENARIO_PRIMARY_OVL_MEMOUT:
  662. case DDP_SCENARIO_PRIMARY_ALL:
  663. on_primary = 1;
  664. break;
  665. default:
  666. DDPMSG("invalid scenario id=%d\n", scenario);
  667. }
  668. return on_primary;
  669. }
  670. char *ddp_get_mutex_sof_name(unsigned int regval)
  671. {
  672. if (regval == SOF_VAL_MUTEX0_SOF_SINGLE_MODE)
  673. return "single";
  674. else if (regval == SOF_VAL_MUTEX0_SOF_FROM_DSI0)
  675. return "dsi0";
  676. else if (regval == SOF_VAL_MUTEX0_SOF_FROM_DPI)
  677. return "dpi";
  678. DDPDUMP("%s, unknown reg=%d\n", __func__, regval);
  679. return "unknown";
  680. }
  681. char *ddp_get_mode_name(DDP_MODE ddp_mode)
  682. {
  683. switch (ddp_mode) {
  684. case DDP_VIDEO_MODE:
  685. return "vido_mode";
  686. case DDP_CMD_MODE:
  687. return "cmd_mode";
  688. default:
  689. DDPMSG("invalid ddp mode =%d\n", ddp_mode);
  690. return "unknown";
  691. }
  692. }
  693. static int ddp_get_module_num_l(int *module_list)
  694. {
  695. unsigned int num = 0;
  696. while (*(module_list + num) != -1) {
  697. num++;
  698. if (num == DDP_ENING_NUM)
  699. break;
  700. }
  701. return num;
  702. }
  703. /* config mout/msel to creat a compelte path */
  704. static void ddp_connect_path_l(int *module_list, void *handle)
  705. {
  706. unsigned int j, k;
  707. int step = 0;
  708. unsigned int mout = 0;
  709. unsigned int reg_mout = 0;
  710. unsigned int mout_idx = 0;
  711. int module_num = ddp_get_module_num_l(module_list);
  712. DDPDBG("connect_path: %s to %s\n", ddp_get_module_name(module_list[0]),
  713. ddp_get_module_name(module_list[module_num - 1]));
  714. /* connect mout */
  715. for (int i = 0; i < module_num - 1; i++) {
  716. for (j = 0; j < sizeof(mout_map)/sizeof(mout_map[0]); j++) {
  717. if (module_list[i] == mout_map[j].id) {
  718. /* find next module which can be connected */
  719. step = i + 1;
  720. while (ddp_modules[module_list[step]].can_connect== 0
  721. && step < module_num) {
  722. step++;
  723. }
  724. ASSERT(step < module_num);
  725. mout = mout_map[j].reg_val;
  726. for (k = 0; k < DDP_MOUT_MAX; k++) {
  727. if (mout_map[j].out_id_bit_map[k].m == -1)
  728. break;
  729. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  730. mout |= mout_map[j].out_id_bit_map[k].v;
  731. reg_mout |= mout;
  732. mout_idx = j;
  733. DDPDBG("connect mout %s to %s bits 0x%x\n",
  734. ddp_get_module_name(module_list[i]),
  735. ddp_get_module_name(module_list[step]),
  736. reg_mout);
  737. break;
  738. }
  739. }
  740. mout_map[j].reg_val = mout;
  741. mout = 0;
  742. }
  743. }
  744. if (reg_mout) {
  745. DISP_REG_SET(handle, mout_map[mout_idx].reg, reg_mout);
  746. reg_mout = 0;
  747. mout_idx = 0;
  748. }
  749. }
  750. /* connect out select */
  751. for (int i = 0; i < module_num - 1; i++) {
  752. for (j = 0; j < sizeof(sel_out_map)/sizeof(sel_out_map[0]); j++) {
  753. if (module_list[i] == sel_out_map[j].id) {
  754. step = i + 1;
  755. /* find next module which can be connected */
  756. while (ddp_modules[module_list[step]].can_connect== 0
  757. && step < module_num) {
  758. step++;
  759. }
  760. ASSERT(step < module_num);
  761. for (k = 0; k < DDP_SOUT_MAX; k++) {
  762. if (sel_out_map[j].id_bit_map[k] == -1)
  763. break;
  764. if (sel_out_map[j].id_bit_map[k] == module_list[step]) {
  765. DDPDBG("connect out_s %s to %s, value=%d\n",
  766. ddp_get_module_name(module_list[i]),
  767. ddp_get_module_name(module_list[step]), k);
  768. DISP_REG_SET(handle, sel_out_map[j].reg,
  769. (uint16_t) k);
  770. break;
  771. }
  772. }
  773. }
  774. }
  775. }
  776. /* connect input select */
  777. for (int i = 1; i < module_num; i++) {
  778. for (j = 0; j < sizeof(sel_in_map)/sizeof(sel_in_map[0]); j++) {
  779. if (module_list[i] == sel_in_map[j].id) {
  780. int found = 0;
  781. step = i - 1;
  782. /* find next module which can be connected */
  783. while (ddp_modules[module_list[step]].can_connect== 0 && step > 0)
  784. step--;
  785. ASSERT(step >= 0);
  786. for (k = 0; k < DDP_SOUT_MAX; k++) {
  787. if (sel_in_map[j].id_bit_map[k] == -1)
  788. break;
  789. if (sel_in_map[j].id_bit_map[k] == module_list[step]) {
  790. DDPDBG("connect in_s %s to %s, value=%d\n",
  791. ddp_get_module_name(module_list[step]),
  792. ddp_get_module_name(module_list[i]), k);
  793. DISP_REG_SET(handle, sel_in_map[j].reg,
  794. (uint16_t) k);
  795. found = 1;
  796. break;
  797. }
  798. }
  799. if (!found)
  800. DDPERR("%s error: %s sel_in not set\n", __func__,
  801. ddp_get_module_name(module_list[i]));
  802. }
  803. }
  804. }
  805. }
  806. static void ddp_check_path_l(int *module_list)
  807. {
  808. unsigned int j, k;
  809. int step = 0;
  810. int valid = 0;
  811. unsigned int mout;
  812. unsigned int path_error = 0;
  813. int module_num = ddp_get_module_num_l(module_list);
  814. DDPDUMP("check_path: %s to %s\n", ddp_get_module_name(module_list[0])
  815. , ddp_get_module_name(module_list[module_num - 1]));
  816. /* check mout */
  817. for (int i = 0; i < module_num - 1; i++) {
  818. for (j = 0; j < sizeof(mout_map)/sizeof(mout_map[0]); j++) {
  819. if (module_list[i] == mout_map[j].id) {
  820. mout = 0;
  821. /* find next module which can be connected */
  822. step = i + 1;
  823. while (ddp_modules[module_list[step]].can_connect== 0
  824. && step < module_num) {
  825. step++;
  826. }
  827. ASSERT(step < module_num);
  828. for (k = 0; k < DDP_MOUT_MAX; k++) {
  829. if (mout_map[j].out_id_bit_map[k].m == -1)
  830. break;
  831. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  832. mout |= mout_map[j].out_id_bit_map[k].v;
  833. valid = 1;
  834. break;
  835. }
  836. }
  837. if (valid == 0) {
  838. DDPDUMP("err: %s mout, connect next module %s failed\n",
  839. ddp_get_module_name(module_list[i]),
  840. ddp_get_module_name(module_list[i+1]));
  841. path_error +=1;
  842. }else if (valid == 1) {
  843. valid = 0;
  844. if ((DISP_REG_GET(mout_map[j].reg) & mout) == 0) {
  845. path_error += 1;
  846. DDPDUMP("error:%s mout, expect=0x%x, real=0x%x\n",
  847. ddp_get_module_name(module_list[i]),
  848. mout, DISP_REG_GET(mout_map[j].reg));
  849. } else if (DISP_REG_GET(mout_map[j].reg) != mout) {
  850. DDPDUMP
  851. ("warning: %s mout expect=0x%x, real=0x%x\n",
  852. ddp_get_module_name(module_list[i]), mout,
  853. DISP_REG_GET(mout_map[j].reg));
  854. }
  855. }
  856. break;
  857. }
  858. }
  859. }
  860. /* check out select */
  861. for (int i = 0; i < module_num - 1; i++) {
  862. for (j = 0; j < sizeof(sel_out_map)/sizeof(sel_out_map[0]); j++) {
  863. if (module_list[i] != sel_out_map[j].id)
  864. continue;
  865. /* find next module which can be connected */
  866. step = i + 1;
  867. while (ddp_modules[module_list[step]].can_connect== 0
  868. && step < module_num) {
  869. step++;
  870. }
  871. ASSERT(step < module_num);
  872. for (k = 0; k < DDP_SOUT_MAX; k++) {
  873. if (sel_out_map[j].id_bit_map[k] == -1) {
  874. path_error += 1;
  875. DDPDUMP
  876. ("error:out_s %s not connect to %s\n",
  877. ddp_get_module_name(module_list[i]),
  878. ddp_get_module_name(module_list[step]));
  879. break;
  880. }
  881. if (sel_out_map[j].id_bit_map[k] == module_list[step]) {
  882. if (DISP_REG_GET(sel_out_map[j].reg) != k) {
  883. path_error += 1;
  884. DDPDUMP
  885. ("error:out_s %s not connect to %s, expect=0x%x, real=0x%x\n",
  886. ddp_get_module_name(module_list[i]),
  887. ddp_get_module_name(module_list[step]),
  888. k, DISP_REG_GET(sel_out_map[j].reg));
  889. }
  890. break;
  891. }
  892. }
  893. }
  894. }
  895. /* check input select */
  896. for (int i = 1; i < module_num; i++) {
  897. for (j = 0; j < sizeof(sel_in_map)/sizeof(sel_in_map[0]); j++) {
  898. if (module_list[i] != sel_in_map[j].id)
  899. continue;
  900. /* find next module which can be connected */
  901. step = i - 1;
  902. while (ddp_modules[module_list[step]].can_connect == 0 && step > 0)
  903. step--;
  904. ASSERT(step >= 0);
  905. for (k = 0; k < DDP_SOUT_MAX; k++) {
  906. if (sel_in_map[j].id_bit_map[k] == -1) {
  907. path_error += 1;
  908. DDPDUMP
  909. ("error:in_s %s not connect to %s\n",
  910. ddp_get_module_name(module_list[i]),
  911. ddp_get_module_name(module_list[step]));
  912. break;
  913. }
  914. if (sel_in_map[j].id_bit_map[k] == module_list[step]) {
  915. if (DISP_REG_GET(sel_in_map[j].reg) != k) {
  916. path_error += 1;
  917. DDPDUMP("error:in_s %s not conn to %s,expect0x%x,real0x%x\n",
  918. ddp_get_module_name(module_list[step]),
  919. ddp_get_module_name(module_list[i]), k,
  920. DISP_REG_GET(sel_in_map[j].reg));
  921. }
  922. break;
  923. }
  924. }
  925. }
  926. }
  927. if (path_error == 0) {
  928. DDPDUMP("path: %s to %s is connected\n", ddp_get_module_name(module_list[0]),
  929. ddp_get_module_name(module_list[module_num - 1]));
  930. } else {
  931. DDPDUMP("path: %s to %s not connected!!!\n", ddp_get_module_name(module_list[0]),
  932. ddp_get_module_name(module_list[module_num - 1]));
  933. }
  934. }
  935. static void ddp_disconnect_path_l(int *module_list, void *handle)
  936. {
  937. unsigned int j, k;
  938. int step = 0;
  939. unsigned int mout = 0;
  940. unsigned int reg_mout = 0;
  941. unsigned int mout_idx = 0;
  942. int module_num = ddp_get_module_num_l(module_list);
  943. DDPDBG("disconnect_path: %s to %s\n", ddp_get_module_name(module_list[0]),
  944. ddp_get_module_name(module_list[module_num - 1]));
  945. for (int i = 0; i < module_num - 1; i++) {
  946. for (j = 0; j < sizeof(mout_map)/sizeof(mout_map[0]); j++) {
  947. if (module_list[i] == mout_map[j].id) {
  948. /* find next module which can be connected */
  949. step = i + 1;
  950. while (ddp_modules[module_list[step]].can_connect== 0
  951. && step < module_num) {
  952. step++;
  953. }
  954. ASSERT(step < module_num);
  955. for (k = 0; k < DDP_MOUT_MAX; k++) {
  956. if (mout_map[j].out_id_bit_map[k].m == -1)
  957. break;
  958. if (mout_map[j].out_id_bit_map[k].m == module_list[step]) {
  959. mout |= mout_map[j].out_id_bit_map[k].v;
  960. reg_mout |= mout;
  961. mout_idx = j;
  962. DDPDBG("disconnect mout %s to %s\n",
  963. ddp_get_module_name(module_list[i]),
  964. ddp_get_module_name(module_list[step]));
  965. break;
  966. }
  967. }
  968. /* update mout_value */
  969. mout_map[j].reg_val &= ~mout;
  970. mout = 0;
  971. }
  972. }
  973. if (reg_mout) {
  974. DISP_REG_SET(handle, mout_map[mout_idx].reg, mout_map[mout_idx].reg_val);
  975. reg_mout = 0;
  976. mout_idx = 0;
  977. }
  978. }
  979. }
  980. static int ddp_get_mutex_src(DISP_MODULE_ENUM dest_module, DDP_MODE ddp_mode,
  981. unsigned int *SOF_src, unsigned int *EOF_src)
  982. {
  983. unsigned int src_from_dst_module = 0;
  984. if (dest_module == DISP_MODULE_WDMA0) {
  985. if (ddp_mode == DDP_VIDEO_MODE)
  986. DISP_LOG_W("%s: dst_mode=%s, but is video mode !!\n", __func__,
  987. ddp_get_module_name(dest_module));
  988. *SOF_src = *EOF_src = SOF_VAL_MUTEX0_SOF_SINGLE_MODE;
  989. return 0;
  990. }
  991. if (dest_module == DISP_MODULE_DSI0 || dest_module == DISP_MODULE_DSIDUAL) {
  992. src_from_dst_module = SOF_VAL_MUTEX0_SOF_FROM_DSI0;
  993. } else {
  994. DDPERR("get mutex sof, invalid param dst module = %s(%d), dis mode %s\n",
  995. ddp_get_module_name(dest_module), dest_module, ddp_get_mode_name(ddp_mode));
  996. ASSERT(0);
  997. }
  998. if (ddp_mode == DDP_CMD_MODE) {
  999. *SOF_src = SOF_VAL_MUTEX0_SOF_SINGLE_MODE;
  1000. if (0/*disp_helper_get_option(DISP_OPT_MUTEX_EOF_EN_FOR_CMD_MODE)*/)
  1001. *EOF_src = src_from_dst_module;
  1002. else
  1003. *EOF_src = SOF_VAL_MUTEX0_EOF_SINGLE_MODE;
  1004. } else {
  1005. *SOF_src = *EOF_src = src_from_dst_module;
  1006. }
  1007. return 0;
  1008. }
  1009. /* id: mutex ID, 0~5 */
  1010. static int ddp_mutex_set_l(int mutex_id, int *module_list, DDP_MODE ddp_mode, void *handle)
  1011. {
  1012. int i = 0;
  1013. unsigned int value0 = 0;
  1014. unsigned int value1 = 0;
  1015. unsigned int sof_val;
  1016. unsigned int sof_src, eof_src;
  1017. int module_num = ddp_get_module_num_l(module_list);
  1018. ddp_get_mutex_src(module_list[module_num - 1], ddp_mode, &sof_src, &eof_src);
  1019. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  1020. DDPERR("exceed mutex max (0 ~ %d)\n", DISP_MUTEX_DDP_LAST);
  1021. return -1;
  1022. }
  1023. for (i = 0; i < module_num; i++) {
  1024. if (module_mutex_map[module_list[i]].bit != -1) {
  1025. DDPDBG("module %s added to mutex %d\n", ddp_get_module_name(module_list[i]),
  1026. mutex_id);
  1027. if (module_mutex_map[module_list[i]].mod_num == 0) {
  1028. if (DISP_MODULE_DSIDUAL == module_mutex_map[module_list[i]].module) {
  1029. value0 |= (1 << module_mutex_map[DISP_MODULE_DSI0].bit); /* DISP MODULE enum must start from 0 */
  1030. value0 |= (1 << module_mutex_map[DISP_MODULE_DSI1].bit);
  1031. } else {
  1032. value0 |= (1 << module_mutex_map[module_list[i]].bit);
  1033. }
  1034. } else if (module_mutex_map[module_list[i]].mod_num == 1) {
  1035. /* DISP_MODULE_DSIDUAL is special */
  1036. if (DISP_MODULE_DSIDUAL == module_mutex_map[module_list[i]].module) {
  1037. value1 |= (1 << module_mutex_map[DISP_MODULE_DSI0].bit); /* DISP MODULE enum must start from 0 */
  1038. value1 |= (1 << module_mutex_map[DISP_MODULE_DSI1].bit);
  1039. } else {
  1040. value1 |= (1 << module_mutex_map[module_list[i]].bit);
  1041. }
  1042. }
  1043. } else {
  1044. DDPDBG("module %s not added to mutex %d\n",
  1045. ddp_get_module_name(module_list[i]), mutex_id);
  1046. }
  1047. }
  1048. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_MOD0(mutex_id), value0);
  1049. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_MOD1(mutex_id), value1);
  1050. sof_val = REG_FLD_VAL(SOF_FLD_MUTEX0_SOF, sof_src);
  1051. sof_val |= REG_FLD_VAL(SOF_FLD_MUTEX0_EOF, eof_src);
  1052. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_SOF(mutex_id), sof_val);
  1053. DDPDBG("mutex %d value=0x%x, sof=%s, eof=%s\n", mutex_id,
  1054. value0, ddp_get_mutex_sof_name(sof_src), ddp_get_mutex_sof_name(eof_src));
  1055. return 0;
  1056. }
  1057. static void ddp_check_mutex_l(int mutex_id, int *module_list, DDP_MODE ddp_mode)
  1058. {
  1059. int i = 0;
  1060. uint32_t real_value0 = 0;
  1061. uint32_t real_value1 = 0;
  1062. uint32_t expect_value0 = 0;
  1063. uint32_t expect_value1 = 0;
  1064. unsigned int real_sof, real_eof, val;
  1065. unsigned int expect_sof, expect_eof;
  1066. int module_num = ddp_get_module_num_l(module_list);
  1067. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  1068. DDPDUMP("error:check mutex fail:exceed mutex max (0 ~ %d)\n", DISP_MUTEX_DDP_LAST);
  1069. return;
  1070. }
  1071. real_value0 = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_MOD0(mutex_id));
  1072. for (i = 0; i < module_num; i++) {
  1073. if (module_mutex_map[module_list[i]].bit != -1) {
  1074. if (module_mutex_map[module_list[i]].mod_num == 0) {
  1075. if (DISP_MODULE_DSIDUAL == module_mutex_map[module_list[i]].module) {
  1076. expect_value0 |= (1 << module_mutex_map[DISP_MODULE_DSI0].bit); /* DISP MODULE enum must start from 0 */
  1077. expect_value0 |= (1 << module_mutex_map[DISP_MODULE_DSI1].bit);
  1078. } else {
  1079. expect_value0 |= (1 << module_mutex_map[module_list[i]].bit);
  1080. }
  1081. }else if (module_mutex_map[module_list[i]].mod_num == 1) {
  1082. if (DISP_MODULE_DSIDUAL == module_mutex_map[module_list[i]].module) {
  1083. expect_value1 |= (1 << module_mutex_map[DISP_MODULE_DSI0].bit); /* DISP MODULE enum must start from 0 */
  1084. expect_value1 |= (1 << module_mutex_map[DISP_MODULE_DSI1].bit);
  1085. } else {
  1086. expect_value1 |= (1 << module_mutex_map[module_list[i]].bit);
  1087. }
  1088. }
  1089. }
  1090. }
  1091. if (expect_value0 != real_value0)
  1092. DDPDUMP("error:mutex %d error: expect0 0x%x, real0 0x%x\n", mutex_id, expect_value0,
  1093. real_value0);
  1094. if (expect_value1 != real_value1)
  1095. DDPDUMP("error:mutex %d error: expect1 0x%x, real1 0x%x\n", mutex_id, expect_value1,
  1096. real_value1);
  1097. val = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_SOF(mutex_id));
  1098. real_sof = REG_FLD_VAL_GET(SOF_FLD_MUTEX0_SOF, val);
  1099. real_eof = REG_FLD_VAL_GET(SOF_FLD_MUTEX0_EOF, val);
  1100. ddp_get_mutex_src(module_list[module_num - 1], ddp_mode, &expect_sof, &expect_eof);
  1101. if (expect_sof != real_sof)
  1102. DDPDUMP("error:mutex %d sof error: expect %s, real %s\n", mutex_id,
  1103. ddp_get_mutex_sof_name(expect_sof), ddp_get_mutex_sof_name(real_sof));
  1104. if (expect_eof != real_eof)
  1105. DDPDUMP("error:mutex %d eof error: expect %s, real %s\n", mutex_id,
  1106. ddp_get_mutex_sof_name(expect_eof), ddp_get_mutex_sof_name(real_eof));
  1107. }
  1108. static int ddp_mutex_enable_l(int mutex_idx, void *handle)
  1109. {
  1110. DDPDBG("mutex %d enable\n", mutex_idx);
  1111. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_CFG, 0);
  1112. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_EN(mutex_idx), 1);
  1113. return 0;
  1114. }
  1115. int ddp_get_module_num(DDP_SCENARIO_ENUM scenario)
  1116. {
  1117. return ddp_get_module_num_l(module_list_scenario[scenario]);
  1118. }
  1119. static void ddp_print_scenario(DDP_SCENARIO_ENUM scenario)
  1120. {
  1121. int i =0;
  1122. char path[512]= {'\0'};
  1123. int num = ddp_get_module_num(scenario);
  1124. for (i = 0; i < num; i++)
  1125. strncat(path, ddp_get_module_name(module_list_scenario[scenario][i]), sizeof(path));
  1126. DDPMSG("scenario %s have modules: %s\n",ddp_get_scenario_name(scenario),path);
  1127. }
  1128. static int ddp_find_module_index(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM module)
  1129. {
  1130. int i = 0;
  1131. for (i = 0; i < DDP_ENING_NUM; i++) {
  1132. if (module_list_scenario[ddp_scenario][i] == (int)module)
  1133. return i;
  1134. }
  1135. DDPDBG("find module: can not find module %s on scenario %s\n", ddp_get_module_name(module),
  1136. ddp_get_scenario_name(ddp_scenario));
  1137. return -1;
  1138. }
  1139. /* set display interface when kernel init */
  1140. int ddp_set_dst_module(DDP_SCENARIO_ENUM scenario, DISP_MODULE_ENUM dst_module)
  1141. {
  1142. int i = 0;
  1143. DDPMSG("ddp_set_dst_module, scenario=%s, dst_module=%s\n",
  1144. ddp_get_scenario_name(scenario), ddp_get_module_name(dst_module));
  1145. if (ddp_find_module_index(scenario, dst_module) > 0) {
  1146. DDPDBG("%s is already on path\n", ddp_get_module_name(dst_module));
  1147. return 0;
  1148. }
  1149. i = ddp_get_module_num_l(module_list_scenario[scenario]) - 1;
  1150. ASSERT(i >= 0);
  1151. if (dst_module == DISP_MODULE_DSIDUAL) {
  1152. if (i < (DDP_ENING_NUM - 1)) {
  1153. module_list_scenario[scenario][i++] = DISP_MODULE_SPLIT0;
  1154. } else {
  1155. DDPERR("set dst module over up bound\n");
  1156. return -1;
  1157. }
  1158. } else {
  1159. if (ddp_get_dst_module(scenario) == DISP_MODULE_DSIDUAL) {
  1160. if (i >= 1) {
  1161. module_list_scenario[scenario][i--] = -1;
  1162. } else {
  1163. DDPERR("set dst module over low bound\n");
  1164. return -1;
  1165. }
  1166. }
  1167. }
  1168. module_list_scenario[scenario][i] = dst_module;
  1169. if (scenario == DDP_SCENARIO_PRIMARY_ALL)
  1170. ddp_set_dst_module(DDP_SCENARIO_PRIMARY_DISP, dst_module);
  1171. ddp_print_scenario(scenario);
  1172. return 0;
  1173. }
  1174. DISP_MODULE_ENUM ddp_get_dst_module(DDP_SCENARIO_ENUM ddp_scenario)
  1175. {
  1176. DISP_MODULE_ENUM module_name = DISP_MODULE_UNKNOWN;
  1177. int module_num = ddp_get_module_num_l(module_list_scenario[ddp_scenario]) - 1;
  1178. if (module_num >= 0)
  1179. module_name = module_list_scenario[ddp_scenario][module_num];
  1180. return module_name;
  1181. }
  1182. int *ddp_get_scenario_list(DDP_SCENARIO_ENUM ddp_scenario)
  1183. {
  1184. return module_list_scenario[ddp_scenario];
  1185. }
  1186. int ddp_is_module_in_scenario(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM module)
  1187. {
  1188. int i = 0;
  1189. for (i = 0; i < DDP_ENING_NUM; i++) {
  1190. if (module_list_scenario[ddp_scenario][i] == (int)module)
  1191. return 1;
  1192. }
  1193. return 0;
  1194. }
  1195. int ddp_insert_module(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM place,
  1196. DISP_MODULE_ENUM module)
  1197. {
  1198. int i = DDP_ENING_NUM - 1;
  1199. int idx = ddp_find_module_index(ddp_scenario, place);
  1200. if (idx < 0) {
  1201. DDPERR("error: ddp_insert_module , place=%s is not in scenario %s!\n",
  1202. ddp_get_module_name(place), ddp_get_scenario_name(ddp_scenario));
  1203. return -1;
  1204. }
  1205. for (i = 0; i < DDP_ENING_NUM; i++) {
  1206. if (module_list_scenario[ddp_scenario][i] == (int)module) {
  1207. DDPERR("error: ddp_insert_module , module=%s is already in scenario %s!\n",
  1208. ddp_get_module_name(module), ddp_get_scenario_name(ddp_scenario));
  1209. return -1;
  1210. }
  1211. }
  1212. /* should have empty room for insert */
  1213. ASSERT(module_list_scenario[ddp_scenario][DDP_ENING_NUM - 1] == -1);
  1214. for (i = DDP_ENING_NUM - 2; i >= idx; i--)
  1215. module_list_scenario[ddp_scenario][i + 1] = module_list_scenario[ddp_scenario][i];
  1216. module_list_scenario[ddp_scenario][idx] = module;
  1217. {
  1218. int *modules = ddp_get_scenario_list(ddp_scenario);
  1219. int module_num = ddp_get_module_num(ddp_scenario);
  1220. DDPMSG("after insert module, module list is:\n");
  1221. for (i = 0; i < module_num; i++)
  1222. DDPMSG("%s-", ddp_get_module_name(modules[i]));
  1223. }
  1224. return 0;
  1225. }
  1226. int ddp_remove_module(DDP_SCENARIO_ENUM ddp_scenario, DISP_MODULE_ENUM module)
  1227. {
  1228. int i = 0;
  1229. int idx = ddp_find_module_index(ddp_scenario, module);
  1230. if (idx < 0) {
  1231. DDPERR("ddp_remove_module, can not find module %s in scenario %s\n",
  1232. ddp_get_module_name(module), ddp_get_scenario_name(ddp_scenario));
  1233. return -1;
  1234. }
  1235. for (i = idx; i < DDP_ENING_NUM - 1; i++)
  1236. module_list_scenario[ddp_scenario][i] = module_list_scenario[ddp_scenario][i + 1];
  1237. module_list_scenario[ddp_scenario][DDP_ENING_NUM - 1] = -1;
  1238. {
  1239. int *modules = ddp_get_scenario_list(ddp_scenario);
  1240. int module_num = ddp_get_module_num(ddp_scenario);
  1241. DDPMSG("after remove module, module list is:\n");
  1242. for (i = 0; i < module_num; i++)
  1243. DDPMSG("%s-", ddp_get_module_name(modules[i]));
  1244. }
  1245. return 0;
  1246. }
  1247. void ddp_connect_path(DDP_SCENARIO_ENUM scenario, void *handle)
  1248. {
  1249. DDPDBG("path connect on scenario %s\n", ddp_get_scenario_name(scenario));
  1250. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  1251. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  1252. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT], handle);
  1253. } else if (scenario == DDP_SCENARIO_PRIMARY1_ALL) {
  1254. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  1255. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT], handle);
  1256. } else if (scenario == DDP_SCENARIO_SUB_ALL) {
  1257. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_SUB_DISP], handle);
  1258. ddp_connect_path_l(module_list_scenario[DDP_SCENARIO_SUB_OVL2_2L_MEMOUT], handle);
  1259. } else {
  1260. ddp_connect_path_l(module_list_scenario[scenario], handle);
  1261. }
  1262. return;
  1263. }
  1264. void ddp_disconnect_path(DDP_SCENARIO_ENUM scenario, void *handle)
  1265. {
  1266. DDPDBG("path disconnect on scenario %s\n", ddp_get_scenario_name(scenario));
  1267. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  1268. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP], handle);
  1269. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT],
  1270. handle);
  1271. } else if (scenario == DDP_SCENARIO_SUB_ALL) {
  1272. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_SUB_DISP], handle);
  1273. ddp_disconnect_path_l(module_list_scenario[DDP_SCENARIO_SUB_OVL2_2L_MEMOUT], handle);
  1274. } else {
  1275. ddp_disconnect_path_l(module_list_scenario[scenario], handle);
  1276. }
  1277. return;
  1278. }
  1279. void ddp_check_path(DDP_SCENARIO_ENUM scenario)
  1280. {
  1281. DDPDBG("path check path on scenario %s\n", ddp_get_scenario_name(scenario));
  1282. if (scenario == DDP_SCENARIO_PRIMARY_ALL) {
  1283. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_DISP]);
  1284. ddp_check_path_l(module_list_scenario[DDP_SCENARIO_PRIMARY_OVL_MEMOUT]);
  1285. } else {
  1286. ddp_check_path_l(module_list_scenario[scenario]);
  1287. }
  1288. return;
  1289. }
  1290. void ddp_check_mutex(int mutex_id, DDP_SCENARIO_ENUM scenario, DDP_MODE mode)
  1291. {
  1292. DDPDBG("check mutex %d on scenario %s\n", mutex_id, ddp_get_scenario_name(scenario));
  1293. ddp_check_mutex_l(mutex_id, module_list_scenario[scenario], mode);
  1294. return;
  1295. }
  1296. int ddp_mutex_set(int mutex_id, DDP_SCENARIO_ENUM scenario, DDP_MODE mode, void *handle)
  1297. {
  1298. if (scenario < DDP_SCENARIO_MAX) {
  1299. return ddp_mutex_set_l(mutex_id, module_list_scenario[scenario], mode, handle);
  1300. } else {
  1301. DDPERR("Invalid scenario %d when setting mutex\n", scenario);
  1302. return -1;
  1303. }
  1304. return 0;
  1305. }
  1306. int ddp_mutex_Interrupt_enable(int mutex_id, void *handle)
  1307. {
  1308. DDPDBG("mutex %d interrupt enable\n", mutex_id);
  1309. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_INTEN, 0x1 << mutex_id, 0x1 << mutex_id);
  1310. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_INTEN, 1 << (mutex_id + DISP_MUTEX_TOTAL),
  1311. 0x1 << (mutex_id + DISP_MUTEX_TOTAL));
  1312. return 0;
  1313. }
  1314. int ddp_mutex_Interrupt_disable(int mutex_id, void *handle)
  1315. {
  1316. DDPDBG("mutex %d interrupt disenable\n", mutex_id);
  1317. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_INTEN, 0, 0x1 << mutex_id);
  1318. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_INTEN, 0, 0x1 << (mutex_id + DISP_MUTEX_TOTAL));
  1319. return 0;
  1320. }
  1321. int ddp_mutex_reset(int mutex_id, void *handle)
  1322. {
  1323. DDPDBG("mutex %d reset\n", mutex_id);
  1324. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_RST(mutex_id), 1);
  1325. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_RST(mutex_id), 0);
  1326. return 0;
  1327. }
  1328. int ddp_is_moudule_in_mutex(int mutex_id, DISP_MODULE_ENUM module)
  1329. {
  1330. int ret = 0;
  1331. uint32_t real_value = 0;
  1332. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  1333. DDPDUMP("error:check_moudule_in_mute fail:exceed mutex max (0 ~ %d)\n",
  1334. DISP_MUTEX_DDP_LAST);
  1335. return ret;
  1336. }
  1337. if (module_mutex_map[module].mod_num == 0) {
  1338. real_value = DISP_REG_GET(DISP_REG_CONFIG_MUTEX_MOD0(mutex_id));
  1339. }
  1340. if (1 == ((real_value >> module_mutex_map[module].bit) & 0x01))
  1341. ret = 1;
  1342. return ret;
  1343. }
  1344. int ddp_mutex_add_module(int mutex_id, DISP_MODULE_ENUM module, void *handle)
  1345. {
  1346. int value = 0;
  1347. if (module < DISP_MODULE_UNKNOWN) {
  1348. if (module_mutex_map[module].bit != -1) {
  1349. DDPDBG("module %s added to mutex %d\n", ddp_get_module_name(module),
  1350. mutex_id);
  1351. value |= (1 << module_mutex_map[module].bit);
  1352. if (module_mutex_map[module].mod_num == 0) {
  1353. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_MOD0(mutex_id), value, value);
  1354. }
  1355. else if (module_mutex_map[module].mod_num == 1) {
  1356. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_MOD1(mutex_id), value, value);
  1357. }
  1358. }
  1359. }
  1360. return 0;
  1361. }
  1362. int ddp_mutex_remove_module(int mutex_id, DISP_MODULE_ENUM module, void *handle)
  1363. {
  1364. int value = 0;
  1365. if (module < DISP_MODULE_UNKNOWN) {
  1366. if (module_mutex_map[module].bit != -1) {
  1367. DDPDBG("module %s added to mutex %d\n", ddp_get_module_name(module),
  1368. mutex_id);
  1369. value |= (1 << module_mutex_map[module].bit);
  1370. if (module_mutex_map[module].mod_num == 0) {
  1371. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_MOD0(mutex_id), 0, value);
  1372. }
  1373. else if (module_mutex_map[module].mod_num == 1) {
  1374. DISP_REG_MASK(handle, DISP_REG_CONFIG_MUTEX_MOD1(mutex_id), 0, value);
  1375. }
  1376. }
  1377. }
  1378. return 0;
  1379. }
  1380. int ddp_mutex_clear(int mutex_id, void *handle)
  1381. {
  1382. DDPDBG("mutex %d clear\n", mutex_id);
  1383. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_MOD0(mutex_id), 0);
  1384. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_SOF(mutex_id), 0);
  1385. /* enough or not */
  1386. /*reset mutex */
  1387. ddp_mutex_reset(mutex_id, handle);
  1388. return 0;
  1389. }
  1390. int ddp_mutex_enable(int mutex_id, DDP_SCENARIO_ENUM scenario, void *handle)
  1391. {
  1392. return ddp_mutex_enable_l(mutex_id, handle);
  1393. }
  1394. int ddp_mutex_disable(int mutex_id, DDP_SCENARIO_ENUM scenario, void *handle)
  1395. {
  1396. DDPDBG("mutex %d disable\n", mutex_id);
  1397. DISP_REG_SET(handle, DISP_REG_CONFIG_MUTEX_EN(mutex_id), 0);
  1398. return 0;
  1399. }
  1400. int ddp_mutex_set_sof_wait(int mutex_id, cmdqRecHandle handle, int wait)
  1401. {
  1402. if (mutex_id < DISP_MUTEX_DDP_FIRST || mutex_id > DISP_MUTEX_DDP_LAST) {
  1403. DDPERR("exceed mutex max (0 ~ %d)\n", DISP_MUTEX_DDP_LAST);
  1404. return -1;
  1405. }
  1406. DISP_REG_SET_FIELD(handle, SOF_FLD_MUTEX0_SOF_WAIT, DISP_REG_CONFIG_MUTEX_SOF(mutex_id), wait);
  1407. return 0;
  1408. }
  1409. int ddp_check_engine_status(int mutexID)
  1410. {
  1411. /* check engines' clock bit & enable bit & status bit before unlock mutex */
  1412. /* should not needed, in comdq do? */
  1413. int result = 0;
  1414. return result;
  1415. }
  1416. int ddp_path_top_clock_on(void)
  1417. {
  1418. DDPMSG("ddp path top clock on\n");
  1419. spm_mtcmos_ctrl_dis(1);
  1420. ddp_enable_module_clock(DISP_MODULE_SMI_COMMON);
  1421. ddp_enable_module_clock(DISP_MODULE_SMI_LARB0);
  1422. DDPMSG("ddp CG0:%x CG1:%x\n", DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0),
  1423. DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON1));
  1424. #if 1 /* Force CG always on */
  1425. DDPMSG("[FPGA Only] before power on MMSYS:0x%x,0x%x,0x%x\n",
  1426. DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0),
  1427. DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON1),
  1428. DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON2));
  1429. DISP_REG_SET(NULL, DISP_REG_CONFIG_MMSYS_CG_CLR0, 0xFFFF3FFF);
  1430. DISP_REG_SET(NULL, DISP_REG_CONFIG_MMSYS_CG_CLR1, 0xFFFFF3FF);
  1431. DISP_REG_SET(NULL, DISP_REG_CONFIG_MMSYS_CG_CLR2, 0xFFFFFFFF);
  1432. DDPMSG("[FPGA Only] before power on MMSYS:0x%x,0x%x,0x%x\n",
  1433. DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0),
  1434. DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON1),
  1435. DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON2));
  1436. #endif
  1437. DDPMSG("SMI subcom before config:(0x%x,0x%x)\n",
  1438. DISP_REG_GET(DISP_REG_SMI_SUBCOM0_L1LEN),
  1439. DISP_REG_GET(DISP_REG_SMI_SUBCOM1_L1LEN));
  1440. DISP_REG_SET(NULL, DISP_REG_SMI_SUBCOM0_L1LEN, 0XA);
  1441. DISP_REG_SET(NULL, DISP_REG_SMI_SUBCOM1_L1LEN, 0XA);
  1442. DDPMSG("SMI subcom after config:(0x%x,0x%x)\n",
  1443. DISP_REG_GET(DISP_REG_SMI_SUBCOM0_L1LEN),
  1444. DISP_REG_GET(DISP_REG_SMI_SUBCOM1_L1LEN));
  1445. return 0;
  1446. }
  1447. int ddp_path_top_clock_off(void)
  1448. {
  1449. DDPMSG("ddp path top clock off\n");
  1450. ddp_disable_module_clock(DISP_MODULE_SMI_LARB0);
  1451. ddp_disable_module_clock(DISP_MODULE_SMI_COMMON);
  1452. DDPMSG("ddp CG0:%x CG1:%x\n", DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0),
  1453. DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON1));
  1454. return 0;
  1455. }
  1456. int ddp_path_m4u_off(void)
  1457. {
  1458. int i;
  1459. DDPMSG("ddp path m4u off\n");
  1460. #ifdef MTKFB_NO_M4U
  1461. /* display ports bypass m4u.
  1462. ==== FBI WARNING: ==========
  1463. This function is hard code of m4u port setting !!!
  1464. Please ask M4U owner about it for new chip porting !!!
  1465. */
  1466. /*
  1467. M4U_PORT_DISP_OVL0,
  1468. M4U_PORT_DISP_2L_OVL0_LARB0,
  1469. M4U_PORT_DISP_RDMA0,
  1470. M4U_PORT_DISP_WDMA0,
  1471. */
  1472. for (i=0; i<4; i++)
  1473. DISP_REG_SET_FIELD(0, REG_FLD_MMU_EN, DISP_REG_SMI_LARB0_MMU_EN + i*4, 0);
  1474. /*
  1475. M4U_PORT_DISP_OVL1_2L,
  1476. M4U_PORT_DISP_RDMA1,
  1477. M4U_PORT_DISP_2L_OVL0,
  1478. */
  1479. /* not use SMI_LARB1 */
  1480. /*
  1481. for (i=0; i<3; i++)
  1482. DISP_REG_SET_FIELD(0, REG_FLD_MMU_EN, DISP_REG_SMI_LARB1_MMU_EN + i*4, 0);
  1483. */
  1484. #endif
  1485. return 0;
  1486. }
  1487. void primary_disp_module_list_insert_dsc(void)
  1488. {
  1489. unsigned int i = 0;
  1490. for (i = 0; i < DDP_ENING_NUM; i++)
  1491. module_list_scenario[DDP_SCENARIO_PRIMARY_DISP][i] =
  1492. primary_disp_dsc_module_list[i];
  1493. }