mtk_drm_plane.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. * Author: CK Hu <ck.hu@mediatek.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef _MTK_DRM_PLANE_H_
  15. #define _MTK_DRM_PLANE_H_
  16. #include <drm/drm_crtc.h>
  17. #include <linux/types.h>
  18. #include <drm/mediatek_drm.h>
  19. #define MAKE_DISP_FORMAT_ID(id, bpp) (((id) << 8) | (bpp))
  20. #define MTK_PLANE_OVL_TIMELINE_ID(x) (x)
  21. /* /============================
  22. */
  23. /* structure declarations */
  24. /* /=========================== */
  25. enum DISP_ORIENTATION {
  26. DISP_ORIENTATION_0 = 0,
  27. DISP_ORIENTATION_90 = 1,
  28. DISP_ORIENTATION_180 = 2,
  29. DISP_ORIENTATION_270 = 3,
  30. };
  31. enum DISP_FORMAT {
  32. DISP_FORMAT_UNKNOWN = 0,
  33. DISP_FORMAT_RGB565 = MAKE_DISP_FORMAT_ID(1, 2),
  34. DISP_FORMAT_RGB888 = MAKE_DISP_FORMAT_ID(2, 3),
  35. DISP_FORMAT_BGR888 = MAKE_DISP_FORMAT_ID(3, 3),
  36. DISP_FORMAT_ARGB8888 = MAKE_DISP_FORMAT_ID(4, 4),
  37. DISP_FORMAT_ABGR8888 = MAKE_DISP_FORMAT_ID(5, 4),
  38. DISP_FORMAT_RGBA8888 = MAKE_DISP_FORMAT_ID(6, 4),
  39. DISP_FORMAT_BGRA8888 = MAKE_DISP_FORMAT_ID(7, 4),
  40. DISP_FORMAT_YUV422 = MAKE_DISP_FORMAT_ID(8, 2),
  41. DISP_FORMAT_XRGB8888 = MAKE_DISP_FORMAT_ID(9, 4),
  42. DISP_FORMAT_XBGR8888 = MAKE_DISP_FORMAT_ID(10, 4),
  43. DISP_FORMAT_RGBX8888 = MAKE_DISP_FORMAT_ID(11, 4),
  44. DISP_FORMAT_BGRX8888 = MAKE_DISP_FORMAT_ID(12, 4),
  45. DISP_FORMAT_UYVY = MAKE_DISP_FORMAT_ID(13, 2),
  46. DISP_FORMAT_YUV420_P = MAKE_DISP_FORMAT_ID(14, 2),
  47. DISP_FORMAT_YV12 = MAKE_DISP_FORMAT_ID(16, 1), /* BPP = 1.5 */
  48. DISP_FORMAT_PARGB8888 = MAKE_DISP_FORMAT_ID(17, 4),
  49. DISP_FORMAT_PABGR8888 = MAKE_DISP_FORMAT_ID(18, 4),
  50. DISP_FORMAT_PRGBA8888 = MAKE_DISP_FORMAT_ID(19, 4),
  51. DISP_FORMAT_PBGRA8888 = MAKE_DISP_FORMAT_ID(20, 4),
  52. DISP_FORMAT_DIM = MAKE_DISP_FORMAT_ID(21, 0),
  53. DISP_FORMAT_BPP_MASK = 0xFF,
  54. };
  55. enum DISP_LAYER_TYPE {
  56. DISP_LAYER_2D = 0,
  57. DISP_LAYER_3D_SBS_0 = 0x1,
  58. DISP_LAYER_3D_SBS_90 = 0x2,
  59. DISP_LAYER_3D_SBS_180 = 0x3,
  60. DISP_LAYER_3D_SBS_270 = 0x4,
  61. DISP_LAYER_3D_TAB_0 = 0x10,
  62. DISP_LAYER_3D_TAB_90 = 0x20,
  63. DISP_LAYER_3D_TAB_180 = 0x30,
  64. DISP_LAYER_3D_TAB_270 = 0x40,
  65. };
  66. enum DISP_BUFFER_TYPE {
  67. /* normal memory */
  68. DISP_NORMAL_BUFFER = 0,
  69. /* normal memory but should not be dumpped within screenshot */
  70. DISP_PROTECT_BUFFER = 1,
  71. /* secure memory */
  72. DISP_SECURE_BUFFER = 2,
  73. DISP_SECURE_BUFFER_SHIFT = 0x10002
  74. };
  75. enum DISP_BUFFER_SOURCE {
  76. /* ion buffer */
  77. DISP_BUFFER_ION = 0,
  78. /* dim layer, const alpha */
  79. DISP_BUFFER_ALPHA = 1,
  80. /* mva buffer */
  81. DISP_BUFFER_MVA = 2,
  82. };
  83. enum DISP_ALPHA_TYPE {
  84. DISP_ALPHA_ONE = 0,
  85. DISP_ALPHA_SRC = 1,
  86. DISP_ALPHA_SRC_INVERT = 2,
  87. DISP_ALPHA_INVALID = 3,
  88. };
  89. enum DISP_YUV_RANGE_ENUM {
  90. DISP_YUV_BT601_FULL = 0,
  91. DISP_YUV_BT601 = 1,
  92. DISP_YUV_BT709 = 2
  93. };
  94. enum MTK_FMT_MODIFIER {
  95. MTK_FMT_NONE = 0,
  96. MTK_FMT_PREMULTIPLIER = 1,
  97. };
  98. enum MTK_PLANE_PROP {
  99. PLANE_PROP_NEXT_BUFF_IDX,
  100. PLANE_PROP_LYE_BLOB_IDX,
  101. PLANE_PROP_ALPHA_CON,
  102. PLANE_PROP_PLANE_ALPHA,
  103. PLANE_PROP_DATASPACE,
  104. PLANE_PROP_VPITCH,
  105. PLANE_PROP_COMPRESS,
  106. PLANE_PROP_DIM_COLOR,
  107. PLANE_PROP_MAX,
  108. };
  109. struct mtk_drm_plane {
  110. struct drm_plane base;
  111. struct drm_property *plane_property[PLANE_PROP_MAX];
  112. };
  113. #define to_mtk_plane(x) container_of(x, struct mtk_drm_plane, base)
  114. struct mtk_plane_pending_state {
  115. bool config;
  116. bool enable;
  117. dma_addr_t addr;
  118. size_t size;
  119. unsigned int pitch;
  120. unsigned int format;
  121. uint64_t modifier;
  122. unsigned int src_x;
  123. unsigned int src_y;
  124. unsigned int dst_x;
  125. unsigned int dst_y;
  126. unsigned int width;
  127. unsigned int height;
  128. bool dirty;
  129. bool is_sec;
  130. unsigned int prop_val[PLANE_PROP_MAX];
  131. };
  132. struct mtk_plane_input_config {
  133. void *src_base_addr;
  134. void *src_phy_addr;
  135. enum DISP_BUFFER_SOURCE buffer_source;
  136. enum DISP_BUFFER_TYPE security;
  137. enum DISP_FORMAT src_fmt;
  138. enum DISP_ALPHA_TYPE src_alpha;
  139. enum DISP_ALPHA_TYPE dst_alpha;
  140. enum DISP_YUV_RANGE_ENUM yuv_range;
  141. enum DISP_ORIENTATION layer_rotation;
  142. enum DISP_LAYER_TYPE layer_type;
  143. enum DISP_ORIENTATION video_rotation;
  144. __u32 next_buff_idx;
  145. /* fence to be waited before using this buffer. -1 if invalid */
  146. int src_fence_fd;
  147. /* fence struct of src_fence_fd, used in kernel */
  148. void *src_fence_struct;
  149. __u32 src_color_key;
  150. __u32 frm_sequence;
  151. void *dirty_roi_addr;
  152. __u16 dirty_roi_num;
  153. __u16 src_pitch;
  154. __u16 src_offset_x, src_offset_y;
  155. __u16 src_width, src_height;
  156. __u16 tgt_offset_x, tgt_offset_y;
  157. __u16 tgt_width, tgt_height;
  158. __u8 alpha_enable;
  159. __u8 alpha;
  160. __u8 sur_aen;
  161. __u8 src_use_color_key;
  162. __u8 layer_id;
  163. __u8 layer_enable;
  164. __u8 src_direct_link;
  165. __u8 isTdshp;
  166. __u8 identity;
  167. __u8 connected_type;
  168. __s8 ext_sel_layer;
  169. };
  170. struct mtk_plane_comp_state {
  171. uint32_t comp_id;
  172. uint32_t lye_id;
  173. int32_t ext_lye_id;
  174. uint32_t layer_caps;
  175. };
  176. struct mtk_plane_state {
  177. struct drm_plane_state base;
  178. struct mtk_plane_pending_state pending;
  179. struct mtk_plane_comp_state comp_state;
  180. struct drm_crtc *crtc;
  181. /* property */
  182. unsigned int prop_val[PLANE_PROP_MAX];
  183. };
  184. #define to_mtk_plane_state(x) container_of(x, struct mtk_plane_state, base)
  185. int mtk_plane_init(struct drm_device *dev, struct mtk_drm_plane *plane,
  186. unsigned int zpos, unsigned long possible_crtcs,
  187. enum drm_plane_type type);
  188. int mtk_get_format_bpp(uint32_t format);
  189. char *mtk_get_format_name(uint32_t format);
  190. void mtk_plane_get_comp_state(struct drm_plane *plane,
  191. struct mtk_plane_comp_state *comp_state,
  192. struct drm_crtc *crtc, int lock);
  193. unsigned int to_crtc_plane_index(unsigned int plane_index);
  194. #endif