msm_drv.h 46 KB

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