ddp_manager.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. #ifndef __DDP_PATH_MANAGER_H__
  2. #define __DDP_PATH_MANAGER_H__
  3. #include <linux/sched.h>
  4. #include "ddp_info.h"
  5. #include "disp_event.h"
  6. #include "ddp_path.h"
  7. #include "cmdq_record.h"
  8. typedef enum {
  9. ENGINE_UFOE = DISP_MODULE_UFOE, /* add wdma0 after UFOE */
  10. ENGINE_OVL0 = DISP_MODULE_OVL0, /* add wdma0 after OVL0 */
  11. ENGINE_OVL1 = DISP_MODULE_OVL1, /* add wdma1 after OVL1 */
  12. ENGINE_DITHER = DISP_MODULE_DITHER, /* add wdma0 after OD */
  13. } ENGINE_DUMP;
  14. #define MAKE_DDP_IRQ_BIT(module, shift) ((module<<24)|(0x1<<shift))
  15. #define IRQBIT_MODULE(irqbit) (irqbit >> 24)
  16. #define IRQBIT_BIT(irqbit) (irqbit & 0xffffff)
  17. /* IRQ and module are combined to consist DDP IRQ */
  18. typedef enum {
  19. DDP_IRQ_OVL0_FRAME_COMPLETE = MAKE_DDP_IRQ_BIT(DISP_MODULE_OVL0, 1),
  20. DDP_IRQ_AAL_OUT_END_FRAME = MAKE_DDP_IRQ_BIT(DISP_MODULE_AAL, 1),
  21. DDP_IRQ_RDMA0_REG_UPDATE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA0, 0),
  22. DDP_IRQ_RDMA0_START = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA0, 1),
  23. DDP_IRQ_RDMA0_DONE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA0, 2),
  24. DDP_IRQ_RDMA0_UNDERFLOW = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA0, 3),
  25. DDP_IRQ_RDMA0_TARGET_LINE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA0, 4),
  26. DDP_IRQ_RDMA1_REG_UPDATE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA1, 0),
  27. DDP_IRQ_RDMA1_START = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA1, 1),
  28. DDP_IRQ_RDMA1_DONE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA1, 2),
  29. DDP_IRQ_RDMA1_UNDERFLOW = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA1, 3),
  30. DDP_IRQ_RDMA1_TARGET_LINE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA1, 4),
  31. DDP_IRQ_RDMA2_REG_UPDATE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA2, 0),
  32. DDP_IRQ_RDMA2_START = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA2, 1),
  33. DDP_IRQ_RDMA2_DONE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA2, 2),
  34. DDP_IRQ_RDMA2_UNDERFLOW = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA2, 3),
  35. DDP_IRQ_RDMA2_TARGET_LINE = MAKE_DDP_IRQ_BIT(DISP_MODULE_RDMA2, 4),
  36. DDP_IRQ_WDMA0_FRAME_COMPLETE = MAKE_DDP_IRQ_BIT(DISP_MODULE_WDMA0, 0),
  37. DDP_IRQ_WDMA1_FRAME_COMPLETE = MAKE_DDP_IRQ_BIT(DISP_MODULE_WDMA1, 0),
  38. DDP_IRQ_DSI0_EXT_TE = MAKE_DDP_IRQ_BIT(DISP_MODULE_DSI0, 2),
  39. DDP_IRQ_DSI0_CMD_DONE = MAKE_DDP_IRQ_BIT(DISP_MODULE_DSI0, 2),
  40. DDP_IRQ_DSI0_FRAME_DONE = MAKE_DDP_IRQ_BIT(DISP_MODULE_DSI0, 4),
  41. DDP_IRQ_MUTEX0_SOF = MAKE_DDP_IRQ_BIT(DISP_MODULE_MUTEX, 0),
  42. DDP_IRQ_MUTEX1_SOF = MAKE_DDP_IRQ_BIT(DISP_MODULE_MUTEX, 1),
  43. DDP_IRQ_UNKNOWN = MAKE_DDP_IRQ_BIT(DISP_MODULE_UNKNOWN, 0),
  44. } DDP_IRQ_BIT;
  45. /* dpmgr_ioctl cmd definition */
  46. typedef enum {
  47. /* DSI operation */
  48. DDP_SWITCH_DSI_MODE = 0,
  49. DDP_STOP_VIDEO_MODE = 1,
  50. DDP_BACK_LIGHT = 2,
  51. DDP_SWITCH_LCM_MODE = 3,
  52. DDP_DPI_FACTORY_TEST = 4,
  53. DDP_DSI_IDLE_CLK_CLOSED = 5,
  54. DDP_DSI_IDLE_CLK_OPEN = 6,
  55. DDP_DSI_VFP_LP = 7,
  56. DDP_DSI_ENABLE_TE = 8,
  57. } DDP_IOCTL_NAME;
  58. /* path handle */
  59. typedef void *disp_path_handle;
  60. extern unsigned int gDDPError;
  61. /* Init ddp manager, now only register irq handler to ddp_irq.c
  62. * return 0 if ok or -1 if fail.
  63. */
  64. int dpmgr_init(void);
  65. /* create disp path handle , it will assign mutex to this handle, and cache this handle
  66. * to modules in scenario, and will assign default irq event to this handle.
  67. * return NULL if fail to create handle.
  68. * scenario: used to demininate path, and ddp manager will do operations
  69. * according to current scenario.
  70. * cmdq_handle : will save current config cmdqhandle, and if cmdq is enable , will
  71. use cmdq to write regitsers.
  72. */
  73. disp_path_handle dpmgr_create_path(DDP_SCENARIO_ENUM scenario, cmdqRecHandle cmdq_handle);
  74. int dpmgr_get_scenario(disp_path_handle dp_handle);
  75. /* NOTES: modify path should call API like this :
  76. old_scenario = dpmgr_get_scenario(handle);
  77. dpmgr_modify_path_power_on_new_modules();
  78. dpmgr_modify_path();
  79. after cmdq handle exec done:
  80. dpmgr_modify_path_power_off_old_modules();
  81. */
  82. int dpmgr_modify_path_power_on_new_modules(disp_path_handle dp_handle,
  83. DDP_SCENARIO_ENUM new_scenario, int sw_only);
  84. int dpmgr_modify_path(disp_path_handle dp_handle, DDP_SCENARIO_ENUM new_scenario,
  85. cmdqRecHandle cmdq_handle, DDP_MODE isvdomode);
  86. int dpmgr_modify_path_power_off_old_modules(DDP_SCENARIO_ENUM old_scenario,
  87. DDP_SCENARIO_ENUM new_scenario, int sw_only);
  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, cmdqRecHandle cmdq_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_memout_clock(disp_path_handle dp_handle, int clock_switch);
  99. int dpmgr_path_add_memout(disp_path_handle dp_handle, ENGINE_DUMP engine, void *cmdq_handle);
  100. /* remove dump to path. should match between add dump and remove dump.
  101. * return 0 if success or -1 if fail.
  102. * dp_handle: disp path handle.
  103. * encmdq: 1 use command queue, 0 not.
  104. */
  105. int dpmgr_path_remove_memout(disp_path_handle dp_handle, void *cmdq_handle);
  106. /* query current path mutex.
  107. * return mutex.
  108. * dp_handle: disp path handle.
  109. */
  110. int dpmgr_path_get_mutex(disp_path_handle dp_handle);
  111. /* query current dst module.
  112. * return module enum.
  113. * dp_handle: disp path handle.
  114. */
  115. DISP_MODULE_ENUM dpmgr_path_get_dst_module(disp_path_handle dp_handle);
  116. /* set dst module, the default dst module maybe not right, so set real dst module on this path.
  117. * return 0.
  118. * dp_handle: disp path handle.
  119. * dst_module(one of bellow):
  120. * DISP_MODULE_DSI0
  121. * DISP_MODULE_DSI1
  122. * DISP_MODULE_DSIDUAL(DISP_MODULE_DSI0+DISP_MODULE_DSI1)
  123. * DISP_MODULE_DPI
  124. */
  125. int dpmgr_path_set_dst_module(disp_path_handle dp_handle, DISP_MODULE_ENUM dst_module);
  126. /* set mode type(sof source): cmd or video mode.
  127. * return 0.
  128. * dp_handle: disp path handle.
  129. * is_vdo_mode: 0 is cmd mode, 1 is video mode.
  130. */
  131. int dpmgr_path_set_video_mode(disp_path_handle dp_handle, int is_vdo_mode);
  132. /* init path , it will set mutex according to modules on this path and sof sorce.
  133. * and it will connect path , then initialize modules on this path.
  134. * return 0.
  135. * dp_handle: disp path handle.
  136. * encmdq: 1 use command queue, 0 not.
  137. */
  138. int dpmgr_path_init(disp_path_handle dp_handle, int encmdq);
  139. /*connect path , it will set mutex according to modules on this path and sof sorce.
  140. * and it will connect path , then initialize modules on this path.
  141. * return 0.
  142. * dp_handle: disp path handle.
  143. * encmdq: 1 use command queue, 0 not.
  144. */
  145. int dpmgr_path_connect(disp_path_handle dp_handle, int encmdq);
  146. /*connect path , it will set mutex according to modules on this path and sof sorce.
  147. * and it will connect path , then initialize modules on this path.
  148. * return 0.
  149. * dp_handle: disp path handle.
  150. * encmdq: 1 use command queue, 0 not.
  151. */
  152. int dpmgr_path_disconnect(disp_path_handle dp_handle, int encmdq);
  153. /* deinit path , it will clear mutex and dissconnect path.
  154. * return 0.
  155. * dp_handle: disp path handle.
  156. * encmdq: 1 use command queue, 0 not.
  157. */
  158. int dpmgr_path_deinit(disp_path_handle dp_handle, int encmdq);
  159. /* start path , it will start this path by calling each drviers start function.
  160. * return 0.
  161. * dp_handle: disp path handle.
  162. * encmdq: 1 use command queue, 0 not.
  163. */
  164. int dpmgr_path_start(disp_path_handle dp_handle, int encmdq);
  165. /* start path , it will stop this path by calling each drviers stop function.
  166. * return 0.
  167. * dp_handle: disp path handle.
  168. * encmdq: 1 use command queue, 0 not.
  169. */
  170. int dpmgr_path_stop(disp_path_handle dp_handle, int encmdq);
  171. /* reset path , it will reset this path by calling each drviers reset function.
  172. * return 0.
  173. * dp_handle: disp path handle.
  174. * encmdq: 1 use command queue, 0 not.
  175. */
  176. int dpmgr_path_reset(disp_path_handle dp_handle, int encmdq);
  177. /* config data , it will config input or output data of this path.
  178. * now config contains three parts:
  179. * 1. dst dirty .it means dst with & dst hight need be updated.
  180. * 2. ovl dirty. it means ovl config need be updated.
  181. * 3. rdma dirty. it means rdma need be updated.
  182. * 4. wdma dirty. it means wdam need be updated.
  183. * return 0.
  184. * dp_handle: disp path handle.
  185. * encmdq: 1 use command queue, 0 not.
  186. */
  187. int dpmgr_path_config(disp_path_handle dp_handle, disp_ddp_path_config *config, void *cmdq_handle);
  188. /* path flush, this will enable mutex
  189. * return 0.
  190. * dp_handle: disp path handle.
  191. * encmdq: 1 use command queue, 0 not.
  192. */
  193. int dpmgr_path_flush(disp_path_handle dp_handle, int encmdq);
  194. /* this will dump modules info on this path.
  195. * return 0.
  196. * dp_handle: disp path handle.
  197. */
  198. int dpmgr_check_status(disp_path_handle dp_handle);
  199. /* this will dump modules info on mutex path.
  200. * return 0.
  201. * mutex_id: mutex idex[0-4], if not in this range, will dump all.
  202. */
  203. void dpmgr_debug_path_status(int mutex_id);
  204. /* this will deal with cmdq message:
  205. * return 0.
  206. * dp_handle: disp path handle.
  207. * trigger_loop_handle: triger thread.
  208. * state :
  209. CMDQ_BEFORE_STREAM_SOF // before sof.
  210. CMDQ_WAIT_STREAM_EOF_EVENT // wait sof
  211. CMDQ_CHECK_IDLE_AFTER_STREAM_EOF // check sof
  212. CMDQ_AFTER_STREAM_EOF // after sof
  213. */
  214. int dpmgr_path_build_cmdq(disp_path_handle dp_handle, void *trigger_loop_handle, CMDQ_STATE state);
  215. /* this will trigger this path. it will trigger each module and enable mutex.
  216. * return 0.
  217. * dp_handle: disp path handle.
  218. * trigger_loop_handle : trigger thread.
  219. */
  220. int dpmgr_path_trigger(disp_path_handle dp_handle, void *trigger_loop_handle, int encmdq);
  221. /* set signal to event. this if not irq signal, but user send event
  222. * return 0.
  223. * dp_handle: disp path handle.
  224. * event: path event.
  225. */
  226. int dpmgr_signal_event(disp_path_handle dp_handle, DISP_PATH_EVENT event);
  227. /* enable init will initialize wakequeue.
  228. * return 0.
  229. * dp_handle: disp path handle.
  230. * event: path event.
  231. */
  232. int dpmgr_enable_event(disp_path_handle dp_handle, DISP_PATH_EVENT event);
  233. /* disable event, related irq will not be received.
  234. * return 0.
  235. * dp_handle: disp path handle.
  236. * event: path event.
  237. */
  238. int dpmgr_disable_event(disp_path_handle dp_handle, DISP_PATH_EVENT event);
  239. /* map event to irq can change mappling between path event and irq .
  240. * return 0.
  241. * dp_handle: disp path handle.
  242. * event: path event.
  243. * irq_bit
  244. */
  245. int dpmgr_map_event_to_irq(disp_path_handle dp_handle, DISP_PATH_EVENT event, DDP_IRQ_BIT irq_bit);
  246. /* wait event, timeout (ms).
  247. * return
  248. * < 0, error.
  249. * 0 timeout
  250. * > 0 no timeout
  251. * event : disp event.
  252. * timeout :(ms).
  253. */
  254. int dpmgr_wait_event_timeout(disp_path_handle dp_handle, DISP_PATH_EVENT event, int timeout);
  255. /* wait event
  256. * return :
  257. * 0 , wait succesfull.
  258. * <0, wait error.
  259. * event : disp event.
  260. * timeout :(ms).
  261. */
  262. int dpmgr_wait_event(disp_path_handle dp_handle, DISP_PATH_EVENT event);
  263. /* power on, turn on each modules clk.
  264. * return 0.
  265. * dp_handle: disp path handle.
  266. * encmdq: 1 use command queue, 0 not.
  267. */
  268. int dpmgr_path_power_on(disp_path_handle dp_handle, CMDQ_SWITCH encmdq);
  269. /* power 0ff, turn off each modules clk, if all hande are closed. top clock will be off.
  270. * return 0.
  271. * dp_handle: disp path handle.
  272. * encmdq: 1 use command queue, 0 not.
  273. */
  274. int dpmgr_path_power_off(disp_path_handle dp_handle, CMDQ_SWITCH encmdq);
  275. /* DSI power on, turn on each modules clk.
  276. * return 0.
  277. * dp_handle: disp path handle.
  278. * encmdq: 1 use command queue, 0 not.
  279. */
  280. int dpmgr_path_dsi_power_on(disp_path_handle dp_handle, CMDQ_SWITCH encmdq);
  281. /* DSI power 0ff, turn off each modules clk, if all hande are closed. top clock will be off.
  282. * return 0.
  283. * dp_handle: disp path handle.
  284. * encmdq: 1 use command queue, 0 not.
  285. */
  286. int dpmgr_path_dsi_power_off(disp_path_handle dp_handle, CMDQ_SWITCH encmdq);
  287. /* wdma path power on, turn on each modules clk on wdma path.
  288. * return 0.
  289. */
  290. int dpmgr_wdma_path_force_power_on(void);
  291. /* wdma path power off, turn off each modules clk on wdma path.
  292. * return 0.
  293. */
  294. int dpmgr_wdma_path_force_power_off(void);
  295. /* set lcm utils. now only dis/dpi used.
  296. * return 0.
  297. * dp_handle: disp path handle.
  298. * lcm_drv: lcm driver
  299. */
  300. int dpmgr_set_lcm_utils(disp_path_handle dp_handle, void *lcm_drv);
  301. /* check if this path is busy. it wil check each module on this path.
  302. * return 0.
  303. * dp_handle: disp path handle.
  304. */
  305. int dpmgr_path_is_busy(disp_path_handle dp_handle);
  306. /* check if this path is idle. it wil check each module on this path.
  307. * return 0 if idle.
  308. * dp_handle: disp path handle.
  309. */
  310. int dpmgr_path_is_idle(disp_path_handle dp_handle);
  311. /* add parameter to this path.
  312. * return 0.
  313. * dp_handle: disp path handle.
  314. * io_evnet: not defined.
  315. * data : data.
  316. */
  317. int dpmgr_path_user_cmd(disp_path_handle dp_handle, int msg, unsigned long arg, void *cmdqhandle);
  318. int dpmgr_path_set_parameter(disp_path_handle dp_handle, int io_evnet, void *data);
  319. /* get parameter of this path.
  320. * return 0.
  321. * dp_handle: disp path handle.
  322. * io_evnet: not defined.
  323. * data : data.
  324. */
  325. int dpmgr_path_get_parameter(disp_path_handle dp_handle, int io_evnet, void *data);
  326. /* dpmgr_ioctl , it will call ioctl of ddp modules ioctl() to do some special config or setting.
  327. * return 0.
  328. * dp_handle: disp path handle.
  329. * cmdq_handle: cmdq handle
  330. * ioctl_cmd: ioctl cmd
  331. * params: ioctl parameters
  332. */
  333. int dpmgr_path_ioctl(disp_path_handle dp_handle, void *cmdq_handle, DDP_IOCTL_NAME ioctl_cmd,
  334. unsigned long *params);
  335. int dpmgr_path_enable_irq(disp_path_handle dp_handle, void *cmdq_handle, DDP_IRQ_LEVEL irq_level);
  336. /* get last config parameter of path
  337. * return pointer to last config
  338. * dp_handle: disp path handle.
  339. */
  340. disp_ddp_path_config *dpmgr_path_get_last_config(disp_path_handle dp_handle);
  341. void dpmgr_get_input_address(disp_path_handle dp_handle, unsigned long *addr);
  342. int dpmgr_path_enable_cascade(disp_path_handle dp_handle, void *cmdq_handle);
  343. int dpmgr_path_disable_cascade(disp_path_handle dp_handle, void *cmdq_handle);
  344. int dpmgr_set_ovl1_status(int status);
  345. int dpmgr_insert_ovl1_sub(disp_path_handle dp_handle, void *cmdq_handle);
  346. int dpmgr_remove_ovl1_sub(disp_path_handle dp_handle, void *cmdq_handle);
  347. /* factory mode test
  348. * return 0
  349. * module_name: module name.
  350. * encmdq: 1 use command queue, 0 not.
  351. * config:
  352. */
  353. int dpmgr_factory_mode_test(int module_name, void *cmdqhandle, void *config);
  354. int dpmgr_wait_ovl_available(int ovl_num);
  355. extern int dpmgr_path_get_handle(unsigned int *dp_handle, unsigned int *cmdq_handle);
  356. /* dpmgr_path_idle_on , it will restore of dst modules 's clock and top clock.
  357. * return 0.
  358. * dp_handle: disp path handle.
  359. * cmdq_handle: cmdq handle
  360. */
  361. int dpmgr_path_idle_on(disp_path_handle dp_handle, void *cmdq_handle, unsigned int level);
  362. /* dpmgr_path_idle_on , it will close of dst modules 's clock and top clock.
  363. * return 0.
  364. * dp_handle: disp path handle.
  365. * cmdq_handle: cmdq handle
  366. */
  367. int dpmgr_path_idle_off(disp_path_handle dp_handle, void *cmdq_handle, unsigned int level);
  368. int dpmgr_path_dsi_on(disp_path_handle dp_handle, void *cmdq_handle, unsigned int level);
  369. int dpmgr_path_dsi_off(disp_path_handle dp_handle, void *cmdq_handle, unsigned int level);
  370. int dpmgr_module_notify(DISP_MODULE_ENUM module, DISP_PATH_EVENT event);
  371. #ifdef CONFIG_SINGLE_PANEL_OUTPUT
  372. /*dpmgr_reset_module_handle, reset moudle path handle for single panel*/
  373. int dpmgr_reset_module_handle(disp_path_handle dp_handle);
  374. #endif
  375. /* disp_session_input_config *captured_session_input; */
  376. #endif