msm_drv.h 43 KB

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