dpu_hw_sspp.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /* Copyright (c) 2015-2018, 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. #ifndef _DPU_HW_SSPP_H
  13. #define _DPU_HW_SSPP_H
  14. #include "dpu_hw_catalog.h"
  15. #include "dpu_hw_mdss.h"
  16. #include "dpu_hw_util.h"
  17. #include "dpu_hw_blk.h"
  18. #include "dpu_formats.h"
  19. struct dpu_hw_pipe;
  20. /**
  21. * Flags
  22. */
  23. #define DPU_SSPP_FLIP_LR BIT(0)
  24. #define DPU_SSPP_FLIP_UD BIT(1)
  25. #define DPU_SSPP_SOURCE_ROTATED_90 BIT(2)
  26. #define DPU_SSPP_ROT_90 BIT(3)
  27. #define DPU_SSPP_SOLID_FILL BIT(4)
  28. /**
  29. * Define all scaler feature bits in catalog
  30. */
  31. #define DPU_SSPP_SCALER ((1UL << DPU_SSPP_SCALER_RGB) | \
  32. (1UL << DPU_SSPP_SCALER_QSEED2) | \
  33. (1UL << DPU_SSPP_SCALER_QSEED3))
  34. /**
  35. * Component indices
  36. */
  37. enum {
  38. DPU_SSPP_COMP_0,
  39. DPU_SSPP_COMP_1_2,
  40. DPU_SSPP_COMP_2,
  41. DPU_SSPP_COMP_3,
  42. DPU_SSPP_COMP_MAX
  43. };
  44. /**
  45. * DPU_SSPP_RECT_SOLO - multirect disabled
  46. * DPU_SSPP_RECT_0 - rect0 of a multirect pipe
  47. * DPU_SSPP_RECT_1 - rect1 of a multirect pipe
  48. *
  49. * Note: HW supports multirect with either RECT0 or
  50. * RECT1. Considering no benefit of such configs over
  51. * SOLO mode and to keep the plane management simple,
  52. * we dont support single rect multirect configs.
  53. */
  54. enum dpu_sspp_multirect_index {
  55. DPU_SSPP_RECT_SOLO = 0,
  56. DPU_SSPP_RECT_0,
  57. DPU_SSPP_RECT_1,
  58. };
  59. enum dpu_sspp_multirect_mode {
  60. DPU_SSPP_MULTIRECT_NONE = 0,
  61. DPU_SSPP_MULTIRECT_PARALLEL,
  62. DPU_SSPP_MULTIRECT_TIME_MX,
  63. };
  64. enum {
  65. DPU_FRAME_LINEAR,
  66. DPU_FRAME_TILE_A4X,
  67. DPU_FRAME_TILE_A5X,
  68. };
  69. enum dpu_hw_filter {
  70. DPU_SCALE_FILTER_NEAREST = 0,
  71. DPU_SCALE_FILTER_BIL,
  72. DPU_SCALE_FILTER_PCMN,
  73. DPU_SCALE_FILTER_CA,
  74. DPU_SCALE_FILTER_MAX
  75. };
  76. enum dpu_hw_filter_alpa {
  77. DPU_SCALE_ALPHA_PIXEL_REP,
  78. DPU_SCALE_ALPHA_BIL
  79. };
  80. enum dpu_hw_filter_yuv {
  81. DPU_SCALE_2D_4X4,
  82. DPU_SCALE_2D_CIR,
  83. DPU_SCALE_1D_SEP,
  84. DPU_SCALE_BIL
  85. };
  86. struct dpu_hw_sharp_cfg {
  87. u32 strength;
  88. u32 edge_thr;
  89. u32 smooth_thr;
  90. u32 noise_thr;
  91. };
  92. struct dpu_hw_pixel_ext {
  93. /* scaling factors are enabled for this input layer */
  94. uint8_t enable_pxl_ext;
  95. int init_phase_x[DPU_MAX_PLANES];
  96. int phase_step_x[DPU_MAX_PLANES];
  97. int init_phase_y[DPU_MAX_PLANES];
  98. int phase_step_y[DPU_MAX_PLANES];
  99. /*
  100. * Number of pixels extension in left, right, top and bottom direction
  101. * for all color components. This pixel value for each color component
  102. * should be sum of fetch + repeat pixels.
  103. */
  104. int num_ext_pxls_left[DPU_MAX_PLANES];
  105. int num_ext_pxls_right[DPU_MAX_PLANES];
  106. int num_ext_pxls_top[DPU_MAX_PLANES];
  107. int num_ext_pxls_btm[DPU_MAX_PLANES];
  108. /*
  109. * Number of pixels needs to be overfetched in left, right, top and
  110. * bottom directions from source image for scaling.
  111. */
  112. int left_ftch[DPU_MAX_PLANES];
  113. int right_ftch[DPU_MAX_PLANES];
  114. int top_ftch[DPU_MAX_PLANES];
  115. int btm_ftch[DPU_MAX_PLANES];
  116. /*
  117. * Number of pixels needs to be repeated in left, right, top and
  118. * bottom directions for scaling.
  119. */
  120. int left_rpt[DPU_MAX_PLANES];
  121. int right_rpt[DPU_MAX_PLANES];
  122. int top_rpt[DPU_MAX_PLANES];
  123. int btm_rpt[DPU_MAX_PLANES];
  124. uint32_t roi_w[DPU_MAX_PLANES];
  125. uint32_t roi_h[DPU_MAX_PLANES];
  126. /*
  127. * Filter type to be used for scaling in horizontal and vertical
  128. * directions
  129. */
  130. enum dpu_hw_filter horz_filter[DPU_MAX_PLANES];
  131. enum dpu_hw_filter vert_filter[DPU_MAX_PLANES];
  132. };
  133. /**
  134. * struct dpu_hw_pipe_cfg : Pipe description
  135. * @layout: format layout information for programming buffer to hardware
  136. * @src_rect: src ROI, caller takes into account the different operations
  137. * such as decimation, flip etc to program this field
  138. * @dest_rect: destination ROI.
  139. * @index: index of the rectangle of SSPP
  140. * @mode: parallel or time multiplex multirect mode
  141. */
  142. struct dpu_hw_pipe_cfg {
  143. struct dpu_hw_fmt_layout layout;
  144. struct drm_rect src_rect;
  145. struct drm_rect dst_rect;
  146. enum dpu_sspp_multirect_index index;
  147. enum dpu_sspp_multirect_mode mode;
  148. };
  149. /**
  150. * struct dpu_hw_pipe_qos_cfg : Source pipe QoS configuration
  151. * @danger_lut: LUT for generate danger level based on fill level
  152. * @safe_lut: LUT for generate safe level based on fill level
  153. * @creq_lut: LUT for generate creq level based on fill level
  154. * @creq_vblank: creq value generated to vbif during vertical blanking
  155. * @danger_vblank: danger value generated during vertical blanking
  156. * @vblank_en: enable creq_vblank and danger_vblank during vblank
  157. * @danger_safe_en: enable danger safe generation
  158. */
  159. struct dpu_hw_pipe_qos_cfg {
  160. u32 danger_lut;
  161. u32 safe_lut;
  162. u64 creq_lut;
  163. u32 creq_vblank;
  164. u32 danger_vblank;
  165. bool vblank_en;
  166. bool danger_safe_en;
  167. };
  168. /**
  169. * enum CDP preload ahead address size
  170. */
  171. enum {
  172. DPU_SSPP_CDP_PRELOAD_AHEAD_32,
  173. DPU_SSPP_CDP_PRELOAD_AHEAD_64
  174. };
  175. /**
  176. * struct dpu_hw_pipe_cdp_cfg : CDP configuration
  177. * @enable: true to enable CDP
  178. * @ubwc_meta_enable: true to enable ubwc metadata preload
  179. * @tile_amortize_enable: true to enable amortization control for tile format
  180. * @preload_ahead: number of request to preload ahead
  181. * DPU_SSPP_CDP_PRELOAD_AHEAD_32,
  182. * DPU_SSPP_CDP_PRELOAD_AHEAD_64
  183. */
  184. struct dpu_hw_pipe_cdp_cfg {
  185. bool enable;
  186. bool ubwc_meta_enable;
  187. bool tile_amortize_enable;
  188. u32 preload_ahead;
  189. };
  190. /**
  191. * struct dpu_hw_pipe_ts_cfg - traffic shaper configuration
  192. * @size: size to prefill in bytes, or zero to disable
  193. * @time: time to prefill in usec, or zero to disable
  194. */
  195. struct dpu_hw_pipe_ts_cfg {
  196. u64 size;
  197. u64 time;
  198. };
  199. /**
  200. * struct dpu_hw_sspp_ops - interface to the SSPP Hw driver functions
  201. * Caller must call the init function to get the pipe context for each pipe
  202. * Assumption is these functions will be called after clocks are enabled
  203. */
  204. struct dpu_hw_sspp_ops {
  205. /**
  206. * setup_format - setup pixel format cropping rectangle, flip
  207. * @ctx: Pointer to pipe context
  208. * @cfg: Pointer to pipe config structure
  209. * @flags: Extra flags for format config
  210. * @index: rectangle index in multirect
  211. */
  212. void (*setup_format)(struct dpu_hw_pipe *ctx,
  213. const struct dpu_format *fmt, u32 flags,
  214. enum dpu_sspp_multirect_index index);
  215. /**
  216. * setup_rects - setup pipe ROI rectangles
  217. * @ctx: Pointer to pipe context
  218. * @cfg: Pointer to pipe config structure
  219. * @index: rectangle index in multirect
  220. */
  221. void (*setup_rects)(struct dpu_hw_pipe *ctx,
  222. struct dpu_hw_pipe_cfg *cfg,
  223. enum dpu_sspp_multirect_index index);
  224. /**
  225. * setup_pe - setup pipe pixel extension
  226. * @ctx: Pointer to pipe context
  227. * @pe_ext: Pointer to pixel ext settings
  228. */
  229. void (*setup_pe)(struct dpu_hw_pipe *ctx,
  230. struct dpu_hw_pixel_ext *pe_ext);
  231. /**
  232. * setup_sourceaddress - setup pipe source addresses
  233. * @ctx: Pointer to pipe context
  234. * @cfg: Pointer to pipe config structure
  235. * @index: rectangle index in multirect
  236. */
  237. void (*setup_sourceaddress)(struct dpu_hw_pipe *ctx,
  238. struct dpu_hw_pipe_cfg *cfg,
  239. enum dpu_sspp_multirect_index index);
  240. /**
  241. * setup_csc - setup color space coversion
  242. * @ctx: Pointer to pipe context
  243. * @data: Pointer to config structure
  244. */
  245. void (*setup_csc)(struct dpu_hw_pipe *ctx, struct dpu_csc_cfg *data);
  246. /**
  247. * setup_solidfill - enable/disable colorfill
  248. * @ctx: Pointer to pipe context
  249. * @const_color: Fill color value
  250. * @flags: Pipe flags
  251. * @index: rectangle index in multirect
  252. */
  253. void (*setup_solidfill)(struct dpu_hw_pipe *ctx, u32 color,
  254. enum dpu_sspp_multirect_index index);
  255. /**
  256. * setup_multirect - setup multirect configuration
  257. * @ctx: Pointer to pipe context
  258. * @index: rectangle index in multirect
  259. * @mode: parallel fetch / time multiplex multirect mode
  260. */
  261. void (*setup_multirect)(struct dpu_hw_pipe *ctx,
  262. enum dpu_sspp_multirect_index index,
  263. enum dpu_sspp_multirect_mode mode);
  264. /**
  265. * setup_sharpening - setup sharpening
  266. * @ctx: Pointer to pipe context
  267. * @cfg: Pointer to config structure
  268. */
  269. void (*setup_sharpening)(struct dpu_hw_pipe *ctx,
  270. struct dpu_hw_sharp_cfg *cfg);
  271. /**
  272. * setup_danger_safe_lut - setup danger safe LUTs
  273. * @ctx: Pointer to pipe context
  274. * @cfg: Pointer to pipe QoS configuration
  275. *
  276. */
  277. void (*setup_danger_safe_lut)(struct dpu_hw_pipe *ctx,
  278. struct dpu_hw_pipe_qos_cfg *cfg);
  279. /**
  280. * setup_creq_lut - setup CREQ LUT
  281. * @ctx: Pointer to pipe context
  282. * @cfg: Pointer to pipe QoS configuration
  283. *
  284. */
  285. void (*setup_creq_lut)(struct dpu_hw_pipe *ctx,
  286. struct dpu_hw_pipe_qos_cfg *cfg);
  287. /**
  288. * setup_qos_ctrl - setup QoS control
  289. * @ctx: Pointer to pipe context
  290. * @cfg: Pointer to pipe QoS configuration
  291. *
  292. */
  293. void (*setup_qos_ctrl)(struct dpu_hw_pipe *ctx,
  294. struct dpu_hw_pipe_qos_cfg *cfg);
  295. /**
  296. * setup_histogram - setup histograms
  297. * @ctx: Pointer to pipe context
  298. * @cfg: Pointer to histogram configuration
  299. */
  300. void (*setup_histogram)(struct dpu_hw_pipe *ctx,
  301. void *cfg);
  302. /**
  303. * setup_scaler - setup scaler
  304. * @ctx: Pointer to pipe context
  305. * @pipe_cfg: Pointer to pipe configuration
  306. * @pe_cfg: Pointer to pixel extension configuration
  307. * @scaler_cfg: Pointer to scaler configuration
  308. */
  309. void (*setup_scaler)(struct dpu_hw_pipe *ctx,
  310. struct dpu_hw_pipe_cfg *pipe_cfg,
  311. struct dpu_hw_pixel_ext *pe_cfg,
  312. void *scaler_cfg);
  313. /**
  314. * get_scaler_ver - get scaler h/w version
  315. * @ctx: Pointer to pipe context
  316. */
  317. u32 (*get_scaler_ver)(struct dpu_hw_pipe *ctx);
  318. /**
  319. * setup_cdp - setup client driven prefetch
  320. * @ctx: Pointer to pipe context
  321. * @cfg: Pointer to cdp configuration
  322. */
  323. void (*setup_cdp)(struct dpu_hw_pipe *ctx,
  324. struct dpu_hw_pipe_cdp_cfg *cfg);
  325. };
  326. /**
  327. * struct dpu_hw_pipe - pipe description
  328. * @base: hardware block base structure
  329. * @hw: block hardware details
  330. * @catalog: back pointer to catalog
  331. * @mdp: pointer to associated mdp portion of the catalog
  332. * @idx: pipe index
  333. * @cap: pointer to layer_cfg
  334. * @ops: pointer to operations possible for this pipe
  335. */
  336. struct dpu_hw_pipe {
  337. struct dpu_hw_blk base;
  338. struct dpu_hw_blk_reg_map hw;
  339. struct dpu_mdss_cfg *catalog;
  340. struct dpu_mdp_cfg *mdp;
  341. /* Pipe */
  342. enum dpu_sspp idx;
  343. const struct dpu_sspp_cfg *cap;
  344. /* Ops */
  345. struct dpu_hw_sspp_ops ops;
  346. };
  347. /**
  348. * dpu_hw_pipe - convert base object dpu_hw_base to container
  349. * @hw: Pointer to base hardware block
  350. * return: Pointer to hardware block container
  351. */
  352. static inline struct dpu_hw_pipe *to_dpu_hw_pipe(struct dpu_hw_blk *hw)
  353. {
  354. return container_of(hw, struct dpu_hw_pipe, base);
  355. }
  356. /**
  357. * dpu_hw_sspp_init - initializes the sspp hw driver object.
  358. * Should be called once before accessing every pipe.
  359. * @idx: Pipe index for which driver object is required
  360. * @addr: Mapped register io address of MDP
  361. * @catalog : Pointer to mdss catalog data
  362. * @is_virtual_pipe: is this pipe virtual pipe
  363. */
  364. struct dpu_hw_pipe *dpu_hw_sspp_init(enum dpu_sspp idx,
  365. void __iomem *addr, struct dpu_mdss_cfg *catalog,
  366. bool is_virtual_pipe);
  367. /**
  368. * dpu_hw_sspp_destroy(): Destroys SSPP driver context
  369. * should be called during Hw pipe cleanup.
  370. * @ctx: Pointer to SSPP driver context returned by dpu_hw_sspp_init
  371. */
  372. void dpu_hw_sspp_destroy(struct dpu_hw_pipe *ctx);
  373. #endif /*_DPU_HW_SSPP_H */