msm_drv.h 43 KB

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