msm_drv.h 39 KB

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