mdss_fb.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /* Copyright (c) 2008-2015, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #ifndef MDSS_FB_H
  14. #define MDSS_FB_H
  15. #include <linux/msm_ion.h>
  16. #include <linux/list.h>
  17. #include <linux/msm_mdp.h>
  18. #include <linux/types.h>
  19. #include <linux/notifier.h>
  20. #include "mdss_panel.h"
  21. #include "mdss_mdp_splash_logo.h"
  22. #define MSM_FB_DEFAULT_PAGE_SIZE 2
  23. #define MFD_KEY 0x11161126
  24. #define MSM_FB_MAX_DEV_LIST 32
  25. #define MSM_FB_ENABLE_DBGFS
  26. /*
  27. * This temporary work around of fence time-out modification is being added to handle
  28. * screen being locked up/blank after resuming - being discussed in SR# 01515705.
  29. * needs to be rolled back once a solution is found to address the issue at hand
  30. */
  31. #if defined(CONFIG_FB_MSM_MDSS_TC_DSI2LVDS_WXGA_PANEL) || defined(CONFIG_FB_MSM_MDSS_SDC_WXGA_PANEL)\
  32. || defined(CONFIG_FB_MSM_MDSS_CPT_QHD_PANEL) || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  33. #define WAIT_FENCE_FIRST_TIMEOUT (0.5 * MSEC_PER_SEC)
  34. #define WAIT_FENCE_FINAL_TIMEOUT (1 * MSEC_PER_SEC)
  35. #else
  36. #define WAIT_FENCE_FIRST_TIMEOUT (3 * MSEC_PER_SEC)
  37. #define WAIT_FENCE_FINAL_TIMEOUT (10 * MSEC_PER_SEC)
  38. #endif
  39. /* Display op timeout should be greater than total timeout */
  40. #define WAIT_DISP_OP_TIMEOUT ((WAIT_FENCE_FIRST_TIMEOUT + \
  41. WAIT_FENCE_FINAL_TIMEOUT) * MDP_MAX_FENCE_FD)
  42. #ifndef MAX
  43. #define MAX(x, y) (((x) > (y)) ? (x) : (y))
  44. #endif
  45. #ifndef MIN
  46. #define MIN(x, y) (((x) < (y)) ? (x) : (y))
  47. #endif
  48. #define MDP_PP_AD_BL_LINEAR 0x0
  49. #define MDP_PP_AD_BL_LINEAR_INV 0x1
  50. /**
  51. * enum mdp_notify_event - Different frame events to indicate frame update state
  52. *
  53. * @MDP_NOTIFY_FRAME_BEGIN: Frame update has started, the frame is about to
  54. * be programmed into hardware.
  55. * @MDP_NOTIFY_FRAME_READY: Frame ready to be kicked off, this can be used
  56. * as the last point in time to synchronized with
  57. * source buffers before kickoff.
  58. * @MDP_NOTIFY_FRAME_FLUSHED: Configuration of frame has been flushed and
  59. * DMA transfer has started.
  60. * @MDP_NOTIFY_FRAME_DONE: Frame DMA transfer has completed.
  61. * - For video mode panels this will indicate that
  62. * previous frame has been replaced by new one.
  63. * - For command mode/writeback frame done happens
  64. * as soon as the DMA of the frame is done.
  65. * @MDP_NOTIFY_FRAME_TIMEOUT: Frame DMA transfer has failed to complete within
  66. * a fair amount of time.
  67. */
  68. enum mdp_notify_event {
  69. MDP_NOTIFY_FRAME_BEGIN = 1,
  70. MDP_NOTIFY_FRAME_READY,
  71. MDP_NOTIFY_FRAME_FLUSHED,
  72. MDP_NOTIFY_FRAME_DONE,
  73. MDP_NOTIFY_FRAME_TIMEOUT,
  74. };
  75. struct disp_info_type_suspend {
  76. int op_enable;
  77. int panel_power_on;
  78. };
  79. struct disp_info_notify {
  80. int type;
  81. struct timer_list timer;
  82. struct completion comp;
  83. struct mutex lock;
  84. int value;
  85. int is_suspend;
  86. int ref_count;
  87. bool init_done;
  88. };
  89. struct msm_sync_pt_data {
  90. char *fence_name;
  91. u32 acq_fen_cnt;
  92. struct sync_fence *acq_fen[MDP_MAX_FENCE_FD];
  93. struct sw_sync_timeline *timeline;
  94. int timeline_value;
  95. u32 threshold;
  96. u32 retire_threshold;
  97. atomic_t commit_cnt;
  98. bool flushed;
  99. bool async_wait_fences;
  100. struct mutex sync_mutex;
  101. struct notifier_block notifier;
  102. struct sync_fence *(*get_retire_fence)
  103. (struct msm_sync_pt_data *sync_pt_data);
  104. };
  105. struct msm_fb_data_type;
  106. struct msm_mdp_interface {
  107. int (*fb_mem_alloc_fnc)(struct msm_fb_data_type *mfd);
  108. int (*fb_mem_get_iommu_domain)(void);
  109. int (*init_fnc)(struct msm_fb_data_type *mfd);
  110. int (*on_fnc)(struct msm_fb_data_type *mfd);
  111. int (*off_fnc)(struct msm_fb_data_type *mfd);
  112. /* called to release resources associated to the process */
  113. int (*release_fnc)(struct msm_fb_data_type *mfd, bool release_all);
  114. int (*kickoff_fnc)(struct msm_fb_data_type *mfd,
  115. struct mdp_display_commit *data);
  116. int (*ioctl_handler)(struct msm_fb_data_type *mfd, u32 cmd, void *arg);
  117. void (*dma_fnc)(struct msm_fb_data_type *mfd);
  118. int (*cursor_update)(struct msm_fb_data_type *mfd,
  119. struct fb_cursor *cursor);
  120. int (*lut_update)(struct msm_fb_data_type *mfd, struct fb_cmap *cmap);
  121. int (*do_histogram)(struct msm_fb_data_type *mfd,
  122. struct mdp_histogram *hist);
  123. int (*ad_calc_bl)(struct msm_fb_data_type *mfd, int bl_in,
  124. int *bl_out, bool *bl_out_notify);
  125. int (*ad_shutdown_cleanup)(struct msm_fb_data_type *mfd);
  126. int (*panel_register_done)(struct mdss_panel_data *pdata);
  127. u32 (*fb_stride)(u32 fb_index, u32 xres, int bpp);
  128. int (*splash_init_fnc)(struct msm_fb_data_type *mfd);
  129. struct msm_sync_pt_data *(*get_sync_fnc)(struct msm_fb_data_type *mfd,
  130. const struct mdp_buf_sync *buf_sync);
  131. void (*check_dsi_status)(struct work_struct *work, uint32_t interval);
  132. int (*configure_panel)(struct msm_fb_data_type *mfd, int mode);
  133. void *private1;
  134. };
  135. #define IS_CALIB_MODE_BL(mfd) (((mfd)->calib_mode) & MDSS_CALIB_MODE_BL)
  136. #define MDSS_BRIGHT_TO_BL(out, v, bl_max, max_bright) do {\
  137. out = (2 * (v) * (bl_max) + max_bright)\
  138. / (2 * max_bright);\
  139. } while (0)
  140. struct mdss_fb_proc_info {
  141. int pid;
  142. u32 ref_cnt;
  143. struct list_head list;
  144. };
  145. struct msm_fb_backup_type {
  146. struct fb_info info;
  147. struct mdp_display_commit disp_commit;
  148. };
  149. struct msm_fb_data_type {
  150. u32 key;
  151. u32 index;
  152. u32 ref_cnt;
  153. u32 fb_page;
  154. struct panel_id panel;
  155. struct mdss_panel_info *panel_info;
  156. int split_display;
  157. int split_fb_left;
  158. int split_fb_right;
  159. u32 dest;
  160. struct fb_info *fbi;
  161. int idle_time;
  162. struct delayed_work idle_notify_work;
  163. int op_enable;
  164. u32 fb_imgType;
  165. int panel_reconfig;
  166. u32 dst_format;
  167. int resume_state;
  168. int panel_power_on;
  169. struct disp_info_type_suspend suspend;
  170. struct ion_handle *ihdl;
  171. unsigned long iova;
  172. void *cursor_buf;
  173. unsigned long cursor_buf_phys;
  174. unsigned long cursor_buf_iova;
  175. int ext_ad_ctrl;
  176. u32 ext_bl_ctrl;
  177. u32 calib_mode;
  178. u32 ad_bl_level;
  179. u32 bl_level;
  180. u32 bl_previous;
  181. u32 bl_scale;
  182. u32 bl_min_lvl;
  183. u32 unset_bl_level;
  184. u32 bl_updated;
  185. u32 bl_level_scaled;
  186. u32 bl_level_prev_scaled;
  187. struct mutex bl_lock;
  188. struct mutex power_state;
  189. struct mutex ctx_lock;
  190. struct platform_device *pdev;
  191. u32 mdp_fb_page_protection;
  192. struct disp_info_notify update;
  193. struct disp_info_notify no_update;
  194. struct completion power_off_comp;
  195. struct msm_mdp_interface mdp;
  196. struct msm_sync_pt_data mdp_sync_pt_data;
  197. u32 acq_fen_cnt;
  198. struct sync_fence *acq_fen[MDP_MAX_FENCE_FD];
  199. int cur_rel_fen_fd;
  200. struct sync_pt *cur_rel_sync_pt;
  201. struct sync_fence *cur_rel_fence;
  202. struct sync_fence *last_rel_fence;
  203. struct sw_sync_timeline *timeline;
  204. int timeline_value;
  205. u32 last_acq_fen_cnt;
  206. struct sync_fence *last_acq_fen[MDP_MAX_FENCE_FD];
  207. struct mutex sync_mutex;
  208. /* for non-blocking */
  209. struct task_struct *disp_thread;
  210. atomic_t commits_pending;
  211. atomic_t kickoff_pending;
  212. wait_queue_head_t commit_wait_q;
  213. wait_queue_head_t idle_wait_q;
  214. wait_queue_head_t kickoff_wait_q;
  215. bool shutdown_pending;
  216. struct msm_fb_splash_info splash_info;
  217. wait_queue_head_t ioctl_q;
  218. atomic_t ioctl_ref_cnt;
  219. struct msm_fb_backup_type msm_fb_backup;
  220. struct completion power_set_comp;
  221. u32 is_power_setting;
  222. u32 dcm_state;
  223. struct list_head proc_list;
  224. u32 wait_for_kickoff;
  225. struct ion_client *fb_ion_client;
  226. struct ion_handle *fb_ion_handle;
  227. struct dma_buf *fbmem_buf;
  228. int blank_mode;
  229. };
  230. static inline void mdss_fb_update_notify_update(struct msm_fb_data_type *mfd)
  231. {
  232. int needs_complete = 0;
  233. mutex_lock(&mfd->update.lock);
  234. mfd->update.value = mfd->update.type;
  235. needs_complete = mfd->update.value == NOTIFY_TYPE_UPDATE;
  236. mutex_unlock(&mfd->update.lock);
  237. if (needs_complete) {
  238. complete(&mfd->update.comp);
  239. mutex_lock(&mfd->no_update.lock);
  240. if (mfd->no_update.timer.function)
  241. del_timer(&(mfd->no_update.timer));
  242. mfd->no_update.timer.expires = jiffies + (2 * HZ);
  243. add_timer(&mfd->no_update.timer);
  244. mutex_unlock(&mfd->no_update.lock);
  245. }
  246. }
  247. #ifdef CONFIG_FB_MSM_CAMERA_CSC
  248. extern u8 csc_update;
  249. extern u8 csc_change;
  250. #endif
  251. #if defined (CONFIG_FB_MSM_MDSS_DBG_SEQ_TICK)
  252. enum{
  253. COMMIT,
  254. KICKOFF,
  255. PP_DONE
  256. };
  257. struct mdss_tick_debug {
  258. u64 commit[10];
  259. u64 kickoff[10];
  260. u64 pingpong_done[10];
  261. u8 commit_cnt;
  262. u8 kickoff_cnt;
  263. u8 pingpong_done_cnt;
  264. };
  265. void mdss_dbg_tick_save(int op_name);
  266. #endif
  267. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQHD_PT_PANEL)
  268. enum TE_SETTING {
  269. TE_SET_INIT = -1,
  270. TE_SET_READY,
  271. TE_SET_START,
  272. TE_SET_DONE,
  273. TE_SET_FAIL,
  274. };
  275. #endif
  276. extern int boot_mode_lpm, boot_mode_recovery;
  277. int mdss_fb_get_phys_info(unsigned long *start, unsigned long *len, int fb_num);
  278. int mdss_fb_get_first_cmt_flag(void);
  279. void mdss_fb_set_backlight(struct msm_fb_data_type *mfd, u32 bkl_lvl);
  280. void mdss_fb_update_backlight(struct msm_fb_data_type *mfd);
  281. void mdss_fb_wait_for_fence(struct msm_sync_pt_data *sync_pt_data);
  282. void mdss_fb_signal_timeline(struct msm_sync_pt_data *sync_pt_data);
  283. struct sync_fence *mdss_fb_sync_get_fence(struct sw_sync_timeline *timeline,
  284. const char *fence_name, int val);
  285. int mdss_fb_register_mdp_instance(struct msm_mdp_interface *mdp);
  286. #if defined(CONFIG_MDNIE_TFT_MSM8X26) || defined (CONFIG_FB_MSM_MDSS_S6E8AA0A_HD_PANEL) || defined(CONFIG_MDNIE_VIDEO_ENHANCED)
  287. void mdss_negative_color(int is_negative_on);
  288. #endif
  289. int mdss_fb_dcm(struct msm_fb_data_type *mfd, int req_state);
  290. int mdss_fb_suspres_panel(struct device *dev, void *data);
  291. #endif /* MDSS_FB_H */