ddp_manager.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. #ifndef __DDP_PATH_MANAGER_H__
  36. #define __DDP_PATH_MANAGER_H__
  37. #include "ddp_info.h"
  38. #include "disp_event.h"
  39. #include "ddp_path.h"
  40. typedef void * cmdqRecHandle;
  41. typedef enum {
  42. ENGINE_UFOE = DISP_MODULE_UFOE, /* add wdma0 after UFOE */
  43. ENGINE_OVL0 = DISP_MODULE_OVL0 , /* add wdma0 after OVL0 */
  44. ENGINE_OVL1 = DISP_MODULE_OVL1, /* add wdma1 after OVL1*/
  45. ENGINE_OD = DISP_MODULE_OD, /* add wdma0 after OD */
  46. }ENGINE_DUMP;
  47. #define MAKE_DDP_IRQ_BIT(module, shift) ((module<<16)|(0x1<<shift))
  48. #define IRQBIT_MODULE(irqbit) (irqbit >> 16)
  49. #define IRQBIT_BIT(irqbit) (irqbit & 0xffff)
  50. /* IRQ and module are combined to consist DDP IRQ */
  51. typedef enum
  52. {
  53. DDP_IRQ_RDMA0_REG_UPDATE = (DISP_MODULE_RDMA0 <<16 | 0x1<<0),
  54. DDP_IRQ_RDMA0_START = (DISP_MODULE_RDMA0 <<16 | 0x1<<1),
  55. DDP_IRQ_RDMA0_DONE = (DISP_MODULE_RDMA0 <<16 | 0x1<<2),
  56. DDP_IRQ_RDMA0_UNDERFLOW = (DISP_MODULE_RDMA0 <<16 | 0x1<<3),
  57. DDP_IRQ_RDMA0_TARGET_LINE = (DISP_MODULE_RDMA0 <<16 | 0x1<<4),
  58. DDP_IRQ_RDMA1_REG_UPDATE = (DISP_MODULE_RDMA1 <<16 | 0x1<<0),
  59. DDP_IRQ_RDMA1_START = (DISP_MODULE_RDMA1 <<16 | 0x1<<1),
  60. DDP_IRQ_RDMA1_DONE = (DISP_MODULE_RDMA1 <<16 | 0x1<<2),
  61. DDP_IRQ_RDMA1_UNDERFLOW = (DISP_MODULE_RDMA1 <<16 | 0x1<<3),
  62. DDP_IRQ_RDMA1_TARGET_LINE = (DISP_MODULE_RDMA1 <<16 | 0x1<<4),
  63. DDP_IRQ_RDMA2_REG_UPDATE = (DISP_MODULE_RDMA2 <<16 | 0x1<<0),
  64. DDP_IRQ_RDMA2_START = (DISP_MODULE_RDMA2 <<16 | 0x1<<1),
  65. DDP_IRQ_RDMA2_DONE = (DISP_MODULE_RDMA2 <<16 | 0x1<<2),
  66. DDP_IRQ_RDMA2_UNDERFLOW = (DISP_MODULE_RDMA2 <<16 | 0x1<<3),
  67. DDP_IRQ_RDMA2_TARGET_LINE = (DISP_MODULE_RDMA2 <<16 | 0x1<<4),
  68. DDP_IRQ_WDMA0_FRAME_COMPLETE = (DISP_MODULE_WDMA0<<16 | 0x1<<0),
  69. DDP_IRQ_WDMA1_FRAME_COMPLETE = (DISP_MODULE_WDMA1<<16 | 0x1<<0),
  70. DDP_IRQ_DSI0_EXT_TE = (DISP_MODULE_DSI0 <<16 | 0x1<<2),
  71. DDP_IRQ_UNKNOW = (DISP_MODULE_UNKNOWN<<16 | 0x1<<0),
  72. }DDP_IRQ_BIT;
  73. /* path handle */
  74. typedef void* disp_path_handle;
  75. /* Init ddp manager, now only register irq handler to ddp_irq.c
  76. * return 0 if ok or -1 if fail.
  77. */
  78. int dpmgr_init(void);
  79. /* create disp path handle , it will assign mutex to this handle, and cache this handle
  80. * to modules in scenario, and will assign default irq event to this handle.
  81. * return NULL if fail to create handle.
  82. * scenario: used to demininate path, and ddp manager will do operations
  83. * according to current scenario.
  84. * cmdq_handle : will save current config cmdqhandle, and if cmdq is enable , will
  85. use cmdq to write regitsers.
  86. */
  87. disp_path_handle dpmgr_create_path(DDP_SCENARIO_ENUM scenario, cmdqRecHandle cmdq_handle);
  88. /* destroy path, it will release mutex to pool, and disconnect path,
  89. * clear mapping between handle and modules.
  90. * return 0;
  91. */
  92. int dpmgr_destroy_path(disp_path_handle dp_handle);
  93. /* add dump to path, for primary path , support OVL0, UFOE and OD.
  94. * for sub path ,support OVL1.
  95. * return 0 if success or -1 if fail.
  96. * dp_handle: disp path handle.
  97. */
  98. int dpmgr_path_add_dump(disp_path_handle dp_handle, ENGINE_DUMP engine,int encmdq);
  99. /* remove dump to path. shoud match between add dump and remove dump.
  100. * return 0 if success or -1 if fail.
  101. * dp_handle: disp path handle.
  102. * encmdq: 1 use command queue, 0 not.
  103. */
  104. int dpmgr_path_remove_dump(disp_path_handle dp_handle, int encmdq);
  105. /* query current dst module.
  106. * return module enum.
  107. * dp_handle: disp path handle.
  108. */
  109. DISP_MODULE_ENUM dpmgr_path_get_dst_module(disp_path_handle dp_handle);
  110. /* set dst module, the default dst module maybe not right, so set real dst module on this path.
  111. * return 0.
  112. * dp_handle: disp path handle.
  113. * dst_module(one of bellow):
  114. * DISP_MODULE_DSI0
  115. * DISP_MODULE_DSI1
  116. * DISP_MODULE_DSIDUAL(DISP_MODULE_DSI0+DISP_MODULE_DSI1)
  117. * DISP_MODULE_DPI
  118. */
  119. int dpmgr_path_set_dst_module(disp_path_handle dp_handle,DISP_MODULE_ENUM dst_module);
  120. /* set mode type(sof source): cmd or video mode.
  121. * return 0.
  122. * dp_handle: disp path handle.
  123. * is_vdo_mode: 0 is cmd mode, 1 is video mode.
  124. */
  125. int dpmgr_path_set_video_mode(disp_path_handle dp_handle, int is_vdo_mode);
  126. /* init path , it will set mutex according to modules on this path and sof sorce.
  127. * and it will connect path , then initialize modules on this path.
  128. * return 0.
  129. * dp_handle: disp path handle.
  130. * encmdq: 1 use command queue, 0 not.
  131. */
  132. int dpmgr_path_init(disp_path_handle dp_handle, int encmdq);
  133. /* deinit path , it will clear mutex and dissconnect path.
  134. * return 0.
  135. * dp_handle: disp path handle.
  136. * encmdq: 1 use command queue, 0 not.
  137. */
  138. int dpmgr_path_deinit(disp_path_handle dp_handle, int encmdq);
  139. /* start path , it will start this path by calling each drviers start function.
  140. * return 0.
  141. * dp_handle: disp path handle.
  142. * encmdq: 1 use command queue, 0 not.
  143. */
  144. int dpmgr_path_start(disp_path_handle dp_handle, int encmdq);
  145. /* start path , it will stop this path by calling each drviers stop function.
  146. * return 0.
  147. * dp_handle: disp path handle.
  148. * encmdq: 1 use command queue, 0 not.
  149. */
  150. int dpmgr_path_stop(disp_path_handle dp_handle, int encmdq);
  151. /* reset path , it will reset this path by calling each drviers reset function.
  152. * return 0.
  153. * dp_handle: disp path handle.
  154. * encmdq: 1 use command queue, 0 not.
  155. */
  156. int dpmgr_path_reset(disp_path_handle dp_handle, int encmdq);
  157. /* config data , it will config input or output data of this path.
  158. * now config contains three parts:
  159. * 1. dst dirty .it means dst with & dst hight need be updated.
  160. * 2. ovl dirty. it means ovl config need be updated.
  161. * 3. rdma dirty. it means rdma need be updated.
  162. * 4. wdma dirty. it means wdam need be updated.
  163. * return 0.
  164. * dp_handle: disp path handle.
  165. * encmdq: 1 use command queue, 0 not.
  166. */
  167. int dpmgr_path_config(disp_path_handle dp_handle, disp_ddp_path_config * config, int encmdq);
  168. /* path flush, this will enable mutex
  169. * return 0.
  170. * dp_handle: disp path handle.
  171. * encmdq: 1 use command queue, 0 not.
  172. */
  173. int dpmgr_path_flush(disp_path_handle dp_handle,int encmdq);
  174. /* this will dump modules info on this path.
  175. * return 0.
  176. * dp_handle: disp path handle.
  177. */
  178. int dpmgr_check_status(disp_path_handle dp_handle);
  179. /* this will deal with cmdq message:
  180. * return 0.
  181. * dp_handle: disp path handle.
  182. * trigger_loop_handle: triger thread.
  183. * state :
  184. CMDQ_BEFORE_STREAM_SOF // before sof.
  185. CMDQ_WAIT_STREAM_EOF_EVENT // wait sof
  186. CMDQ_CHECK_IDLE_AFTER_STREAM_EOF // check sof
  187. CMDQ_AFTER_STREAM_EOF // after sof
  188. */
  189. int dpmgr_path_build_cmdq(disp_path_handle dp_handle, void *trigger_loop_handle, CMDQ_STATE state);
  190. /* this will trigger this path. it will trigger each module and enable mutex.
  191. * return 0.
  192. * dp_handle: disp path handle.
  193. * trigger_loop_handle : trigger thread.
  194. */
  195. int dpmgr_path_trigger(disp_path_handle dp_handle, void *trigger_loop_handle, int encmdq);
  196. /* set signal to event. this if not irq signal, but user send event
  197. * return 0.
  198. * dp_handle: disp path handle.
  199. * event: path event.
  200. */
  201. int dpmgr_signal_event(disp_path_handle dp_handle, DISP_PATH_EVENT event);
  202. /* enable init will initialize wakequeue.
  203. * return 0.
  204. * dp_handle: disp path handle.
  205. * event: path event.
  206. */
  207. int dpmgr_enable_event(disp_path_handle dp_handle, DISP_PATH_EVENT event);
  208. /* disable event, related irq will not be received.
  209. * return 0.
  210. * dp_handle: disp path handle.
  211. * event: path event.
  212. */
  213. int dpmgr_disable_event(disp_path_handle dp_handle, DISP_PATH_EVENT event);
  214. /* map event to irq can change mappling between path event and irq .
  215. * return 0.
  216. * dp_handle: disp path handle.
  217. * event: path event.
  218. * irq_bit
  219. */
  220. int dpmgr_map_event_to_irq(disp_path_handle dp_handle, DISP_PATH_EVENT event, DDP_IRQ_BIT irq_bit);
  221. /* wait event, timeout (ms).
  222. * return
  223. * < 0, error.
  224. * 0 timeout
  225. * > 0 no timeout
  226. * event : disp event.
  227. * timeout :(ms).
  228. */
  229. int dpmgr_wait_event_timeout(disp_path_handle dp_handle, DISP_PATH_EVENT event, int timeout);
  230. /* wait event
  231. * return :
  232. * 0 , wait succesfull.
  233. * <0, wait error.
  234. * event : disp event.
  235. * timeout :(ms).
  236. */
  237. int dpmgr_wait_event(disp_path_handle dp_handle, DISP_PATH_EVENT event);
  238. /* power on, turn on each modules clk.
  239. * return 0.
  240. * dp_handle: disp path handle.
  241. * encmdq: 1 use command queue, 0 not.
  242. */
  243. int dpmgr_path_power_on(disp_path_handle dp_handle, CMDQ_SWITCH encmdq);
  244. /* power 0ff, turn off each modules clk, if all hande are closed. top clock will be off.
  245. * return 0.
  246. * dp_handle: disp path handle.
  247. * encmdq: 1 use command queue, 0 not.
  248. */
  249. int dpmgr_path_power_off(disp_path_handle dp_handle, CMDQ_SWITCH encmdq);
  250. /* set lcm utils. now only dis/dpi used.
  251. * return 0.
  252. * dp_handle: disp path handle.
  253. * lcm_drv: lcm driver
  254. */
  255. int dpmgr_set_lcm_utils(disp_path_handle dp_handle, void *lcm_drv);
  256. /* check if this path is busy. it wil check each module on this path.
  257. * return 0.
  258. * dp_handle: disp path handle.
  259. */
  260. int dpmgr_path_is_busy(disp_path_handle dp_handle);
  261. /* add parameter to this path.
  262. * return 0.
  263. * dp_handle: disp path handle.
  264. * io_evnet: not defined.
  265. * data : data.
  266. */
  267. int dpmgr_path_is_idle(disp_path_handle dp_handle);
  268. int dpmgr_path_set_parameter(disp_path_handle dp_handle, int io_evnet, void * data);
  269. /* get parameter of this path.
  270. * return 0.
  271. * dp_handle: disp path handle.
  272. * io_evnet: not defined.
  273. * data : data.
  274. */
  275. int dpmgr_path_get_parameter(disp_path_handle dp_handle,int io_evnet, void * data );
  276. /* get last config parameter of path
  277. * return pointer to last config
  278. * dp_handle: disp path handle.
  279. */
  280. disp_ddp_path_config *dpmgr_path_get_last_config(disp_path_handle dp_handle);
  281. #endif