msm_drv.h 43 KB

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