mdp.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  1. /* Copyright (c) 2008-2012, 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 MDP_H
  14. #define MDP_H
  15. #include <linux/kernel.h>
  16. #include <linux/sched.h>
  17. #include <linux/time.h>
  18. #include <linux/init.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/fb.h>
  21. #include <linux/hrtimer.h>
  22. #include <linux/msm_mdp.h>
  23. #include <linux/memory_alloc.h>
  24. #include <mach/hardware.h>
  25. #include <linux/msm_ion.h>
  26. #ifdef CONFIG_MSM_BUS_SCALING
  27. #include <mach/msm_bus.h>
  28. #include <mach/msm_bus_board.h>
  29. #endif
  30. #include <linux/io.h>
  31. #include <asm/system.h>
  32. #include <asm/mach-types.h>
  33. #include "msm_fb_panel.h"
  34. extern uint32 mdp_hw_revision;
  35. extern ulong mdp4_display_intf;
  36. extern spinlock_t mdp_spin_lock;
  37. extern int mdp_rev;
  38. extern int mdp_iommu_split_domain;
  39. extern struct mdp_csc_cfg mdp_csc_convert[4];
  40. extern struct mdp_csc_cfg_data csc_cfg_matrix[];
  41. extern struct workqueue_struct *mdp_hist_wq;
  42. extern uint32 mdp_intr_mask;
  43. #define MDP4_REVISION_V1 0
  44. #define MDP4_REVISION_V2 1
  45. #define MDP4_REVISION_V2_1 2
  46. #define MDP4_REVISION_NONE 0xffffffff
  47. #ifdef BIT
  48. #undef BIT
  49. #endif
  50. #define BIT(x) (1<<(x))
  51. #define MDPOP_NOP 0
  52. #define MDPOP_LR BIT(0) /* left to right flip */
  53. #define MDPOP_UD BIT(1) /* up and down flip */
  54. #define MDPOP_ROT90 BIT(2) /* rotate image to 90 degree */
  55. #define MDPOP_ROT180 (MDPOP_UD|MDPOP_LR)
  56. #define MDPOP_ROT270 (MDPOP_ROT90|MDPOP_UD|MDPOP_LR)
  57. #define MDPOP_ASCALE BIT(7)
  58. #define MDPOP_ALPHAB BIT(8) /* enable alpha blending */
  59. #define MDPOP_TRANSP BIT(9) /* enable transparency */
  60. #define MDPOP_DITHER BIT(10) /* enable dither */
  61. #define MDPOP_SHARPENING BIT(11) /* enable sharpening */
  62. #define MDPOP_BLUR BIT(12) /* enable blur */
  63. #define MDPOP_FG_PM_ALPHA BIT(13)
  64. #define MDPOP_LAYER_IS_FG BIT(14)
  65. #define MDP_ALLOC(x) kmalloc(x, GFP_KERNEL)
  66. struct mdp_buf_type {
  67. struct ion_handle *ihdl;
  68. u32 write_addr;
  69. u32 read_addr;
  70. u32 size;
  71. };
  72. struct mdp_table_entry {
  73. uint32_t reg;
  74. uint32_t val;
  75. };
  76. extern struct mdp_ccs mdp_ccs_yuv2rgb ;
  77. extern struct mdp_ccs mdp_ccs_rgb2yuv ;
  78. extern unsigned char hdmi_prim_display;
  79. extern unsigned char hdmi_prim_resolution;
  80. struct vsync {
  81. ktime_t vsync_time;
  82. struct completion vsync_comp;
  83. struct device *dev;
  84. struct work_struct vsync_work;
  85. int vsync_irq_enabled;
  86. int vsync_dma_enabled;
  87. int disabled_clocks;
  88. struct completion vsync_wait;
  89. atomic_t suspend;
  90. atomic_t vsync_resume;
  91. int sysfs_created;
  92. };
  93. extern struct vsync vsync_cntrl;
  94. /*
  95. * MDP Image Structure
  96. */
  97. typedef struct mdpImg_ {
  98. uint32 imgType; /* Image type */
  99. uint32 *bmy_addr; /* bitmap or y addr */
  100. uint32 *cbcr_addr; /* cbcr addr */
  101. uint32 width; /* image width */
  102. uint32 mdpOp; /* image opertion (rotation,flip up/down, alpha/tp) */
  103. uint32 tpVal; /* transparency color */
  104. uint32 alpha; /* alpha percentage 0%(0x0) ~ 100%(0x100) */
  105. int sp_value; /* sharpening strength */
  106. } MDPIMG;
  107. #define MDP_OUTP(addr, data) outpdw((addr), (data))
  108. #define MDP_BASE msm_mdp_base
  109. typedef enum {
  110. MDP_BC_SCALE_POINT2_POINT4,
  111. MDP_BC_SCALE_POINT4_POINT6,
  112. MDP_BC_SCALE_POINT6_POINT8,
  113. MDP_BC_SCALE_POINT8_1,
  114. MDP_BC_SCALE_UP,
  115. MDP_PR_SCALE_POINT2_POINT4,
  116. MDP_PR_SCALE_POINT4_POINT6,
  117. MDP_PR_SCALE_POINT6_POINT8,
  118. MDP_PR_SCALE_POINT8_1,
  119. MDP_PR_SCALE_UP,
  120. MDP_SCALE_BLUR,
  121. MDP_INIT_SCALE
  122. } MDP_SCALE_MODE;
  123. typedef enum {
  124. MDP_BLOCK_POWER_OFF,
  125. MDP_BLOCK_POWER_ON
  126. } MDP_BLOCK_POWER_STATE;
  127. typedef enum {
  128. MDP_CMD_BLOCK,
  129. MDP_OVERLAY0_BLOCK,
  130. MDP_MASTER_BLOCK,
  131. MDP_PPP_BLOCK,
  132. MDP_DMA2_BLOCK,
  133. MDP_DMA3_BLOCK,
  134. MDP_DMA_S_BLOCK,
  135. MDP_DMA_E_BLOCK,
  136. MDP_OVERLAY1_BLOCK,
  137. MDP_OVERLAY2_BLOCK,
  138. MDP_MAX_BLOCK
  139. } MDP_BLOCK_TYPE;
  140. /* Let's keep Q Factor power of 2 for optimization */
  141. #define MDP_SCALE_Q_FACTOR 512
  142. #ifdef CONFIG_FB_MSM_MDP31
  143. #define MDP_MAX_X_SCALE_FACTOR (MDP_SCALE_Q_FACTOR*8)
  144. #define MDP_MIN_X_SCALE_FACTOR (MDP_SCALE_Q_FACTOR/8)
  145. #define MDP_MAX_Y_SCALE_FACTOR (MDP_SCALE_Q_FACTOR*8)
  146. #define MDP_MIN_Y_SCALE_FACTOR (MDP_SCALE_Q_FACTOR/8)
  147. #else
  148. #define MDP_MAX_X_SCALE_FACTOR (MDP_SCALE_Q_FACTOR*4)
  149. #define MDP_MIN_X_SCALE_FACTOR (MDP_SCALE_Q_FACTOR/4)
  150. #define MDP_MAX_Y_SCALE_FACTOR (MDP_SCALE_Q_FACTOR*4)
  151. #define MDP_MIN_Y_SCALE_FACTOR (MDP_SCALE_Q_FACTOR/4)
  152. #endif
  153. /* SHIM Q Factor */
  154. #define PHI_Q_FACTOR 29
  155. #define PQF_PLUS_5 (PHI_Q_FACTOR + 5) /* due to 32 phases */
  156. #define PQF_PLUS_4 (PHI_Q_FACTOR + 4)
  157. #define PQF_PLUS_2 (PHI_Q_FACTOR + 2) /* to get 4.0 */
  158. #define PQF_MINUS_2 (PHI_Q_FACTOR - 2) /* to get 0.25 */
  159. #define PQF_PLUS_5_PLUS_2 (PQF_PLUS_5 + 2)
  160. #define PQF_PLUS_5_MINUS_2 (PQF_PLUS_5 - 2)
  161. #define MDP_CONVTP(tpVal) (((tpVal&0xF800)<<8)|((tpVal&0x7E0)<<5)|((tpVal&0x1F)<<3))
  162. #define MDPOP_ROTATION (MDPOP_ROT90|MDPOP_LR|MDPOP_UD)
  163. #define MDP_CHKBIT(val, bit) ((bit) == ((val) & (bit)))
  164. /* overlay interface API defines */
  165. typedef enum {
  166. MORE_IBUF,
  167. FINAL_IBUF,
  168. COMPLETE_IBUF
  169. } MDP_IBUF_STATE;
  170. struct mdp_dirty_region {
  171. __u32 xoffset; /* source origin in the x-axis */
  172. __u32 yoffset; /* source origin in the y-axis */
  173. __u32 width; /* number of pixels in the x-axis */
  174. __u32 height; /* number of pixels in the y-axis */
  175. };
  176. /*
  177. * MDP extended data types
  178. */
  179. typedef struct mdp_roi_s {
  180. uint32 x;
  181. uint32 y;
  182. uint32 width;
  183. uint32 height;
  184. int32 lcd_x;
  185. int32 lcd_y;
  186. uint32 dst_width;
  187. uint32 dst_height;
  188. } MDP_ROI;
  189. typedef struct mdp_ibuf_s {
  190. uint8 *buf;
  191. uint32 bpp;
  192. uint32 ibuf_type;
  193. uint32 ibuf_width;
  194. uint32 ibuf_height;
  195. MDP_ROI roi;
  196. MDPIMG mdpImg;
  197. int32 dma_x;
  198. int32 dma_y;
  199. uint32 dma_w;
  200. uint32 dma_h;
  201. uint32 vsync_enable;
  202. } MDPIBUF;
  203. struct mdp_dma_data {
  204. boolean busy;
  205. boolean dmap_busy;
  206. boolean waiting;
  207. struct mutex ov_mutex;
  208. struct semaphore mutex;
  209. struct completion comp;
  210. struct completion dmap_comp;
  211. };
  212. extern struct list_head mdp_hist_lut_list;
  213. extern struct mutex mdp_hist_lut_list_mutex;
  214. struct mdp_hist_lut_mgmt {
  215. uint32_t block;
  216. struct mutex lock;
  217. struct list_head list;
  218. };
  219. struct mdp_hist_lut_info {
  220. uint32_t block;
  221. boolean is_enabled, has_sel_update;
  222. int bank_sel;
  223. };
  224. struct mdp_hist_mgmt {
  225. uint32_t block;
  226. uint32_t irq_term;
  227. uint32_t intr;
  228. uint32_t base;
  229. struct completion mdp_hist_comp;
  230. struct mutex mdp_hist_mutex;
  231. struct mutex mdp_do_hist_mutex;
  232. boolean mdp_is_hist_start, mdp_is_hist_data;
  233. boolean mdp_is_hist_valid, mdp_is_hist_init;
  234. uint8_t frame_cnt, bit_mask, num_bins;
  235. struct work_struct mdp_histogram_worker;
  236. struct mdp_histogram_data *hist;
  237. uint32_t *c0, *c1, *c2;
  238. uint32_t *extra_info;
  239. };
  240. enum {
  241. MDP_HIST_MGMT_DMA_P = 0,
  242. MDP_HIST_MGMT_DMA_S,
  243. MDP_HIST_MGMT_VG_1,
  244. MDP_HIST_MGMT_VG_2,
  245. MDP_HIST_MGMT_MAX,
  246. };
  247. extern struct mdp_hist_mgmt *mdp_hist_mgmt_array[];
  248. #define MDP_CMD_DEBUG_ACCESS_BASE (MDP_BASE+0x10000)
  249. #define MDP_DMA2_TERM 0x1
  250. #define MDP_DMA3_TERM 0x2
  251. #define MDP_PPP_TERM 0x4
  252. #define MDP_DMA_S_TERM 0x8
  253. #define MDP_DMA_E_TERM 0x10
  254. #ifdef CONFIG_FB_MSM_MDP40
  255. #define MDP_OVERLAY0_TERM 0x20
  256. #define MDP_OVERLAY1_TERM 0x40
  257. #define MDP_DMAP_TERM MDP_DMA2_TERM /* dmap == dma2 */
  258. #define MDP_PRIM_VSYNC_TERM 0x100
  259. #define MDP_EXTER_VSYNC_TERM 0x200
  260. #define MDP_PRIM_RDPTR_TERM 0x400
  261. #endif
  262. #define MDP_OVERLAY2_TERM 0x80
  263. #define MDP_HISTOGRAM_TERM_DMA_P 0x10000
  264. #define MDP_HISTOGRAM_TERM_DMA_S 0x20000
  265. #define MDP_HISTOGRAM_TERM_VG_1 0x40000
  266. #define MDP_HISTOGRAM_TERM_VG_2 0x80000
  267. #define MDP_VSYNC_TERM 0x1000
  268. #define ACTIVE_START_X_EN BIT(31)
  269. #define ACTIVE_START_Y_EN BIT(31)
  270. #define ACTIVE_HIGH 0
  271. #define ACTIVE_LOW 1
  272. #define MDP_DMA_S_DONE BIT(2)
  273. #define MDP_DMA_E_DONE BIT(3)
  274. #define LCDC_FRAME_START BIT(15)
  275. #define LCDC_UNDERFLOW BIT(16)
  276. #ifdef CONFIG_FB_MSM_MDP22
  277. #define MDP_DMA_P_DONE BIT(2)
  278. #else
  279. #define MDP_DMA_P_DONE BIT(14)
  280. #endif
  281. #define MDP_PPP_DONE BIT(0)
  282. #define TV_OUT_DMA3_DONE BIT(6)
  283. #define TV_ENC_UNDERRUN BIT(7)
  284. #define MDP_PRIM_RDPTR BIT(8)
  285. #define TV_OUT_DMA3_START BIT(13)
  286. #define MDP_HIST_DONE BIT(20)
  287. /*MDP4 MDP histogram interrupts*/
  288. /*note: these are only applicable on MDP4+ targets*/
  289. #define INTR_VG1_HISTOGRAM BIT(5)
  290. #define INTR_VG2_HISTOGRAM BIT(6)
  291. #define INTR_DMA_P_HISTOGRAM BIT(17)
  292. #define INTR_DMA_S_HISTOGRAM BIT(26)
  293. /*end MDP4 MDP histogram interrupts*/
  294. /* histogram interrupts */
  295. #define INTR_HIST_DONE BIT(1)
  296. #define INTR_HIST_RESET_SEQ_DONE BIT(0)
  297. #ifdef CONFIG_FB_MSM_MDP22
  298. #define MDP_ANY_INTR_MASK (MDP_PPP_DONE| \
  299. MDP_DMA_P_DONE| \
  300. TV_ENC_UNDERRUN)
  301. #else
  302. #define MDP_ANY_INTR_MASK (MDP_PPP_DONE| \
  303. MDP_DMA_P_DONE| \
  304. MDP_DMA_S_DONE| \
  305. MDP_DMA_E_DONE| \
  306. LCDC_UNDERFLOW| \
  307. TV_ENC_UNDERRUN)
  308. #endif
  309. #define MDP_TOP_LUMA 16
  310. #define MDP_TOP_CHROMA 0
  311. #define MDP_BOTTOM_LUMA 19
  312. #define MDP_BOTTOM_CHROMA 3
  313. #define MDP_LEFT_LUMA 22
  314. #define MDP_LEFT_CHROMA 6
  315. #define MDP_RIGHT_LUMA 25
  316. #define MDP_RIGHT_CHROMA 9
  317. #define CLR_G 0x0
  318. #define CLR_B 0x1
  319. #define CLR_R 0x2
  320. #define CLR_ALPHA 0x3
  321. #define CLR_Y CLR_G
  322. #define CLR_CB CLR_B
  323. #define CLR_CR CLR_R
  324. /* from lsb to msb */
  325. #define MDP_GET_PACK_PATTERN(a,x,y,z,bit) (((a)<<(bit*3))|((x)<<(bit*2))|((y)<<bit)|(z))
  326. /*
  327. * 0x0000 0x0004 0x0008 MDP sync config
  328. */
  329. #ifdef CONFIG_FB_MSM_MDP22
  330. #define MDP_SYNCFG_HGT_LOC 22
  331. #define MDP_SYNCFG_VSYNC_EXT_EN BIT(21)
  332. #define MDP_SYNCFG_VSYNC_INT_EN BIT(20)
  333. #else
  334. #define MDP_SYNCFG_HGT_LOC 21
  335. #define MDP_SYNCFG_VSYNC_EXT_EN BIT(20)
  336. #define MDP_SYNCFG_VSYNC_INT_EN BIT(19)
  337. #define MDP_HW_VSYNC
  338. #endif
  339. /*
  340. * 0x0018 MDP VSYNC THREASH
  341. */
  342. #define MDP_PRIM_BELOW_LOC 0
  343. #define MDP_PRIM_ABOVE_LOC 8
  344. /*
  345. * MDP_PRIMARY_VSYNC_OUT_CTRL
  346. * 0x0080,84,88 internal vsync pulse config
  347. */
  348. #define VSYNC_PULSE_EN BIT(31)
  349. #define VSYNC_PULSE_INV BIT(30)
  350. /*
  351. * 0x008c MDP VSYNC CONTROL
  352. */
  353. #define DISP0_VSYNC_MAP_VSYNC0 0
  354. #define DISP0_VSYNC_MAP_VSYNC1 BIT(0)
  355. #define DISP0_VSYNC_MAP_VSYNC2 BIT(0)|BIT(1)
  356. #define DISP1_VSYNC_MAP_VSYNC0 0
  357. #define DISP1_VSYNC_MAP_VSYNC1 BIT(2)
  358. #define DISP1_VSYNC_MAP_VSYNC2 BIT(2)|BIT(3)
  359. #define PRIMARY_LCD_SYNC_EN BIT(4)
  360. #define PRIMARY_LCD_SYNC_DISABLE 0
  361. #define SECONDARY_LCD_SYNC_EN BIT(5)
  362. #define SECONDARY_LCD_SYNC_DISABLE 0
  363. #define EXTERNAL_LCD_SYNC_EN BIT(6)
  364. #define EXTERNAL_LCD_SYNC_DISABLE 0
  365. /*
  366. * 0x101f0 MDP VSYNC Threshold
  367. */
  368. #define VSYNC_THRESHOLD_ABOVE_LOC 0
  369. #define VSYNC_THRESHOLD_BELOW_LOC 16
  370. #define VSYNC_ANTI_TEAR_EN BIT(31)
  371. /*
  372. * 0x10004 command config
  373. */
  374. #define MDP_CMD_DBGBUS_EN BIT(0)
  375. /*
  376. * 0x10124 or 0x101d4PPP source config
  377. */
  378. #define PPP_SRC_C0G_8BITS (BIT(1)|BIT(0))
  379. #define PPP_SRC_C1B_8BITS (BIT(3)|BIT(2))
  380. #define PPP_SRC_C2R_8BITS (BIT(5)|BIT(4))
  381. #define PPP_SRC_C3A_8BITS (BIT(7)|BIT(6))
  382. #define PPP_SRC_C0G_6BITS BIT(1)
  383. #define PPP_SRC_C1B_6BITS BIT(3)
  384. #define PPP_SRC_C2R_6BITS BIT(5)
  385. #define PPP_SRC_C0G_5BITS BIT(0)
  386. #define PPP_SRC_C1B_5BITS BIT(2)
  387. #define PPP_SRC_C2R_5BITS BIT(4)
  388. #define PPP_SRC_C3_ALPHA_EN BIT(8)
  389. #define PPP_SRC_BPP_INTERLVD_1BYTES 0
  390. #define PPP_SRC_BPP_INTERLVD_2BYTES BIT(9)
  391. #define PPP_SRC_BPP_INTERLVD_3BYTES BIT(10)
  392. #define PPP_SRC_BPP_INTERLVD_4BYTES (BIT(10)|BIT(9))
  393. #define PPP_SRC_BPP_ROI_ODD_X BIT(11)
  394. #define PPP_SRC_BPP_ROI_ODD_Y BIT(12)
  395. #define PPP_SRC_INTERLVD_2COMPONENTS BIT(13)
  396. #define PPP_SRC_INTERLVD_3COMPONENTS BIT(14)
  397. #define PPP_SRC_INTERLVD_4COMPONENTS (BIT(14)|BIT(13))
  398. /*
  399. * RGB666 unpack format
  400. * TIGHT means R6+G6+B6 together
  401. * LOOSE means R6+2 +G6+2+ B6+2 (with MSB)
  402. * or 2+R6 +2+G6 +2+B6 (with LSB)
  403. */
  404. #define PPP_SRC_UNPACK_TIGHT BIT(17)
  405. #define PPP_SRC_UNPACK_LOOSE 0
  406. #define PPP_SRC_UNPACK_ALIGN_LSB 0
  407. #define PPP_SRC_UNPACK_ALIGN_MSB BIT(18)
  408. #define PPP_SRC_FETCH_PLANES_INTERLVD 0
  409. #define PPP_SRC_FETCH_PLANES_PSEUDOPLNR BIT(20)
  410. #define PPP_SRC_WMV9_MODE BIT(21) /* window media version 9 */
  411. /*
  412. * 0x10138 PPP operation config
  413. */
  414. #define PPP_OP_SCALE_X_ON BIT(0)
  415. #define PPP_OP_SCALE_Y_ON BIT(1)
  416. #define PPP_OP_CONVERT_RGB2YCBCR 0
  417. #define PPP_OP_CONVERT_YCBCR2RGB BIT(2)
  418. #define PPP_OP_CONVERT_ON BIT(3)
  419. #define PPP_OP_CONVERT_MATRIX_PRIMARY 0
  420. #define PPP_OP_CONVERT_MATRIX_SECONDARY BIT(4)
  421. #define PPP_OP_LUT_C0_ON BIT(5)
  422. #define PPP_OP_LUT_C1_ON BIT(6)
  423. #define PPP_OP_LUT_C2_ON BIT(7)
  424. /* rotate or blend enable */
  425. #define PPP_OP_ROT_ON BIT(8)
  426. #define PPP_OP_ROT_90 BIT(9)
  427. #define PPP_OP_FLIP_LR BIT(10)
  428. #define PPP_OP_FLIP_UD BIT(11)
  429. #define PPP_OP_BLEND_ON BIT(12)
  430. #define PPP_OP_BLEND_SRCPIXEL_ALPHA 0
  431. #define PPP_OP_BLEND_DSTPIXEL_ALPHA BIT(13)
  432. #define PPP_OP_BLEND_CONSTANT_ALPHA BIT(14)
  433. #define PPP_OP_BLEND_SRCPIXEL_TRANSP (BIT(13)|BIT(14))
  434. #define PPP_OP_BLEND_ALPHA_BLEND_NORMAL 0
  435. #define PPP_OP_BLEND_ALPHA_BLEND_REVERSE BIT(15)
  436. #define PPP_OP_DITHER_EN BIT(16)
  437. #define PPP_OP_COLOR_SPACE_RGB 0
  438. #define PPP_OP_COLOR_SPACE_YCBCR BIT(17)
  439. #define PPP_OP_SRC_CHROMA_RGB 0
  440. #define PPP_OP_SRC_CHROMA_H2V1 BIT(18)
  441. #define PPP_OP_SRC_CHROMA_H1V2 BIT(19)
  442. #define PPP_OP_SRC_CHROMA_420 (BIT(18)|BIT(19))
  443. #define PPP_OP_SRC_CHROMA_COSITE 0
  444. #define PPP_OP_SRC_CHROMA_OFFSITE BIT(20)
  445. #define PPP_OP_DST_CHROMA_RGB 0
  446. #define PPP_OP_DST_CHROMA_H2V1 BIT(21)
  447. #define PPP_OP_DST_CHROMA_H1V2 BIT(22)
  448. #define PPP_OP_DST_CHROMA_420 (BIT(21)|BIT(22))
  449. #define PPP_OP_DST_CHROMA_COSITE 0
  450. #define PPP_OP_DST_CHROMA_OFFSITE BIT(23)
  451. #define PPP_BLEND_CALPHA_TRNASP BIT(24)
  452. #define PPP_OP_BG_CHROMA_RGB 0
  453. #define PPP_OP_BG_CHROMA_H2V1 BIT(25)
  454. #define PPP_OP_BG_CHROMA_H1V2 BIT(26)
  455. #define PPP_OP_BG_CHROMA_420 BIT(25)|BIT(26)
  456. #define PPP_OP_BG_CHROMA_SITE_COSITE 0
  457. #define PPP_OP_BG_CHROMA_SITE_OFFSITE BIT(27)
  458. #define PPP_OP_DEINT_EN BIT(28)
  459. #define PPP_BLEND_BG_USE_ALPHA_SEL (1 << 0)
  460. #define PPP_BLEND_BG_ALPHA_REVERSE (1 << 3)
  461. #define PPP_BLEND_BG_SRCPIXEL_ALPHA (0 << 1)
  462. #define PPP_BLEND_BG_DSTPIXEL_ALPHA (1 << 1)
  463. #define PPP_BLEND_BG_CONSTANT_ALPHA (2 << 1)
  464. #define PPP_BLEND_BG_CONST_ALPHA_VAL(x) ((x) << 24)
  465. #define PPP_OP_DST_RGB 0
  466. #define PPP_OP_DST_YCBCR BIT(30)
  467. /*
  468. * 0x10150 PPP destination config
  469. */
  470. #define PPP_DST_C0G_8BIT (BIT(0)|BIT(1))
  471. #define PPP_DST_C1B_8BIT (BIT(3)|BIT(2))
  472. #define PPP_DST_C2R_8BIT (BIT(5)|BIT(4))
  473. #define PPP_DST_C3A_8BIT (BIT(7)|BIT(6))
  474. #define PPP_DST_C0G_6BIT BIT(1)
  475. #define PPP_DST_C1B_6BIT BIT(3)
  476. #define PPP_DST_C2R_6BIT BIT(5)
  477. #define PPP_DST_C0G_5BIT BIT(0)
  478. #define PPP_DST_C1B_5BIT BIT(2)
  479. #define PPP_DST_C2R_5BIT BIT(4)
  480. #define PPP_DST_C3A_8BIT (BIT(7)|BIT(6))
  481. #define PPP_DST_C3ALPHA_EN BIT(8)
  482. #define PPP_DST_PACKET_CNT_INTERLVD_2ELEM BIT(9)
  483. #define PPP_DST_PACKET_CNT_INTERLVD_3ELEM BIT(10)
  484. #define PPP_DST_PACKET_CNT_INTERLVD_4ELEM (BIT(10)|BIT(9))
  485. #define PPP_DST_PACKET_CNT_INTERLVD_6ELEM (BIT(11)|BIT(9))
  486. #define PPP_DST_PACK_LOOSE 0
  487. #define PPP_DST_PACK_TIGHT BIT(13)
  488. #define PPP_DST_PACK_ALIGN_LSB 0
  489. #define PPP_DST_PACK_ALIGN_MSB BIT(14)
  490. #define PPP_DST_OUT_SEL_AXI 0
  491. #define PPP_DST_OUT_SEL_MDDI BIT(15)
  492. #define PPP_DST_BPP_2BYTES BIT(16)
  493. #define PPP_DST_BPP_3BYTES BIT(17)
  494. #define PPP_DST_BPP_4BYTES (BIT(17)|BIT(16))
  495. #define PPP_DST_PLANE_INTERLVD 0
  496. #define PPP_DST_PLANE_PLANAR BIT(18)
  497. #define PPP_DST_PLANE_PSEUDOPLN BIT(19)
  498. #define PPP_DST_TO_TV BIT(20)
  499. #define PPP_DST_MDDI_PRIMARY 0
  500. #define PPP_DST_MDDI_SECONDARY BIT(21)
  501. #define PPP_DST_MDDI_EXTERNAL BIT(22)
  502. /*
  503. * 0x10180 DMA config
  504. */
  505. #define DMA_DSTC0G_8BITS (BIT(1)|BIT(0))
  506. #define DMA_DSTC1B_8BITS (BIT(3)|BIT(2))
  507. #define DMA_DSTC2R_8BITS (BIT(5)|BIT(4))
  508. #define DMA_DSTC0G_6BITS BIT(1)
  509. #define DMA_DSTC1B_6BITS BIT(3)
  510. #define DMA_DSTC2R_6BITS BIT(5)
  511. #define DMA_DSTC0G_5BITS BIT(0)
  512. #define DMA_DSTC1B_5BITS BIT(2)
  513. #define DMA_DSTC2R_5BITS BIT(4)
  514. #define DMA_PACK_TIGHT BIT(6)
  515. #define DMA_PACK_LOOSE 0
  516. #define DMA_PACK_ALIGN_LSB 0
  517. /*
  518. * use DMA_PACK_ALIGN_MSB if the upper 6 bits from 8 bits output
  519. * from LCDC block maps into 6 pins out to the panel
  520. */
  521. #define DMA_PACK_ALIGN_MSB BIT(7)
  522. #define DMA_PACK_PATTERN_RGB \
  523. (MDP_GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 2)<<8)
  524. #define DMA_PACK_PATTERN_BGR \
  525. (MDP_GET_PACK_PATTERN(0, CLR_B, CLR_G, CLR_R, 2)<<8)
  526. #define DMA_OUT_SEL_AHB 0
  527. #define DMA_OUT_SEL_LCDC BIT(20)
  528. #define DMA_IBUF_FORMAT_RGB888 0
  529. #define DMA_IBUF_FORMAT_xRGB8888_OR_ARGB8888 BIT(26)
  530. #ifdef CONFIG_FB_MSM_MDP303
  531. #define DMA_OUT_SEL_DSI_CMD BIT(19)
  532. #define DMA_OUT_SEL_DSI_VIDEO (3 << 19)
  533. #endif
  534. #ifdef CONFIG_FB_MSM_MDP22
  535. #define DMA_OUT_SEL_MDDI BIT(14)
  536. #define DMA_AHBM_LCD_SEL_PRIMARY 0
  537. #define DMA_AHBM_LCD_SEL_SECONDARY BIT(15)
  538. #define DMA_IBUF_C3ALPHA_EN BIT(16)
  539. #define DMA_DITHER_EN BIT(17)
  540. #define DMA_MDDI_DMAOUT_LCD_SEL_PRIMARY 0
  541. #define DMA_MDDI_DMAOUT_LCD_SEL_SECONDARY BIT(18)
  542. #define DMA_MDDI_DMAOUT_LCD_SEL_EXTERNAL BIT(19)
  543. #define DMA_IBUF_FORMAT_RGB565 BIT(20)
  544. #define DMA_IBUF_FORMAT_RGB888_OR_ARGB8888 0
  545. #define DMA_IBUF_NONCONTIGUOUS BIT(21)
  546. #else
  547. #define DMA_OUT_SEL_MDDI BIT(19)
  548. #define DMA_AHBM_LCD_SEL_PRIMARY 0
  549. #define DMA_AHBM_LCD_SEL_SECONDARY 0
  550. #define DMA_IBUF_C3ALPHA_EN 0
  551. #define DMA_BUF_FORMAT_RGB565 BIT(25)
  552. #define DMA_DITHER_EN BIT(24) /* dma_p */
  553. #define DMA_DEFLKR_EN BIT(24) /* dma_e */
  554. #define DMA_MDDI_DMAOUT_LCD_SEL_PRIMARY 0
  555. #define DMA_MDDI_DMAOUT_LCD_SEL_SECONDARY 0
  556. #define DMA_MDDI_DMAOUT_LCD_SEL_EXTERNAL 0
  557. #define DMA_IBUF_FORMAT_RGB565 BIT(25)
  558. #define DMA_IBUF_NONCONTIGUOUS 0
  559. #endif
  560. /*
  561. * MDDI Register
  562. */
  563. #define MDDI_VDO_PACKET_DESC_16 0x5565
  564. #define MDDI_VDO_PACKET_DESC 0x5666 /* 18 bits */
  565. #define MDDI_VDO_PACKET_DESC_24 0x5888
  566. #define MDP_HIST_INTR_STATUS_OFF (0x0014)
  567. #define MDP_HIST_INTR_CLEAR_OFF (0x0018)
  568. #define MDP_HIST_INTR_ENABLE_OFF (0x001C)
  569. #ifdef CONFIG_FB_MSM_MDP40
  570. #define MDP_INTR_ENABLE (msm_mdp_base + 0x0050)
  571. #define MDP_INTR_STATUS (msm_mdp_base + 0x0054)
  572. #define MDP_INTR_CLEAR (msm_mdp_base + 0x0058)
  573. #define MDP_EBI2_LCD0 (msm_mdp_base + 0x0060)
  574. #define MDP_EBI2_LCD1 (msm_mdp_base + 0x0064)
  575. #define MDP_EBI2_PORTMAP_MODE (msm_mdp_base + 0x0070)
  576. #define MDP_DMA_P_HIST_INTR_STATUS (msm_mdp_base + 0x95014)
  577. #define MDP_DMA_P_HIST_INTR_CLEAR (msm_mdp_base + 0x95018)
  578. #define MDP_DMA_P_HIST_INTR_ENABLE (msm_mdp_base + 0x9501C)
  579. #else
  580. #define MDP_INTR_ENABLE (msm_mdp_base + 0x0020)
  581. #define MDP_INTR_STATUS (msm_mdp_base + 0x0024)
  582. #define MDP_INTR_CLEAR (msm_mdp_base + 0x0028)
  583. #define MDP_EBI2_LCD0 (msm_mdp_base + 0x003c)
  584. #define MDP_EBI2_LCD1 (msm_mdp_base + 0x0040)
  585. #define MDP_EBI2_PORTMAP_MODE (msm_mdp_base + 0x005c)
  586. #define MDP_DMA_P_HIST_INTR_STATUS (msm_mdp_base + 0x94014)
  587. #define MDP_DMA_P_HIST_INTR_CLEAR (msm_mdp_base + 0x94018)
  588. #define MDP_DMA_P_HIST_INTR_ENABLE (msm_mdp_base + 0x9401C)
  589. #endif
  590. #define MDP_FULL_BYPASS_WORD43 (msm_mdp_base + 0x101ac)
  591. #define MDP_CSC_PFMVn(n) (msm_mdp_base + 0x40400 + 4 * (n))
  592. #define MDP_CSC_PRMVn(n) (msm_mdp_base + 0x40440 + 4 * (n))
  593. #define MDP_CSC_PRE_BV1n(n) (msm_mdp_base + 0x40500 + 4 * (n))
  594. #define MDP_CSC_PRE_BV2n(n) (msm_mdp_base + 0x40540 + 4 * (n))
  595. #define MDP_CSC_POST_BV1n(n) (msm_mdp_base + 0x40580 + 4 * (n))
  596. #define MDP_CSC_POST_BV2n(n) (msm_mdp_base + 0x405c0 + 4 * (n))
  597. #ifdef CONFIG_FB_MSM_MDP31
  598. #define MDP_CSC_PRE_LV1n(n) (msm_mdp_base + 0x40600 + 4 * (n))
  599. #define MDP_CSC_PRE_LV2n(n) (msm_mdp_base + 0x40640 + 4 * (n))
  600. #define MDP_CSC_POST_LV1n(n) (msm_mdp_base + 0x40680 + 4 * (n))
  601. #define MDP_CSC_POST_LV2n(n) (msm_mdp_base + 0x406c0 + 4 * (n))
  602. #define MDP_PPP_SCALE_COEFF_LSBn(n) (msm_mdp_base + 0x50400 + 8 * (n))
  603. #define MDP_PPP_SCALE_COEFF_MSBn(n) (msm_mdp_base + 0x50404 + 8 * (n))
  604. #define SCALE_D0_SET 0
  605. #define SCALE_D1_SET BIT(0)
  606. #define SCALE_D2_SET BIT(1)
  607. #define SCALE_U1_SET (BIT(0)|BIT(1))
  608. #else
  609. #define MDP_CSC_PRE_LV1n(n) (msm_mdp_base + 0x40580 + 4 * (n))
  610. #endif
  611. #define MDP_CURSOR_WIDTH 64
  612. #define MDP_CURSOR_HEIGHT 64
  613. #define MDP_CURSOR_SIZE (MDP_CURSOR_WIDTH*MDP_CURSOR_WIDTH*4)
  614. #define MDP_DMA_P_LUT_C0_EN BIT(0)
  615. #define MDP_DMA_P_LUT_C1_EN BIT(1)
  616. #define MDP_DMA_P_LUT_C2_EN BIT(2)
  617. #define MDP_DMA_P_LUT_POST BIT(4)
  618. void mdp_hw_init(int splash);
  619. int mdp_ppp_pipe_wait(void);
  620. void mdp_pipe_kickoff(uint32 term, struct msm_fb_data_type *mfd);
  621. void mdp_clk_ctrl(int on);
  622. void mdp_pipe_ctrl(MDP_BLOCK_TYPE block, MDP_BLOCK_POWER_STATE state,
  623. boolean isr);
  624. void mdp_set_dma_pan_info(struct fb_info *info, struct mdp_dirty_region *dirty,
  625. boolean sync);
  626. void mdp_dma_pan_update(struct fb_info *info);
  627. void mdp_refresh_screen(unsigned long data);
  628. int mdp_ppp_blit(struct fb_info *info, struct mdp_blit_req *req);
  629. void mdp_lcd_update_workqueue_handler(struct work_struct *work);
  630. void mdp_vsync_resync_workqueue_handler(struct work_struct *work);
  631. void mdp_dma2_update(struct msm_fb_data_type *mfd);
  632. void mdp_vsync_cfg_regs(struct msm_fb_data_type *mfd,
  633. boolean first_time);
  634. void mdp_config_vsync(struct platform_device *pdev,
  635. struct msm_fb_data_type *mfd);
  636. uint32 mdp_get_lcd_line_counter(struct msm_fb_data_type *mfd);
  637. enum hrtimer_restart mdp_dma2_vsync_hrtimer_handler(struct hrtimer *ht);
  638. void mdp_set_scale(MDPIBUF *iBuf,
  639. uint32 dst_roi_width,
  640. uint32 dst_roi_height,
  641. boolean inputRGB, boolean outputRGB, uint32 *pppop_reg_ptr);
  642. void mdp_init_scale_table(void);
  643. void mdp_adjust_start_addr(uint8 **src0,
  644. uint8 **src1,
  645. int v_slice,
  646. int h_slice,
  647. int x,
  648. int y,
  649. uint32 width,
  650. uint32 height, int bpp, MDPIBUF *iBuf, int layer);
  651. void mdp_set_blend_attr(MDPIBUF *iBuf,
  652. uint32 *alpha,
  653. uint32 *tpVal,
  654. uint32 perPixelAlpha, uint32 *pppop_reg_ptr);
  655. int mdp_dma3_on(struct platform_device *pdev);
  656. int mdp_dma3_off(struct platform_device *pdev);
  657. void mdp_dma3_update(struct msm_fb_data_type *mfd);
  658. int mdp_lcdc_on(struct platform_device *pdev);
  659. int mdp_lcdc_off(struct platform_device *pdev);
  660. void mdp_lcdc_update(struct msm_fb_data_type *mfd);
  661. void mdp_free_splash_buffer(struct msm_fb_data_type *mfd);
  662. #ifdef CONFIG_FB_MSM_MDP303
  663. int mdp_dsi_video_on(struct platform_device *pdev);
  664. int mdp_dsi_video_off(struct platform_device *pdev);
  665. void mdp_dsi_video_update(struct msm_fb_data_type *mfd);
  666. void mdp3_dsi_cmd_dma_busy_wait(struct msm_fb_data_type *mfd);
  667. static inline int mdp4_dsi_cmd_off(struct platform_device *pdev)
  668. {
  669. return 0;
  670. }
  671. static inline int mdp4_dsi_video_off(struct platform_device *pdev)
  672. {
  673. return 0;
  674. }
  675. static inline int mdp4_lcdc_off(struct platform_device *pdev)
  676. {
  677. return 0;
  678. }
  679. static inline int mdp4_mddi_off(struct platform_device *pdev)
  680. {
  681. return 0;
  682. }
  683. static inline int mdp4_dsi_cmd_on(struct platform_device *pdev)
  684. {
  685. return 0;
  686. }
  687. static inline int mdp4_dsi_video_on(struct platform_device *pdev)
  688. {
  689. return 0;
  690. }
  691. static inline int mdp4_lcdc_on(struct platform_device *pdev)
  692. {
  693. return 0;
  694. }
  695. static inline int mdp4_mddi_on(struct platform_device *pdev)
  696. {
  697. return 0;
  698. }
  699. #endif
  700. #ifndef CONFIG_FB_MSM_MDDI
  701. static inline void mdp4_mddi_rdptr_init(int cndx)
  702. {
  703. /* empty */
  704. }
  705. #endif
  706. void set_cont_splashScreen_status(int);
  707. int mdp_hw_cursor_update(struct fb_info *info, struct fb_cursor *cursor);
  708. #if defined(CONFIG_FB_MSM_OVERLAY) && defined(CONFIG_FB_MSM_MDP40)
  709. int mdp_hw_cursor_sync_update(struct fb_info *info, struct fb_cursor *cursor);
  710. #else
  711. static inline int mdp_hw_cursor_sync_update(struct fb_info *info,
  712. struct fb_cursor *cursor)
  713. {
  714. return 0;
  715. }
  716. #endif
  717. void mdp_enable_irq(uint32 term);
  718. void mdp_disable_irq(uint32 term);
  719. void mdp_disable_irq_nosync(uint32 term);
  720. int mdp_get_bytes_per_pixel(uint32_t format,
  721. struct msm_fb_data_type *mfd);
  722. int mdp_set_core_clk(u32 rate);
  723. int mdp_clk_round_rate(u32 rate);
  724. unsigned long mdp_get_core_clk(void);
  725. #ifdef CONFIG_MSM_BUS_SCALING
  726. int mdp_bus_scale_update_request(u64 ab, u64 ib);
  727. #else
  728. static inline int mdp_bus_scale_update_request(u64 ab,
  729. u64 ib)
  730. {
  731. return 0;
  732. }
  733. #endif
  734. void mdp_dma_vsync_ctrl(int enable);
  735. void mdp_dma_video_vsync_ctrl(int enable);
  736. void mdp_dma_lcdc_vsync_ctrl(int enable);
  737. ssize_t mdp_dma_show_event(struct device *dev,
  738. struct device_attribute *attr, char *buf);
  739. ssize_t mdp_dma_video_show_event(struct device *dev,
  740. struct device_attribute *attr, char *buf);
  741. ssize_t mdp_dma_lcdc_show_event(struct device *dev,
  742. struct device_attribute *attr, char *buf);
  743. #ifdef MDP_HW_VSYNC
  744. void vsync_clk_prepare_enable(void);
  745. void vsync_clk_disable_unprepare(void);
  746. void mdp_hw_vsync_clk_enable(struct msm_fb_data_type *mfd);
  747. void mdp_hw_vsync_clk_disable(struct msm_fb_data_type *mfd);
  748. void mdp_vsync_clk_disable(void);
  749. void mdp_vsync_clk_enable(void);
  750. #endif
  751. #ifdef CONFIG_DEBUG_FS
  752. int mdp_debugfs_init(void);
  753. #endif
  754. void mdp_dma_s_update(struct msm_fb_data_type *mfd);
  755. int mdp_histogram_start(struct mdp_histogram_start_req *req);
  756. int mdp_histogram_stop(struct fb_info *info, uint32_t block);
  757. int mdp_histogram_ctrl(boolean en, uint32_t block);
  758. int mdp_histogram_ctrl_all(boolean en);
  759. int mdp_histogram_block2mgmt(uint32_t block, struct mdp_hist_mgmt **mgmt);
  760. void mdp_histogram_handle_isr(struct mdp_hist_mgmt *mgmt);
  761. void __mdp_histogram_kickoff(struct mdp_hist_mgmt *mgmt);
  762. void __mdp_histogram_reset(struct mdp_hist_mgmt *mgmt);
  763. void mdp_footswitch_ctrl(boolean on);
  764. #ifdef CONFIG_FB_MSM_MDP303
  765. static inline void mdp4_dsi_cmd_dma_busy_wait(struct msm_fb_data_type *mfd)
  766. {
  767. /* empty */
  768. }
  769. static inline void mdp4_dsi_blt_dmap_busy_wait(struct msm_fb_data_type *mfd)
  770. {
  771. /* empty */
  772. }
  773. static inline void mdp4_overlay_dsi_state_set(int state)
  774. {
  775. /* empty */
  776. }
  777. static inline int mdp4_overlay_dsi_state_get(void)
  778. {
  779. return 0;
  780. }
  781. #endif
  782. #ifndef CONFIG_FB_MSM_MDP40
  783. static inline void mdp_dsi_cmd_overlay_suspend(struct msm_fb_data_type *mfd)
  784. {
  785. /* empty */
  786. }
  787. static inline int msmfb_overlay_vsync_ctrl(struct fb_info *info,
  788. void __user *argp)
  789. {
  790. return 0;
  791. }
  792. #endif
  793. int mdp_ppp_v4l2_overlay_set(struct fb_info *info, struct mdp_overlay *req);
  794. int mdp_ppp_v4l2_overlay_clear(void);
  795. int mdp_ppp_v4l2_overlay_play(struct fb_info *info, bool bUserPtr,
  796. unsigned long srcp0_addr, unsigned long srcp0_size,
  797. unsigned long srcp1_addr, unsigned long srcp1_size);
  798. void mdp_update_pm(struct msm_fb_data_type *mfd, ktime_t pre_vsync);
  799. u32 mdp_get_panel_framerate(struct msm_fb_data_type *mfd);
  800. #ifdef CONFIG_FB_MSM_DTV
  801. void mdp_vid_quant_set(void);
  802. #else
  803. static inline void mdp_vid_quant_set(void)
  804. {
  805. /* empty */
  806. }
  807. #endif
  808. #endif /* MDP_H */