msm_drv.h 40 KB

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