msm_drv.h 44 KB

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