msm_drv.h 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512
  1. /*
  2. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (C) 2013 Red Hat
  5. * Author: Rob Clark <[email protected]>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __MSM_DRV_H__
  20. #define __MSM_DRV_H__
  21. #include <linux/kernel.h>
  22. #include <linux/clk.h>
  23. #include <linux/cpufreq.h>
  24. #include <linux/module.h>
  25. #include <linux/component.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/pm.h>
  28. #include <linux/pm_runtime.h>
  29. #include <linux/slab.h>
  30. #include <linux/list.h>
  31. #include <linux/iommu.h>
  32. #include <linux/types.h>
  33. #include <linux/of_graph.h>
  34. #include <linux/of_device.h>
  35. #include <linux/sde_io_util.h>
  36. #include <linux/sde_vm_event.h>
  37. #include <linux/sizes.h>
  38. #include <linux/kthread.h>
  39. #include <linux/version.h>
  40. #include <drm/drm_atomic.h>
  41. #include <drm/drm_atomic_helper.h>
  42. #include <drm/drm_plane_helper.h>
  43. #include <drm/drm_fb_helper.h>
  44. #include <drm/msm_drm.h>
  45. #include <drm/sde_drm.h>
  46. #include <drm/drm_file.h>
  47. #include <drm/drm_gem.h>
  48. #include <drm/drm_dsc.h>
  49. #include <drm/drm_bridge.h>
  50. #include "sde_power_handle.h"
  51. #define GET_MAJOR_REV(rev) ((rev) >> 28)
  52. #define GET_MINOR_REV(rev) (((rev) >> 16) & 0xFFF)
  53. #define GET_STEP_REV(rev) ((rev) & 0xFFFF)
  54. struct msm_kms;
  55. struct msm_gpu;
  56. struct msm_mmu;
  57. struct msm_mdss;
  58. struct msm_rd_state;
  59. struct msm_perf_state;
  60. struct msm_gem_submit;
  61. struct msm_fence_context;
  62. struct msm_fence_cb;
  63. struct msm_gem_address_space;
  64. struct msm_gem_vma;
  65. #define NUM_DOMAINS 4 /* one for KMS, then one per gpu core (?) */
  66. #define MAX_CRTCS 16
  67. #define MAX_PLANES 20
  68. #define MAX_ENCODERS 16
  69. #define MAX_BRIDGES 16
  70. #define MAX_CONNECTORS 16
  71. #define MSM_RGB 0x0
  72. #define MSM_YUV 0x1
  73. #define MSM_CHROMA_444 0x0
  74. #define MSM_CHROMA_422 0x1
  75. #define MSM_CHROMA_420 0x2
  76. #define TEARDOWN_DEADLOCK_RETRY_MAX 5
  77. #define DISP_DEV_ERR(dev, fmt, ...) dev_err(dev, "[%s:%d] " fmt, __func__, __LINE__, ##__VA_ARGS__)
  78. struct msm_file_private {
  79. rwlock_t queuelock;
  80. struct list_head submitqueues;
  81. int queueid;
  82. /* update the refcount when user driver calls power_ctrl IOCTL */
  83. unsigned short enable_refcnt;
  84. /* protects enable_refcnt */
  85. struct mutex power_lock;
  86. };
  87. enum msm_mdp_plane_property {
  88. /* blob properties, always put these first */
  89. PLANE_PROP_CSC_V1,
  90. PLANE_PROP_CSC_DMA_V1,
  91. PLANE_PROP_INFO,
  92. PLANE_PROP_SCALER_LUT_ED,
  93. PLANE_PROP_SCALER_LUT_CIR,
  94. PLANE_PROP_SCALER_LUT_SEP,
  95. PLANE_PROP_SKIN_COLOR,
  96. PLANE_PROP_SKY_COLOR,
  97. PLANE_PROP_FOLIAGE_COLOR,
  98. PLANE_PROP_VIG_GAMUT,
  99. PLANE_PROP_VIG_IGC,
  100. PLANE_PROP_DMA_IGC,
  101. PLANE_PROP_DMA_GC,
  102. PLANE_PROP_FP16_GC,
  103. PLANE_PROP_FP16_CSC,
  104. /* # of blob properties */
  105. PLANE_PROP_BLOBCOUNT,
  106. /* range properties */
  107. PLANE_PROP_ZPOS = PLANE_PROP_BLOBCOUNT,
  108. PLANE_PROP_ALPHA,
  109. PLANE_PROP_COLOR_FILL,
  110. PLANE_PROP_H_DECIMATE,
  111. PLANE_PROP_V_DECIMATE,
  112. PLANE_PROP_INPUT_FENCE,
  113. PLANE_PROP_HUE_ADJUST,
  114. PLANE_PROP_SATURATION_ADJUST,
  115. PLANE_PROP_VALUE_ADJUST,
  116. PLANE_PROP_CONTRAST_ADJUST,
  117. PLANE_PROP_EXCL_RECT_V1,
  118. PLANE_PROP_PREFILL_SIZE,
  119. PLANE_PROP_PREFILL_TIME,
  120. PLANE_PROP_SCALER_V1,
  121. PLANE_PROP_SCALER_V2,
  122. PLANE_PROP_INVERSE_PMA,
  123. PLANE_PROP_FP16_IGC,
  124. PLANE_PROP_FP16_UNMULT,
  125. PLANE_PROP_UBWC_STATS_ROI,
  126. /* enum/bitmask properties */
  127. PLANE_PROP_BLEND_OP,
  128. PLANE_PROP_SRC_CONFIG,
  129. PLANE_PROP_FB_TRANSLATION_MODE,
  130. PLANE_PROP_MULTIRECT_MODE,
  131. /* total # of properties */
  132. PLANE_PROP_COUNT
  133. };
  134. enum msm_mdp_crtc_property {
  135. CRTC_PROP_INFO,
  136. CRTC_PROP_DEST_SCALER_LUT_ED,
  137. CRTC_PROP_DEST_SCALER_LUT_CIR,
  138. CRTC_PROP_DEST_SCALER_LUT_SEP,
  139. CRTC_PROP_DSPP_INFO,
  140. /* # of blob properties */
  141. CRTC_PROP_BLOBCOUNT,
  142. /* range properties */
  143. CRTC_PROP_INPUT_FENCE_TIMEOUT = CRTC_PROP_BLOBCOUNT,
  144. CRTC_PROP_OUTPUT_FENCE,
  145. CRTC_PROP_OUTPUT_FENCE_OFFSET,
  146. CRTC_PROP_DIM_LAYER_V1,
  147. CRTC_PROP_CORE_CLK,
  148. CRTC_PROP_CORE_AB,
  149. CRTC_PROP_CORE_IB,
  150. CRTC_PROP_LLCC_AB,
  151. CRTC_PROP_LLCC_IB,
  152. CRTC_PROP_DRAM_AB,
  153. CRTC_PROP_DRAM_IB,
  154. CRTC_PROP_ROT_PREFILL_BW,
  155. CRTC_PROP_ROT_CLK,
  156. CRTC_PROP_ROI_V1,
  157. CRTC_PROP_SECURITY_LEVEL,
  158. CRTC_PROP_DEST_SCALER,
  159. CRTC_PROP_CAPTURE_OUTPUT,
  160. CRTC_PROP_IDLE_PC_STATE,
  161. CRTC_PROP_CACHE_STATE,
  162. CRTC_PROP_VM_REQ_STATE,
  163. CRTC_PROP_NOISE_LAYER_V1,
  164. CRTC_PROP_FRAME_DATA_BUF,
  165. /* total # of properties */
  166. CRTC_PROP_COUNT
  167. };
  168. enum msm_mdp_conn_property {
  169. /* blob properties, always put these first */
  170. CONNECTOR_PROP_SDE_INFO,
  171. CONNECTOR_PROP_MODE_INFO,
  172. CONNECTOR_PROP_HDR_INFO,
  173. CONNECTOR_PROP_EXT_HDR_INFO,
  174. CONNECTOR_PROP_PP_DITHER,
  175. CONNECTOR_PROP_PP_CWB_DITHER,
  176. CONNECTOR_PROP_HDR_METADATA,
  177. CONNECTOR_PROP_DEMURA_PANEL_ID,
  178. CONNECTOR_PROP_DIMMING_BL_LUT,
  179. CONNECTOR_PROP_DNSC_BLUR,
  180. /* # of blob properties */
  181. CONNECTOR_PROP_BLOBCOUNT,
  182. /* range properties */
  183. CONNECTOR_PROP_OUT_FB = CONNECTOR_PROP_BLOBCOUNT,
  184. CONNECTOR_PROP_RETIRE_FENCE,
  185. CONN_PROP_RETIRE_FENCE_OFFSET,
  186. CONNECTOR_PROP_DST_X,
  187. CONNECTOR_PROP_DST_Y,
  188. CONNECTOR_PROP_DST_W,
  189. CONNECTOR_PROP_DST_H,
  190. CONNECTOR_PROP_ROI_V1,
  191. CONNECTOR_PROP_BL_SCALE,
  192. CONNECTOR_PROP_SV_BL_SCALE,
  193. CONNECTOR_PROP_SUPPORTED_COLORSPACES,
  194. CONNECTOR_PROP_DYN_BIT_CLK,
  195. CONNECTOR_PROP_DIMMING_CTRL,
  196. CONNECTOR_PROP_DIMMING_MIN_BL,
  197. CONNECTOR_PROP_EARLY_FENCE_LINE,
  198. CONNECTOR_PROP_DYN_TRANSFER_TIME,
  199. /* enum/bitmask properties */
  200. CONNECTOR_PROP_TOPOLOGY_NAME,
  201. CONNECTOR_PROP_TOPOLOGY_CONTROL,
  202. CONNECTOR_PROP_AUTOREFRESH,
  203. CONNECTOR_PROP_LP,
  204. CONNECTOR_PROP_FB_TRANSLATION_MODE,
  205. CONNECTOR_PROP_QSYNC_MODE,
  206. CONNECTOR_PROP_CMD_FRAME_TRIGGER_MODE,
  207. CONNECTOR_PROP_SET_PANEL_MODE,
  208. CONNECTOR_PROP_AVR_STEP,
  209. CONNECTOR_PROP_CACHE_STATE,
  210. CONNECTOR_PROP_DSC_MODE,
  211. CONNECTOR_PROP_WB_USAGE_TYPE,
  212. /* total # of properties */
  213. CONNECTOR_PROP_COUNT
  214. };
  215. #define MSM_GPU_MAX_RINGS 4
  216. #define MAX_H_TILES_PER_DISPLAY 2
  217. /**
  218. * enum msm_display_compression_type - compression method used for pixel stream
  219. * @MSM_DISPLAY_COMPRESSION_NONE: Pixel data is not compressed
  220. * @MSM_DISPLAY_COMPRESSION_DSC: DSC compresison is used
  221. * @MSM_DISPLAY_COMPRESSION_VDC: VDC compresison is used
  222. */
  223. enum msm_display_compression_type {
  224. MSM_DISPLAY_COMPRESSION_NONE,
  225. MSM_DISPLAY_COMPRESSION_DSC,
  226. MSM_DISPLAY_COMPRESSION_VDC
  227. };
  228. /**
  229. * enum msm_display_wd_jitter_type - Type of WD jitter used
  230. * @MSM_DISPLAY_WD_JITTER_NONE: No WD timer jitter enabled
  231. * @MSM_DISPLAY_WD_INSTANTANEOUS_JITTER: Instantaneous WD jitter enabled
  232. * @MSM_DISPLAY_WD_LTJ_JITTER: LTJ WD jitter enabled
  233. */
  234. enum msm_display_wd_jitter_type {
  235. MSM_DISPLAY_WD_JITTER_NONE = BIT(0),
  236. MSM_DISPLAY_WD_INSTANTANEOUS_JITTER = BIT(1),
  237. MSM_DISPLAY_WD_LTJ_JITTER = BIT(2),
  238. };
  239. #define MSM_DISPLAY_COMPRESSION_RATIO_NONE 1
  240. #define MSM_DISPLAY_COMPRESSION_RATIO_MAX 5
  241. /**
  242. * enum msm_display_spr_pack_type - sub pixel rendering pack patterns supported
  243. * @MSM_DISPLAY_SPR_TYPE_NONE: Bypass, no special packing
  244. * @MSM_DISPLAY_SPR_TYPE_PENTILE: pentile pack pattern
  245. * @MSM_DISPLAY_SPR_TYPE_RGBW: RGBW pack pattern
  246. * @MSM_DISPLAY_SPR_TYPE_YYGM: YYGM pack pattern
  247. * @MSM_DISPLAY_SPR_TYPE_YYGW: YYGW pack patterm
  248. * @MSM_DISPLAY_SPR_TYPE_MAX: max and invalid
  249. */
  250. enum msm_display_spr_pack_type {
  251. MSM_DISPLAY_SPR_TYPE_NONE,
  252. MSM_DISPLAY_SPR_TYPE_PENTILE,
  253. MSM_DISPLAY_SPR_TYPE_RGBW,
  254. MSM_DISPLAY_SPR_TYPE_YYGM,
  255. MSM_DISPLAY_SPR_TYPE_YYGW,
  256. MSM_DISPLAY_SPR_TYPE_MAX
  257. };
  258. static const char *msm_spr_pack_type_str[MSM_DISPLAY_SPR_TYPE_MAX] = {
  259. [MSM_DISPLAY_SPR_TYPE_NONE] = "",
  260. [MSM_DISPLAY_SPR_TYPE_PENTILE] = "pentile",
  261. [MSM_DISPLAY_SPR_TYPE_RGBW] = "rgbw",
  262. [MSM_DISPLAY_SPR_TYPE_YYGM] = "yygm",
  263. [MSM_DISPLAY_SPR_TYPE_YYGW] = "yygw",
  264. };
  265. /**
  266. * enum msm_display_caps - features/capabilities supported by displays
  267. * @MSM_DISPLAY_CAP_VID_MODE: Video or "active" mode supported
  268. * @MSM_DISPLAY_CAP_CMD_MODE: Command mode supported
  269. * @MSM_DISPLAY_CAP_HOT_PLUG: Hot plug detection supported
  270. * @MSM_DISPLAY_CAP_EDID: EDID supported
  271. * @MSM_DISPLAY_ESD_ENABLED: ESD feature enabled
  272. * @MSM_DISPLAY_CAP_MST_MODE: Display with MST support
  273. * @MSM_DISPLAY_SPLIT_LINK: Split Link enabled
  274. */
  275. enum msm_display_caps {
  276. MSM_DISPLAY_CAP_VID_MODE = BIT(0),
  277. MSM_DISPLAY_CAP_CMD_MODE = BIT(1),
  278. MSM_DISPLAY_CAP_HOT_PLUG = BIT(2),
  279. MSM_DISPLAY_CAP_EDID = BIT(3),
  280. MSM_DISPLAY_ESD_ENABLED = BIT(4),
  281. MSM_DISPLAY_CAP_MST_MODE = BIT(5),
  282. MSM_DISPLAY_SPLIT_LINK = BIT(6),
  283. };
  284. /**
  285. * enum panel_mode - panel operation mode
  286. * @MSM_DISPLAY_VIDEO_MODE: video mode panel
  287. * @MSM_DISPLAY_CMD_MODE: Command mode panel
  288. * @MODE_MAX:
  289. */
  290. enum panel_op_mode {
  291. MSM_DISPLAY_VIDEO_MODE = BIT(0),
  292. MSM_DISPLAY_CMD_MODE = BIT(1),
  293. MSM_DISPLAY_MODE_MAX = BIT(2)
  294. };
  295. /**
  296. * enum msm_display_dsc_mode - panel dsc mode
  297. * @MSM_DISPLAY_DSC_MODE_NONE: No operation
  298. * @MSM_DISPLAY_DSC_MODE_ENABLED: DSC is enabled
  299. * @MSM_DISPLAY_DSC_MODE_DISABLED: DSC is disabled
  300. */
  301. enum msm_display_dsc_mode {
  302. MSM_DISPLAY_DSC_MODE_NONE,
  303. MSM_DISPLAY_DSC_MODE_ENABLED,
  304. MSM_DISPLAY_DSC_MODE_DISABLED,
  305. };
  306. /**
  307. * struct msm_display_mode - wrapper for drm_display_mode
  308. * @base: drm_display_mode attached to this msm_mode
  309. * @private_flags: integer holding private driver mode flags
  310. * @private: pointer to private driver information
  311. */
  312. struct msm_display_mode {
  313. struct drm_display_mode *base;
  314. u32 private_flags;
  315. u32 *private;
  316. };
  317. /**
  318. * struct msm_sub_mode - msm display sub mode
  319. * @dsc_enabled: boolean used to indicate if dsc should be enabled
  320. */
  321. struct msm_sub_mode {
  322. enum msm_display_dsc_mode dsc_mode;
  323. };
  324. /**
  325. * struct msm_ratio - integer ratio
  326. * @numer: numerator
  327. * @denom: denominator
  328. */
  329. struct msm_ratio {
  330. uint32_t numer;
  331. uint32_t denom;
  332. };
  333. /**
  334. * enum msm_event_wait - type of HW events to wait for
  335. * @MSM_ENC_COMMIT_DONE - wait for the driver to flush the registers to HW
  336. * @MSM_ENC_TX_COMPLETE - wait for the HW to transfer the frame to panel
  337. * @MSM_ENC_VBLANK - wait for the HW VBLANK event (for driver-internal waiters)
  338. * @MSM_ENC_ACTIVE_REGION - wait for the TG to be in active pixel region
  339. */
  340. enum msm_event_wait {
  341. MSM_ENC_COMMIT_DONE = 0,
  342. MSM_ENC_TX_COMPLETE,
  343. MSM_ENC_VBLANK,
  344. MSM_ENC_ACTIVE_REGION,
  345. };
  346. /**
  347. * struct msm_roi_alignment - region of interest alignment restrictions
  348. * @xstart_pix_align: left x offset alignment restriction
  349. * @width_pix_align: width alignment restriction
  350. * @ystart_pix_align: top y offset alignment restriction
  351. * @height_pix_align: height alignment restriction
  352. * @min_width: minimum width restriction
  353. * @min_height: minimum height restriction
  354. */
  355. struct msm_roi_alignment {
  356. uint32_t xstart_pix_align;
  357. uint32_t width_pix_align;
  358. uint32_t ystart_pix_align;
  359. uint32_t height_pix_align;
  360. uint32_t min_width;
  361. uint32_t min_height;
  362. };
  363. /**
  364. * struct msm_roi_caps - display's region of interest capabilities
  365. * @enabled: true if some region of interest is supported
  366. * @merge_rois: merge rois before sending to display
  367. * @num_roi: maximum number of rois supported
  368. * @align: roi alignment restrictions
  369. */
  370. struct msm_roi_caps {
  371. bool enabled;
  372. bool merge_rois;
  373. uint32_t num_roi;
  374. struct msm_roi_alignment align;
  375. };
  376. /**
  377. * struct msm_display_dsc_info - defines dsc configuration
  378. * @config DSC encoder configuration
  379. * @scr_rev: DSC revision.
  380. * @initial_lines: Number of initial lines stored in encoder.
  381. * @pkt_per_line: Number of packets per line.
  382. * @bytes_in_slice: Number of bytes in slice.
  383. * @eol_byte_num: Valid bytes at the end of line.
  384. * @bytes_per_pkt Number of bytes in DSI packet
  385. * @pclk_per_line: Compressed width.
  386. * @slice_last_group_size: Size of last group in pixels.
  387. * @slice_per_pkt: Number of slices per packet.
  388. * @num_active_ss_per_enc: Number of active soft slices per encoder.
  389. * @source_color_space: Source color space of DSC encoder
  390. * @chroma_format: Chroma_format of DSC encoder.
  391. * @det_thresh_flatness: Flatness threshold.
  392. * @extra_width: Extra width required in timing calculations.
  393. * @pps_delay_ms: Post PPS command delay in milliseconds.
  394. * @dsc_4hsmerge_en: Using DSC 4HS merge topology
  395. * @dsc_4hsmerge_padding 4HS merge DSC pair padding value in bytes
  396. * @dsc_4hsmerge_alignment 4HS merge DSC alignment value in bytes
  397. * @half_panel_pu True for single and dual dsc encoders if partial
  398. * update sets the roi width to half of mode width
  399. * False in all other cases
  400. */
  401. struct msm_display_dsc_info {
  402. struct drm_dsc_config config;
  403. u8 scr_rev;
  404. int initial_lines;
  405. int pkt_per_line;
  406. int bytes_in_slice;
  407. int bytes_per_pkt;
  408. int eol_byte_num;
  409. int pclk_per_line;
  410. int slice_last_group_size;
  411. int slice_per_pkt;
  412. int num_active_ss_per_enc;
  413. int source_color_space;
  414. int chroma_format;
  415. int det_thresh_flatness;
  416. u32 extra_width;
  417. u32 pps_delay_ms;
  418. bool dsc_4hsmerge_en;
  419. u32 dsc_4hsmerge_padding;
  420. u32 dsc_4hsmerge_alignment;
  421. bool half_panel_pu;
  422. };
  423. /**
  424. * struct msm_display_vdc_info - defines vdc configuration
  425. * @version_major: major version number of VDC encoder.
  426. * @version_minor: minor version number of VDC encoder.
  427. * @source_color_space: source color space of VDC encoder
  428. * @chroma_format: chroma_format of VDC encoder.
  429. * @mppf_bpc_r_y: MPPF bpc for R/Y color component
  430. * @mppf_bpc_g_cb: MPPF bpc for G/Cb color component
  431. * @mppf_bpc_b_cr: MPPF bpc for B/Cr color component
  432. * @mppf_bpc_y: MPPF bpc for Y color component
  433. * @mppf_bpc_co: MPPF bpc for Co color component
  434. * @mppf_bpc_cg: MPPF bpc for Cg color component
  435. * @flatqp_vf_fbls: flatness qp very flat FBLs
  436. * @flatqp_vf_nbls: flatness qp very flat NBLs
  437. * @flatqp_sw_fbls: flatness qp somewhat flat FBLs
  438. * @flatqp_sw_nbls: flatness qp somewhat flat NBLs
  439. * @chroma_samples: number of chroma samples
  440. * @split_panel_enable: indicates whether split panel is enabled
  441. * @traffic_mode: indicates burst/non-burst mode
  442. * @flatness_qp_lut: LUT used to determine flatness QP
  443. * @max_qp_lut: LUT used to determine maximum QP
  444. * @tar_del_lut: LUT used to calculate RC target rate
  445. * @lbda_brate_lut: lambda bitrate LUT for encoder
  446. * @lbda_bf_lut: lambda buffer fullness lut for encoder
  447. * @lbda_brate_lut_interp: interpolated lambda bitrate LUT
  448. * @lbda_bf_lut_interp: interpolated lambda buffer fullness lut
  449. * @num_of_active_ss: number of active soft slices
  450. * @bits_per_component: number of bits per component.
  451. * @max_pixels_per_line: maximum pixels per line
  452. * @max_pixels_per_hs_line: maximum pixels per hs line
  453. * @max_lines_per_frame: maximum lines per frame
  454. * @max_lines_per_slice: maximum lines per slice
  455. * @chunk_size: chunk size for encoder
  456. * @chunk_size_bits: number of bits in the chunk
  457. * @avg_block_bits: average block bits
  458. * @per_chunk_pad_bits: number of bits per chunk pad
  459. * @tot_pad_bits: total padding bits
  460. * @rc_stuffing_bits: rate control stuffing bits
  461. * @chunk_adj_bits: number of adjacent bits in the chunk
  462. * @rc_buf_init_size_temp: temporary rate control buffer init size
  463. * @init_tx_delay_temp: initial tx delay
  464. * @rc_buffer_init_size: rate control buffer init size
  465. * @rc_init_tx_delay: rate control buffer init tx delay
  466. * @rc_init_tx_delay_px_times: rate control buffer init tx
  467. * delay times pixels
  468. * @rc_buffer_max_size: max size of rate control buffer
  469. * @rc_tar_rate_scale_temp_a: rate control target rate scale parameter
  470. * @rc_tar_rate_scale_temp_b: rate control target rate scale parameter
  471. * @rc_tar_rate_scale: rate control target rate scale
  472. * @block_max_bits: max bits in the block
  473. * @rc_lambda_bitrate_scale: rate control lambda bitrate scale
  474. * @rc_buffer_fullness_scale: rate control lambda fullness scale
  475. * @rc_fullness_offset_thresh: rate control lambda fullness threshold
  476. * @ramp_blocks: number of ramp blocks
  477. * @bits_per_pixel: number of bits per pixel.
  478. * @num_extra_mux_bits_init: initial value of number of extra mux bits
  479. * @extra_crop_bits: number of extra crop bits
  480. * @num_extra_mux_bits: value of number of extra mux bits
  481. * @mppf_bits_comp_0: mppf bits in color component 0
  482. * @mppf_bits_comp_1: mppf bits in color component 1
  483. * @mppf_bits_comp_2: mppf bits in color component 2
  484. * @min_block_bits: min number of block bits
  485. * @slice_height: slice height configuration of encoder.
  486. * @slice_width: slice width configuration of encoder.
  487. * @frame_width: frame width configuration of encoder
  488. * @frame_height: frame height configuration of encoder
  489. * @bytes_in_slice: Number of bytes in slice.
  490. * @bytes_per_pkt: Number of bytes in packet.
  491. * @eol_byte_num: Valid bytes at the end of line.
  492. * @pclk_per_line: Compressed width.
  493. * @slice_per_pkt: Number of slices per packet.
  494. * @pkt_per_line: Number of packets per line.
  495. * @min_ssm_delay: Min Sub-stream multiplexing delay
  496. * @max_ssm_delay: Max Sub-stream multiplexing delay
  497. * @input_ssm_out_latency: input Sub-stream multiplexing output latency
  498. * @input_ssm_out_latency_min: min input Sub-stream multiplexing output latency
  499. * @obuf_latency: Output buffer latency
  500. * @base_hs_latency: base hard-slice latency
  501. * @base_hs_latency_min: base hard-slice min latency
  502. * @base_hs_latency_pixels: base hard-slice latency pixels
  503. * @base_hs_latency_pixels_min: base hard-slice latency pixels(min)
  504. * @base_initial_lines: base initial lines
  505. * @base_top_up: base top up
  506. * @output_rate: output rate
  507. * @output_rate_ratio_100: output rate times 100
  508. * @burst_accum_pixels: burst accumulated pixels
  509. * @ss_initial_lines: soft-slice initial lines
  510. * @burst_initial_lines: burst mode initial lines
  511. * @initial_lines: initial lines
  512. * @obuf_base: output buffer base
  513. * @obuf_extra_ss0: output buffer extra ss0
  514. * @obuf_extra_ss1: output buffer extra ss1
  515. * @obuf_extra_burst: output buffer extra burst
  516. * @obuf_ss0: output buffer ss0
  517. * @obuf_ss1: output buffer ss1
  518. * @obuf_margin_words: output buffer margin words
  519. * @ob0_max_addr: output buffer 0 max address
  520. * @ob1_max_addr: output buffer 1 max address
  521. * @slice_width_orig: original slice width
  522. * @r2b0_max_addr: r2b0 max addr
  523. * @r2b1_max_addr: r1b1 max addr
  524. * @slice_num_px: number of pixels per slice
  525. * @rc_target_rate_threshold: rate control target rate threshold
  526. * @rc_fullness_offset_slope: rate control fullness offset slop
  527. * @pps_delay_ms: Post PPS command delay in milliseconds.
  528. * @version_release: release version of VDC encoder.
  529. * @slice_num_bits: number of bits per slice
  530. * @ramp_bits: number of ramp bits
  531. */
  532. struct msm_display_vdc_info {
  533. u8 version_major;
  534. u8 version_minor;
  535. u8 source_color_space;
  536. u8 chroma_format;
  537. u8 mppf_bpc_r_y;
  538. u8 mppf_bpc_g_cb;
  539. u8 mppf_bpc_b_cr;
  540. u8 mppf_bpc_y;
  541. u8 mppf_bpc_co;
  542. u8 mppf_bpc_cg;
  543. u8 flatqp_vf_fbls;
  544. u8 flatqp_vf_nbls;
  545. u8 flatqp_sw_fbls;
  546. u8 flatqp_sw_nbls;
  547. u8 chroma_samples;
  548. u8 split_panel_enable;
  549. u8 traffic_mode;
  550. u16 flatness_qp_lut[8];
  551. u16 max_qp_lut[8];
  552. u16 tar_del_lut[16];
  553. u16 lbda_brate_lut[16];
  554. u16 lbda_bf_lut[16];
  555. u16 lbda_brate_lut_interp[64];
  556. u16 lbda_bf_lut_interp[64];
  557. u8 num_of_active_ss;
  558. u8 bits_per_component;
  559. u16 max_pixels_per_line;
  560. u16 max_pixels_per_hs_line;
  561. u16 max_lines_per_frame;
  562. u16 max_lines_per_slice;
  563. u16 chunk_size;
  564. u16 chunk_size_bits;
  565. u16 avg_block_bits;
  566. u16 per_chunk_pad_bits;
  567. u16 tot_pad_bits;
  568. u16 rc_stuffing_bits;
  569. u16 chunk_adj_bits;
  570. u16 rc_buf_init_size_temp;
  571. u16 init_tx_delay_temp;
  572. u16 rc_buffer_init_size;
  573. u16 rc_init_tx_delay;
  574. u16 rc_init_tx_delay_px_times;
  575. u16 rc_buffer_max_size;
  576. u16 rc_tar_rate_scale_temp_a;
  577. u16 rc_tar_rate_scale_temp_b;
  578. u16 rc_tar_rate_scale;
  579. u16 block_max_bits;
  580. u16 rc_lambda_bitrate_scale;
  581. u16 rc_buffer_fullness_scale;
  582. u16 rc_fullness_offset_thresh;
  583. u16 ramp_blocks;
  584. u16 bits_per_pixel;
  585. u16 num_extra_mux_bits_init;
  586. u16 extra_crop_bits;
  587. u16 num_extra_mux_bits;
  588. u16 mppf_bits_comp_0;
  589. u16 mppf_bits_comp_1;
  590. u16 mppf_bits_comp_2;
  591. u16 min_block_bits;
  592. int slice_height;
  593. int slice_width;
  594. int frame_width;
  595. int frame_height;
  596. int bytes_in_slice;
  597. int bytes_per_pkt;
  598. int eol_byte_num;
  599. int pclk_per_line;
  600. int slice_per_pkt;
  601. int pkt_per_line;
  602. int min_ssm_delay;
  603. int max_ssm_delay;
  604. int input_ssm_out_latency;
  605. int input_ssm_out_latency_min;
  606. int obuf_latency;
  607. int base_hs_latency;
  608. int base_hs_latency_min;
  609. int base_hs_latency_pixels;
  610. int base_hs_latency_pixels_min;
  611. int base_initial_lines;
  612. int base_top_up;
  613. int output_rate;
  614. int output_rate_ratio_100;
  615. int burst_accum_pixels;
  616. int ss_initial_lines;
  617. int burst_initial_lines;
  618. int initial_lines;
  619. int obuf_base;
  620. int obuf_extra_ss0;
  621. int obuf_extra_ss1;
  622. int obuf_extra_burst;
  623. int obuf_ss0;
  624. int obuf_ss1;
  625. int obuf_margin_words;
  626. int ob0_max_addr;
  627. int ob1_max_addr;
  628. int slice_width_orig;
  629. int r2b0_max_addr;
  630. int r2b1_max_addr;
  631. u32 slice_num_px;
  632. u32 rc_target_rate_threshold;
  633. u32 rc_fullness_offset_slope;
  634. u32 pps_delay_ms;
  635. u32 version_release;
  636. u64 slice_num_bits;
  637. u64 ramp_bits;
  638. };
  639. /**
  640. * Bits/pixel target >> 4 (removing the fractional bits)
  641. * returns the integer bpp value from the drm_dsc_config struct
  642. */
  643. #define DSC_BPP(config) ((config).bits_per_pixel >> 4)
  644. /**
  645. * struct msm_compression_info - defined panel compression
  646. * @enabled: enabled/disabled
  647. * @comp_type: type of compression supported
  648. * @comp_ratio: compression ratio
  649. * @src_bpp: bits per pixel before compression
  650. * @tgt_bpp: bits per pixel after compression
  651. * @dsc_info: dsc configuration if the compression
  652. * supported is DSC
  653. * @vdc_info: vdc configuration if the compression
  654. * supported is VDC
  655. */
  656. struct msm_compression_info {
  657. bool enabled;
  658. enum msm_display_compression_type comp_type;
  659. u32 comp_ratio;
  660. u32 src_bpp;
  661. u32 tgt_bpp;
  662. union{
  663. struct msm_display_dsc_info dsc_info;
  664. struct msm_display_vdc_info vdc_info;
  665. };
  666. };
  667. /**
  668. * struct msm_display_topology - defines a display topology pipeline
  669. * @num_lm: number of layer mixers used
  670. * @num_enc: number of compression encoder blocks used
  671. * @num_intf: number of interfaces the panel is mounted on
  672. * @comp_type: type of compression supported
  673. */
  674. struct msm_display_topology {
  675. u32 num_lm;
  676. u32 num_enc;
  677. u32 num_intf;
  678. enum msm_display_compression_type comp_type;
  679. };
  680. /**
  681. * struct msm_dyn_clk_list - list of dynamic clock rates.
  682. * @count: number of supported clock rates
  683. * @rates: list of supported clock rates
  684. * @type: dynamic clock feature support type
  685. * @front_porches: list of clock rate matching porch compensation values
  686. * @pixel_clks_khz: list of clock rate matching pixel clock values
  687. */
  688. struct msm_dyn_clk_list {
  689. u32 count;
  690. u32 *rates;
  691. u32 type;
  692. u32 *front_porches;
  693. u32 *pixel_clks_khz;
  694. };
  695. /**
  696. * struct msm_display_wd_jitter_config - defines jitter properties for WD timer
  697. * @jitter_type: Type of WD jitter enabled.
  698. * @inst_jitter_numer: Instantaneous jitter numerator.
  699. * @inst_jitter_denom: Instantaneous jitter denominator.
  700. * @ltj_max_numer: LTJ max numerator.
  701. * @ltj_max_denom: LTJ max denominator.
  702. * @ltj_time_sec: LTJ time in seconds.
  703. */
  704. struct msm_display_wd_jitter_config {
  705. enum msm_display_wd_jitter_type jitter_type;
  706. u32 inst_jitter_numer;
  707. u32 inst_jitter_denom;
  708. u32 ltj_max_numer;
  709. u32 ltj_max_denom;
  710. u32 ltj_time_sec;
  711. };
  712. /**
  713. * struct msm_mode_info - defines all msm custom mode info
  714. * @frame_rate: frame_rate of the mode
  715. * @vtotal: vtotal calculated for the mode
  716. * @prefill_lines: prefill lines based on porches.
  717. * @jitter_numer: display panel jitter numerator configuration
  718. * @jitter_denom: display panel jitter denominator configuration
  719. * @clk_rate: DSI bit clock per lane in HZ.
  720. * @dfps_maxfps: max FPS of dynamic FPS
  721. * @topology: supported topology for the mode
  722. * @comp_info: compression info supported
  723. * @roi_caps: panel roi capabilities
  724. * @wide_bus_en: wide-bus mode cfg for interface module
  725. * @panel_mode_caps panel mode capabilities
  726. * @mdp_transfer_time_us Specifies the mdp transfer time for command mode
  727. * panels in microseconds.
  728. * @mdp_transfer_time_us_min Specifies the minimum possible mdp transfer time
  729. * for command mode panels in microseconds.
  730. * @mdp_transfer_time_us_max Specifies the maximum possible mdp transfer time
  731. * for command mode panels in microseconds.
  732. * @allowed_mode_switches: bit mask to indicate supported mode switch.
  733. * @disable_rsc_solver: Dynamically disable RSC solver for the timing mode due to lower bitclk rate.
  734. * @dyn_clk_list: List of dynamic clock rates for RFI.
  735. * @qsync_min_fps: qsync min fps rate
  736. * @wd_jitter: Info for WD jitter.
  737. * @vpadding: panel stacking height
  738. */
  739. struct msm_mode_info {
  740. uint32_t frame_rate;
  741. uint32_t vtotal;
  742. uint32_t prefill_lines;
  743. uint32_t jitter_numer;
  744. uint32_t jitter_denom;
  745. uint64_t clk_rate;
  746. uint32_t dfps_maxfps;
  747. struct msm_display_topology topology;
  748. struct msm_compression_info comp_info;
  749. struct msm_roi_caps roi_caps;
  750. bool wide_bus_en;
  751. u32 panel_mode_caps;
  752. u32 mdp_transfer_time_us;
  753. u32 mdp_transfer_time_us_min;
  754. u32 mdp_transfer_time_us_max;
  755. u32 allowed_mode_switches;
  756. bool disable_rsc_solver;
  757. struct msm_dyn_clk_list dyn_clk_list;
  758. u32 qsync_min_fps;
  759. struct msm_display_wd_jitter_config wd_jitter;
  760. u32 vpadding;
  761. };
  762. /**
  763. * struct msm_resource_caps_info - defines hw resources
  764. * @num_lm number of layer mixers available
  765. * @num_dsc number of dsc available
  766. * @num_vdc number of vdc available
  767. * @num_ctl number of ctl available
  768. * @num_3dmux number of 3d mux available
  769. * @max_mixer_width: max width supported by layer mixer
  770. */
  771. struct msm_resource_caps_info {
  772. uint32_t num_lm;
  773. uint32_t num_dsc;
  774. uint32_t num_vdc;
  775. uint32_t num_ctl;
  776. uint32_t num_3dmux;
  777. uint32_t max_mixer_width;
  778. };
  779. /**
  780. * struct msm_display_info - defines display properties
  781. * @intf_type: DRM_MODE_CONNECTOR_ display type
  782. * @capabilities: Bitmask of display flags
  783. * @num_of_h_tiles: Number of horizontal tiles in case of split interface
  784. * @h_tile_instance: Controller instance used per tile. Number of elements is
  785. * based on num_of_h_tiles
  786. * @is_connected: Set to true if display is connected
  787. * @width_mm: Physical width
  788. * @height_mm: Physical height
  789. * @max_width: Max width of display. In case of hot pluggable display
  790. * this is max width supported by controller
  791. * @max_height: Max height of display. In case of hot pluggable display
  792. * this is max height supported by controller
  793. * @clk_rate: DSI bit clock per lane in HZ.
  794. * @display_type: Enum for type of display
  795. * @is_te_using_watchdog_timer: Boolean to indicate watchdog TE is
  796. * used instead of panel TE in cmd mode panels
  797. * @poms_align_vsync: poms with vsync aligned
  798. * @roi_caps: Region of interest capability info
  799. * @qsync_min_fps Minimum fps supported by Qsync feature
  800. * @has_qsync_min_fps_list True if dsi-supported-qsync-min-fps-list exits
  801. * @has_avr_step_req Panel has defined requirement for AVR steps
  802. * @te_source vsync source pin information
  803. * @dsc_count: max dsc hw blocks used by display (only available
  804. * for dsi display)
  805. * @lm_count: max layer mixer blocks used by display (only available
  806. * for dsi display)
  807. */
  808. struct msm_display_info {
  809. int intf_type;
  810. uint32_t capabilities;
  811. enum panel_op_mode curr_panel_mode;
  812. uint32_t num_of_h_tiles;
  813. uint32_t h_tile_instance[MAX_H_TILES_PER_DISPLAY];
  814. bool is_connected;
  815. unsigned int width_mm;
  816. unsigned int height_mm;
  817. uint32_t max_width;
  818. uint32_t max_height;
  819. uint64_t clk_rate;
  820. uint32_t display_type;
  821. bool is_te_using_watchdog_timer;
  822. bool poms_align_vsync;
  823. struct msm_roi_caps roi_caps;
  824. uint32_t qsync_min_fps;
  825. bool has_qsync_min_fps_list;
  826. bool has_avr_step_req;
  827. uint32_t te_source;
  828. uint32_t dsc_count;
  829. uint32_t lm_count;
  830. };
  831. #define MSM_MAX_ROI 4
  832. /**
  833. * struct msm_roi_list - list of regions of interest for a drm object
  834. * @num_rects: number of valid rectangles in the roi array
  835. * @roi: list of roi rectangles
  836. */
  837. struct msm_roi_list {
  838. uint32_t num_rects;
  839. struct drm_clip_rect roi[MSM_MAX_ROI];
  840. };
  841. /**
  842. * struct - msm_display_kickoff_params - info for display features at kickoff
  843. * @rois: Regions of interest structure for mapping CRTC to Connector output
  844. */
  845. struct msm_display_kickoff_params {
  846. struct msm_roi_list *rois;
  847. struct drm_msm_ext_hdr_metadata *hdr_meta;
  848. };
  849. /**
  850. * struct - msm_display_conn_params - info of dpu display features
  851. * @qsync_mode: Qsync mode, where 0: disabled 1: continuous mode 2: oneshot
  852. * @qsync_update: Qsync settings were changed/updated
  853. */
  854. struct msm_display_conn_params {
  855. uint32_t qsync_mode;
  856. bool qsync_update;
  857. };
  858. /**
  859. * struct msm_drm_event - defines custom event notification struct
  860. * @base: base object required for event notification by DRM framework.
  861. * @event: event object required for event notification by DRM framework.
  862. */
  863. struct msm_drm_event {
  864. struct drm_pending_event base;
  865. struct drm_msm_event_resp event;
  866. };
  867. /* Commit/Event thread specific structure */
  868. struct msm_drm_thread {
  869. struct drm_device *dev;
  870. struct task_struct *thread;
  871. unsigned int crtc_id;
  872. struct kthread_worker worker;
  873. };
  874. struct msm_drm_private {
  875. struct drm_device *dev;
  876. struct msm_kms *kms;
  877. struct sde_power_handle phandle;
  878. /* subordinate devices, if present: */
  879. struct platform_device *gpu_pdev;
  880. /* top level MDSS wrapper device (for MDP5 only) */
  881. struct msm_mdss *mdss;
  882. /* possibly this should be in the kms component, but it is
  883. * shared by both mdp4 and mdp5..
  884. */
  885. struct hdmi *hdmi;
  886. /* eDP is for mdp5 only, but kms has not been created
  887. * when edp_bind() and edp_init() are called. Here is the only
  888. * place to keep the edp instance.
  889. */
  890. struct msm_edp *edp;
  891. /* DSI is shared by mdp4 and mdp5 */
  892. struct msm_dsi *dsi[2];
  893. /* when we have more than one 'msm_gpu' these need to be an array: */
  894. struct msm_gpu *gpu;
  895. struct msm_file_private *lastctx;
  896. struct drm_fb_helper *fbdev;
  897. struct msm_rd_state *rd; /* debugfs to dump all submits */
  898. struct msm_rd_state *hangrd; /* debugfs to dump hanging submits */
  899. struct msm_perf_state *perf;
  900. /*
  901. * List of inactive GEM objects. Every bo is either in the inactive_list
  902. * or gpu->active_list (for the gpu it is active on[1])
  903. *
  904. * These lists are protected by mm_lock. If struct_mutex is involved, it
  905. * should be aquired prior to mm_lock. One should *not* hold mm_lock in
  906. * get_pages()/vmap()/etc paths, as they can trigger the shrinker.
  907. *
  908. * [1] if someone ever added support for the old 2d cores, there could be
  909. * more than one gpu object
  910. */
  911. struct list_head inactive_list;
  912. struct mutex mm_lock;
  913. struct workqueue_struct *wq;
  914. /* crtcs pending async atomic updates: */
  915. uint32_t pending_crtcs;
  916. uint32_t pending_planes;
  917. wait_queue_head_t pending_crtcs_event;
  918. unsigned int num_planes;
  919. struct drm_plane *planes[MAX_PLANES];
  920. unsigned int num_crtcs;
  921. struct drm_crtc *crtcs[MAX_CRTCS];
  922. struct msm_drm_thread disp_thread[MAX_CRTCS];
  923. struct msm_drm_thread event_thread[MAX_CRTCS];
  924. struct task_struct *pp_event_thread;
  925. struct kthread_worker pp_event_worker;
  926. struct kthread_work thread_priority_work;
  927. unsigned int num_encoders;
  928. struct drm_encoder *encoders[MAX_ENCODERS];
  929. unsigned int num_bridges;
  930. struct drm_bridge *bridges[MAX_BRIDGES];
  931. unsigned int num_connectors;
  932. struct drm_connector *connectors[MAX_CONNECTORS];
  933. /* Properties */
  934. struct drm_property *plane_property[PLANE_PROP_COUNT];
  935. struct drm_property *crtc_property[CRTC_PROP_COUNT];
  936. struct drm_property *conn_property[CONNECTOR_PROP_COUNT];
  937. /* Color processing properties for the crtc */
  938. struct drm_property **cp_property;
  939. /* VRAM carveout, used when no IOMMU: */
  940. struct {
  941. unsigned long size;
  942. dma_addr_t paddr;
  943. /* NOTE: mm managed at the page level, size is in # of pages
  944. * and position mm_node->start is in # of pages:
  945. */
  946. struct drm_mm mm;
  947. spinlock_t lock; /* Protects drm_mm node allocation/removal */
  948. } vram;
  949. struct notifier_block vmap_notifier;
  950. struct shrinker shrinker;
  951. struct drm_atomic_state *pm_state;
  952. /* task holding struct_mutex.. currently only used in submit path
  953. * to detect and reject faults from copy_from_user() for submit
  954. * ioctl.
  955. */
  956. struct task_struct *struct_mutex_task;
  957. /* list of clients waiting for events */
  958. struct list_head client_event_list;
  959. /* whether registered and drm_dev_unregister should be called */
  960. bool registered;
  961. /* msm drv debug root node */
  962. struct dentry *debug_root;
  963. /* update the flag when msm driver receives shutdown notification */
  964. bool shutdown_in_progress;
  965. struct mutex vm_client_lock;
  966. struct list_head vm_client_list;
  967. };
  968. /* get struct msm_kms * from drm_device * */
  969. #define ddev_to_msm_kms(D) ((D) && (D)->dev_private ? \
  970. ((struct msm_drm_private *)((D)->dev_private))->kms : NULL)
  971. struct msm_format {
  972. uint32_t pixel_format;
  973. };
  974. int msm_atomic_prepare_fb(struct drm_plane *plane,
  975. struct drm_plane_state *new_state);
  976. void msm_atomic_commit_tail(struct drm_atomic_state *state);
  977. int msm_atomic_commit(struct drm_device *dev,
  978. struct drm_atomic_state *state, bool nonblock);
  979. /* callback from wq once fence has passed: */
  980. struct msm_fence_cb {
  981. struct work_struct work;
  982. uint32_t fence;
  983. void (*func)(struct msm_fence_cb *cb);
  984. };
  985. void __msm_fence_worker(struct work_struct *work);
  986. #define INIT_FENCE_CB(_cb, _func) do { \
  987. INIT_WORK(&(_cb)->work, __msm_fence_worker); \
  988. (_cb)->func = _func; \
  989. } while (0)
  990. struct drm_atomic_state *msm_atomic_state_alloc(struct drm_device *dev);
  991. void msm_atomic_state_clear(struct drm_atomic_state *state);
  992. void msm_atomic_state_free(struct drm_atomic_state *state);
  993. int msm_gem_init_vma(struct msm_gem_address_space *aspace,
  994. struct msm_gem_vma *vma, int npages);
  995. void msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
  996. struct msm_gem_vma *vma, struct sg_table *sgt,
  997. unsigned int flags);
  998. int msm_gem_map_vma(struct msm_gem_address_space *aspace,
  999. struct msm_gem_vma *vma, struct sg_table *sgt, int npages,
  1000. unsigned int flags);
  1001. struct device *msm_gem_get_aspace_device(struct msm_gem_address_space *aspace);
  1002. void msm_gem_address_space_put(struct msm_gem_address_space *aspace);
  1003. /* For SDE display */
  1004. struct msm_gem_address_space *
  1005. msm_gem_smmu_address_space_create(struct drm_device *dev, struct msm_mmu *mmu,
  1006. const char *name);
  1007. /**
  1008. * msm_gem_add_obj_to_aspace_active_list: adds obj to active obj list in aspace
  1009. */
  1010. void msm_gem_add_obj_to_aspace_active_list(
  1011. struct msm_gem_address_space *aspace,
  1012. struct drm_gem_object *obj);
  1013. /**
  1014. * msm_gem_remove_obj_from_aspace_active_list: removes obj from active obj
  1015. * list in aspace
  1016. */
  1017. void msm_gem_remove_obj_from_aspace_active_list(
  1018. struct msm_gem_address_space *aspace,
  1019. struct drm_gem_object *obj);
  1020. /**
  1021. * msm_gem_smmu_address_space_get: returns the aspace pointer for the requested
  1022. * domain
  1023. */
  1024. struct msm_gem_address_space *
  1025. msm_gem_smmu_address_space_get(struct drm_device *dev,
  1026. unsigned int domain);
  1027. int msm_register_mmu(struct drm_device *dev, struct msm_mmu *mmu);
  1028. void msm_unregister_mmu(struct drm_device *dev, struct msm_mmu *mmu);
  1029. /**
  1030. * msm_gem_aspace_domain_attach_detach: function to inform the attach/detach
  1031. * of the domain for this aspace
  1032. */
  1033. void msm_gem_aspace_domain_attach_detach_update(
  1034. struct msm_gem_address_space *aspace,
  1035. bool is_detach);
  1036. /**
  1037. * msm_gem_address_space_register_cb: function to register callback for attach
  1038. * and detach of the domain
  1039. */
  1040. int msm_gem_address_space_register_cb(
  1041. struct msm_gem_address_space *aspace,
  1042. void (*cb)(void *, bool),
  1043. void *cb_data);
  1044. /**
  1045. * msm_gem_address_space_register_cb: function to unregister callback
  1046. */
  1047. int msm_gem_address_space_unregister_cb(
  1048. struct msm_gem_address_space *aspace,
  1049. void (*cb)(void *, bool),
  1050. void *cb_data);
  1051. void msm_gem_submit_free(struct msm_gem_submit *submit);
  1052. int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
  1053. struct drm_file *file);
  1054. void msm_gem_shrinker_init(struct drm_device *dev);
  1055. void msm_gem_shrinker_cleanup(struct drm_device *dev);
  1056. void msm_gem_sync(struct drm_gem_object *obj);
  1057. int msm_gem_mmap_obj(struct drm_gem_object *obj,
  1058. struct vm_area_struct *vma);
  1059. int msm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
  1060. uint64_t msm_gem_mmap_offset(struct drm_gem_object *obj);
  1061. int msm_gem_get_iova(struct drm_gem_object *obj,
  1062. struct msm_gem_address_space *aspace, uint64_t *iova);
  1063. uint64_t msm_gem_iova(struct drm_gem_object *obj,
  1064. struct msm_gem_address_space *aspace);
  1065. void msm_gem_unpin_iova(struct drm_gem_object *obj,
  1066. struct msm_gem_address_space *aspace);
  1067. struct page **msm_gem_get_pages(struct drm_gem_object *obj);
  1068. void msm_gem_put_pages(struct drm_gem_object *obj);
  1069. void msm_gem_put_iova(struct drm_gem_object *obj,
  1070. struct msm_gem_address_space *aspace);
  1071. dma_addr_t msm_gem_get_dma_addr(struct drm_gem_object *obj);
  1072. int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
  1073. struct drm_mode_create_dumb *args);
  1074. int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
  1075. uint32_t handle, uint64_t *offset);
  1076. struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj);
  1077. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
  1078. int msm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);
  1079. void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);
  1080. #else
  1081. void *msm_gem_prime_vmap(struct drm_gem_object *obj);
  1082. void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
  1083. vm_fault_t msm_gem_fault(struct vm_fault *vmf);
  1084. #endif
  1085. int msm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
  1086. struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
  1087. struct dma_buf_attachment *attach, struct sg_table *sg);
  1088. int msm_gem_prime_pin(struct drm_gem_object *obj);
  1089. void msm_gem_prime_unpin(struct drm_gem_object *obj);
  1090. struct drm_gem_object *msm_gem_prime_import(struct drm_device *dev,
  1091. struct dma_buf *dma_buf);
  1092. void *msm_gem_get_vaddr(struct drm_gem_object *obj);
  1093. void msm_gem_put_vaddr(struct drm_gem_object *obj);
  1094. int msm_gem_madvise(struct drm_gem_object *obj, unsigned madv);
  1095. int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout);
  1096. int msm_gem_cpu_fini(struct drm_gem_object *obj);
  1097. void msm_gem_free_object(struct drm_gem_object *obj);
  1098. int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
  1099. uint32_t size, uint32_t flags, uint32_t *handle, char *name);
  1100. struct drm_gem_object *msm_gem_new(struct drm_device *dev,
  1101. uint32_t size, uint32_t flags);
  1102. struct drm_gem_object *msm_gem_import(struct drm_device *dev,
  1103. struct dma_buf *dmabuf, struct sg_table *sgt);
  1104. __printf(2, 3)
  1105. void msm_gem_object_set_name(struct drm_gem_object *bo, const char *fmt, ...);
  1106. int msm_gem_delayed_import(struct drm_gem_object *obj);
  1107. #define MSM_FB_CACHE_NONE 0x0
  1108. #define MSM_FB_CACHE_WRITE_EN 0x1
  1109. #define MSM_FB_CACHE_READ_EN 0x2
  1110. int msm_framebuffer_prepare(struct drm_framebuffer *fb,
  1111. struct msm_gem_address_space *aspace);
  1112. void msm_framebuffer_cleanup(struct drm_framebuffer *fb,
  1113. struct msm_gem_address_space *aspace);
  1114. uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb,
  1115. struct msm_gem_address_space *aspace, int plane);
  1116. uint32_t msm_framebuffer_phys(struct drm_framebuffer *fb, int plane);
  1117. struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane);
  1118. const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb);
  1119. struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
  1120. const struct drm_mode_fb_cmd2 *mode_cmd,
  1121. struct drm_gem_object **bos);
  1122. struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
  1123. struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
  1124. void msm_framebuffer_set_cache_hint(struct drm_framebuffer *fb, u32 flags, u32 type);
  1125. void msm_framebuffer_get_cache_hint(struct drm_framebuffer *fb, u32 *flags, u32 *type);
  1126. struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev);
  1127. void msm_fbdev_free(struct drm_device *dev);
  1128. struct hdmi;
  1129. #if IS_ENABLED(CONFIG_DRM_MSM_HDMI)
  1130. int msm_hdmi_modeset_init(struct hdmi *hdmi, struct drm_device *dev,
  1131. struct drm_encoder *encoder);
  1132. void __init msm_hdmi_register(void);
  1133. void __exit msm_hdmi_unregister(void);
  1134. #else
  1135. static inline void __init msm_hdmi_register(void)
  1136. {
  1137. }
  1138. static inline void __exit msm_hdmi_unregister(void)
  1139. {
  1140. }
  1141. #endif /* CONFIG_DRM_MSM_HDMI */
  1142. struct msm_edp;
  1143. #if IS_ENABLED(CONFIG_DRM_MSM_EDP)
  1144. void __init msm_edp_register(void);
  1145. void __exit msm_edp_unregister(void);
  1146. int msm_edp_modeset_init(struct msm_edp *edp, struct drm_device *dev,
  1147. struct drm_encoder *encoder);
  1148. #else
  1149. static inline void __init msm_edp_register(void)
  1150. {
  1151. }
  1152. static inline void __exit msm_edp_unregister(void)
  1153. {
  1154. }
  1155. static inline int msm_edp_modeset_init(struct msm_edp *edp,
  1156. struct drm_device *dev, struct drm_encoder *encoder)
  1157. {
  1158. return -EINVAL;
  1159. }
  1160. #endif /* CONFIG_DRM_MSM_EDP */
  1161. struct msm_dsi;
  1162. /* *
  1163. * msm_mode_object_event_notify - notify user-space clients of drm object
  1164. * events.
  1165. * @obj: mode object (crtc/connector) that is generating the event.
  1166. * @event: event that needs to be notified.
  1167. * @payload: payload for the event.
  1168. */
  1169. void msm_mode_object_event_notify(struct drm_mode_object *obj,
  1170. struct drm_device *dev, struct drm_event *event, u8 *payload);
  1171. #if IS_ENABLED(CONFIG_DRM_MSM_DSI)
  1172. static inline void __init msm_dsi_register(void)
  1173. {
  1174. }
  1175. static inline void __exit msm_dsi_unregister(void)
  1176. {
  1177. }
  1178. static inline int msm_dsi_modeset_init(struct msm_dsi *msm_dsi,
  1179. struct drm_device *dev,
  1180. struct drm_encoder *encoder)
  1181. {
  1182. return -EINVAL;
  1183. }
  1184. #else
  1185. void __init msm_dsi_register(void);
  1186. void __exit msm_dsi_unregister(void);
  1187. int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
  1188. struct drm_encoder *encoder);
  1189. #endif /* CONFIG_DRM_MSM_DSI */
  1190. #if IS_ENABLED(CONFIG_DRM_MSM_MDP5)
  1191. void __init msm_mdp_register(void);
  1192. void __exit msm_mdp_unregister(void);
  1193. #else
  1194. static inline void __init msm_mdp_register(void)
  1195. {
  1196. }
  1197. static inline void __exit msm_mdp_unregister(void)
  1198. {
  1199. }
  1200. #endif /* CONFIG_DRM_MSM_MDP5 */
  1201. #if IS_ENABLED(CONFIG_DEBUG_FS)
  1202. int msm_debugfs_late_init(struct drm_device *dev);
  1203. int msm_rd_debugfs_init(struct drm_minor *minor);
  1204. void msm_rd_debugfs_cleanup(struct msm_drm_private *priv);
  1205. __printf(3, 4)
  1206. void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit,
  1207. const char *fmt, ...);
  1208. int msm_perf_debugfs_init(struct drm_minor *minor);
  1209. void msm_perf_debugfs_cleanup(struct msm_drm_private *priv);
  1210. #else
  1211. static inline int msm_debugfs_late_init(struct drm_device *dev) { return 0; }
  1212. __printf(3, 4)
  1213. static inline void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit,
  1214. const char *fmt, ...) {}
  1215. static inline void msm_rd_debugfs_cleanup(struct msm_drm_private *priv) {}
  1216. static inline void msm_perf_debugfs_cleanup(struct msm_drm_private *priv) {}
  1217. #endif /* CONFIG_DEBUG_FS */
  1218. #if IS_ENABLED(CONFIG_DRM_MSM_DSI)
  1219. void __init dsi_display_register(void);
  1220. void __exit dsi_display_unregister(void);
  1221. #else
  1222. static inline void __init dsi_display_register(void)
  1223. {
  1224. }
  1225. static inline void __exit dsi_display_unregister(void)
  1226. {
  1227. }
  1228. #endif /* CONFIG_DRM_MSM_DSI */
  1229. #if IS_ENABLED(CONFIG_HDCP_QSEECOM)
  1230. void __init msm_hdcp_register(void);
  1231. void __exit msm_hdcp_unregister(void);
  1232. #else
  1233. static inline void __init msm_hdcp_register(void)
  1234. {
  1235. }
  1236. static inline void __exit msm_hdcp_unregister(void)
  1237. {
  1238. }
  1239. #endif /* CONFIG_HDCP_QSEECOM */
  1240. #if IS_ENABLED(CONFIG_DRM_MSM_DP)
  1241. void __init dp_display_register(void);
  1242. void __exit dp_display_unregister(void);
  1243. #else
  1244. static inline void __init dp_display_register(void)
  1245. {
  1246. }
  1247. static inline void __exit dp_display_unregister(void)
  1248. {
  1249. }
  1250. #endif /* CONFIG_DRM_MSM_DP */
  1251. #if IS_ENABLED(CONFIG_DRM_SDE_RSC)
  1252. void __init sde_rsc_register(void);
  1253. void __exit sde_rsc_unregister(void);
  1254. void __init sde_rsc_rpmh_register(void);
  1255. #else
  1256. static inline void __init sde_rsc_register(void)
  1257. {
  1258. }
  1259. static inline void __exit sde_rsc_unregister(void)
  1260. {
  1261. }
  1262. static inline void __init sde_rsc_rpmh_register(void)
  1263. {
  1264. }
  1265. #endif /* CONFIG_DRM_SDE_RSC */
  1266. #if IS_ENABLED(CONFIG_DRM_SDE_WB)
  1267. void __init sde_wb_register(void);
  1268. void __exit sde_wb_unregister(void);
  1269. #else
  1270. static inline void __init sde_wb_register(void)
  1271. {
  1272. }
  1273. static inline void __exit sde_wb_unregister(void)
  1274. {
  1275. }
  1276. #endif /* CONFIG_DRM_SDE_WB */
  1277. #if IS_ENABLED(CONFIG_MSM_SDE_ROTATOR)
  1278. void sde_rotator_register(void);
  1279. void sde_rotator_unregister(void);
  1280. #else
  1281. static inline void sde_rotator_register(void)
  1282. {
  1283. }
  1284. static inline void sde_rotator_unregister(void)
  1285. {
  1286. }
  1287. #endif /* CONFIG_MSM_SDE_ROTATOR */
  1288. #if IS_ENABLED(CONFIG_MSM_SDE_ROTATOR)
  1289. void sde_rotator_smmu_driver_register(void);
  1290. void sde_rotator_smmu_driver_unregister(void);
  1291. #else
  1292. static inline void sde_rotator_smmu_driver_register(void)
  1293. {
  1294. }
  1295. static inline void sde_rotator_smmu_driver_unregister(void)
  1296. {
  1297. }
  1298. #endif /* CONFIG_MSM_SDE_ROTATOR */
  1299. struct clk *msm_clk_get(struct platform_device *pdev, const char *name);
  1300. int msm_clk_bulk_get(struct device *dev, struct clk_bulk_data **bulk);
  1301. struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count,
  1302. const char *name);
  1303. void __iomem *msm_ioremap(struct platform_device *pdev, const char *name,
  1304. const char *dbgname);
  1305. unsigned long msm_iomap_size(struct platform_device *pdev, const char *name);
  1306. unsigned long msm_get_phys_addr(struct platform_device *pdev, const char *name);
  1307. void msm_iounmap(struct platform_device *dev, void __iomem *addr);
  1308. void msm_writel(u32 data, void __iomem *addr);
  1309. u32 msm_readl(const void __iomem *addr);
  1310. #define DBG(fmt, ...) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)
  1311. #define VERB(fmt, ...) if (0) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)
  1312. static inline int align_pitch(int width, int bpp)
  1313. {
  1314. int bytespp = (bpp + 7) / 8;
  1315. /* adreno needs pitch aligned to 32 pixels: */
  1316. return bytespp * ALIGN(width, 32);
  1317. }
  1318. /* for the generated headers: */
  1319. #define INVALID_IDX(idx) ({BUG(); 0;})
  1320. #define fui(x) ({BUG(); 0;})
  1321. #define util_float_to_half(x) ({BUG(); 0;})
  1322. #define FIELD(val, name) (((val) & name ## __MASK) >> name ## __SHIFT)
  1323. /* for conditionally setting boolean flag(s): */
  1324. #define COND(bool, val) ((bool) ? (val) : 0)
  1325. static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
  1326. {
  1327. ktime_t now = ktime_get();
  1328. unsigned long remaining_jiffies;
  1329. if (ktime_compare(*timeout, now) < 0) {
  1330. remaining_jiffies = 0;
  1331. } else {
  1332. ktime_t rem = ktime_sub(*timeout, now);
  1333. remaining_jiffies = nsecs_to_jiffies(ktime_to_ns(rem));
  1334. }
  1335. return remaining_jiffies;
  1336. }
  1337. int msm_get_mixer_count(struct msm_drm_private *priv,
  1338. const struct drm_display_mode *mode,
  1339. const struct msm_resource_caps_info *res, u32 *num_lm);
  1340. int msm_get_dsc_count(struct msm_drm_private *priv,
  1341. u32 hdisplay, u32 *num_dsc);
  1342. int msm_get_src_bpc(int chroma_format, int bpc);
  1343. #endif /* __MSM_DRV_H__ */