dc.h 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103
  1. /*
  2. * Copyright 2012-14 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef DC_INTERFACE_H_
  26. #define DC_INTERFACE_H_
  27. #include "dc_types.h"
  28. #include "grph_object_defs.h"
  29. #include "logger_types.h"
  30. #include "gpio_types.h"
  31. #include "link_service_types.h"
  32. #include "grph_object_ctrl_defs.h"
  33. #include <inc/hw/opp.h>
  34. #include "inc/hw_sequencer.h"
  35. #include "inc/compressor.h"
  36. #include "dml/display_mode_lib.h"
  37. #define DC_VER "3.1.07"
  38. #define MAX_SURFACES 3
  39. #define MAX_STREAMS 6
  40. #define MAX_SINKS_PER_LINK 4
  41. /*******************************************************************************
  42. * Display Core Interfaces
  43. ******************************************************************************/
  44. struct dc_caps {
  45. uint32_t max_streams;
  46. uint32_t max_links;
  47. uint32_t max_audios;
  48. uint32_t max_slave_planes;
  49. uint32_t max_planes;
  50. uint32_t max_downscale_ratio;
  51. uint32_t i2c_speed_in_khz;
  52. unsigned int max_cursor_size;
  53. unsigned int max_video_width;
  54. bool dcc_const_color;
  55. bool dynamic_audio;
  56. };
  57. struct dc_dcc_surface_param {
  58. struct dc_size surface_size;
  59. enum surface_pixel_format format;
  60. enum swizzle_mode_values swizzle_mode;
  61. enum dc_scan_direction scan;
  62. };
  63. struct dc_dcc_setting {
  64. unsigned int max_compressed_blk_size;
  65. unsigned int max_uncompressed_blk_size;
  66. bool independent_64b_blks;
  67. };
  68. struct dc_surface_dcc_cap {
  69. union {
  70. struct {
  71. struct dc_dcc_setting rgb;
  72. } grph;
  73. struct {
  74. struct dc_dcc_setting luma;
  75. struct dc_dcc_setting chroma;
  76. } video;
  77. };
  78. bool capable;
  79. bool const_color_support;
  80. };
  81. struct dc_static_screen_events {
  82. bool cursor_update;
  83. bool surface_update;
  84. bool overlay_update;
  85. };
  86. /* Forward declaration*/
  87. struct dc;
  88. struct dc_plane_state;
  89. struct dc_state;
  90. struct dc_cap_funcs {
  91. bool (*get_dcc_compression_cap)(const struct dc *dc,
  92. const struct dc_dcc_surface_param *input,
  93. struct dc_surface_dcc_cap *output);
  94. };
  95. struct dc_stream_state_funcs {
  96. bool (*adjust_vmin_vmax)(struct dc *dc,
  97. struct dc_stream_state **stream,
  98. int num_streams,
  99. int vmin,
  100. int vmax);
  101. bool (*get_crtc_position)(struct dc *dc,
  102. struct dc_stream_state **stream,
  103. int num_streams,
  104. unsigned int *v_pos,
  105. unsigned int *nom_v_pos);
  106. bool (*set_gamut_remap)(struct dc *dc,
  107. const struct dc_stream_state *stream);
  108. bool (*program_csc_matrix)(struct dc *dc,
  109. struct dc_stream_state *stream);
  110. void (*set_static_screen_events)(struct dc *dc,
  111. struct dc_stream_state **stream,
  112. int num_streams,
  113. const struct dc_static_screen_events *events);
  114. void (*set_dither_option)(struct dc_stream_state *stream,
  115. enum dc_dither_option option);
  116. void (*set_dpms)(struct dc *dc,
  117. struct dc_stream_state *stream,
  118. bool dpms_off);
  119. };
  120. struct link_training_settings;
  121. struct dc_link_funcs {
  122. void (*set_drive_settings)(struct dc *dc,
  123. struct link_training_settings *lt_settings,
  124. const struct dc_link *link);
  125. void (*perform_link_training)(struct dc *dc,
  126. struct dc_link_settings *link_setting,
  127. bool skip_video_pattern);
  128. void (*set_preferred_link_settings)(struct dc *dc,
  129. struct dc_link_settings *link_setting,
  130. struct dc_link *link);
  131. void (*enable_hpd)(const struct dc_link *link);
  132. void (*disable_hpd)(const struct dc_link *link);
  133. void (*set_test_pattern)(
  134. struct dc_link *link,
  135. enum dp_test_pattern test_pattern,
  136. const struct link_training_settings *p_link_settings,
  137. const unsigned char *p_custom_pattern,
  138. unsigned int cust_pattern_size);
  139. };
  140. /* Structure to hold configuration flags set by dm at dc creation. */
  141. struct dc_config {
  142. bool gpu_vm_support;
  143. bool disable_disp_pll_sharing;
  144. };
  145. enum dcc_option {
  146. DCC_ENABLE = 0,
  147. DCC_DISABLE = 1,
  148. DCC_HALF_REQ_DISALBE = 2,
  149. };
  150. enum pipe_split_policy {
  151. MPC_SPLIT_DYNAMIC = 0,
  152. MPC_SPLIT_AVOID = 1,
  153. MPC_SPLIT_AVOID_MULT_DISP = 2,
  154. };
  155. enum wm_report_mode {
  156. WM_REPORT_DEFAULT = 0,
  157. WM_REPORT_OVERRIDE = 1,
  158. };
  159. struct dc_debug {
  160. bool surface_visual_confirm;
  161. bool sanity_checks;
  162. bool max_disp_clk;
  163. bool surface_trace;
  164. bool timing_trace;
  165. bool clock_trace;
  166. bool validation_trace;
  167. /* stutter efficiency related */
  168. bool disable_stutter;
  169. bool use_max_lb;
  170. enum dcc_option disable_dcc;
  171. enum pipe_split_policy pipe_split_policy;
  172. bool force_single_disp_pipe_split;
  173. bool voltage_align_fclk;
  174. bool disable_dfs_bypass;
  175. bool disable_dpp_power_gate;
  176. bool disable_hubp_power_gate;
  177. bool disable_pplib_wm_range;
  178. enum wm_report_mode pplib_wm_report_mode;
  179. unsigned int min_disp_clk_khz;
  180. int sr_exit_time_dpm0_ns;
  181. int sr_enter_plus_exit_time_dpm0_ns;
  182. int sr_exit_time_ns;
  183. int sr_enter_plus_exit_time_ns;
  184. int urgent_latency_ns;
  185. int percent_of_ideal_drambw;
  186. int dram_clock_change_latency_ns;
  187. int always_scale;
  188. bool disable_pplib_clock_request;
  189. bool disable_clock_gate;
  190. bool disable_dmcu;
  191. bool disable_psr;
  192. bool force_abm_enable;
  193. bool disable_hbup_pg;
  194. bool disable_dpp_pg;
  195. bool disable_stereo_support;
  196. bool vsr_support;
  197. bool performance_trace;
  198. };
  199. struct dc_state;
  200. struct resource_pool;
  201. struct dce_hwseq;
  202. struct dc {
  203. struct dc_caps caps;
  204. struct dc_cap_funcs cap_funcs;
  205. struct dc_stream_state_funcs stream_funcs;
  206. struct dc_link_funcs link_funcs;
  207. struct dc_config config;
  208. struct dc_debug debug;
  209. struct dc_context *ctx;
  210. uint8_t link_count;
  211. struct dc_link *links[MAX_PIPES * 2];
  212. struct dc_state *current_state;
  213. struct resource_pool *res_pool;
  214. /* Display Engine Clock levels */
  215. struct dm_pp_clock_levels sclk_lvls;
  216. /* Inputs into BW and WM calculations. */
  217. struct bw_calcs_dceip *bw_dceip;
  218. struct bw_calcs_vbios *bw_vbios;
  219. #ifdef CONFIG_DRM_AMD_DC_DCN1_0
  220. struct dcn_soc_bounding_box *dcn_soc;
  221. struct dcn_ip_params *dcn_ip;
  222. struct display_mode_lib dml;
  223. #endif
  224. /* HW functions */
  225. struct hw_sequencer_funcs hwss;
  226. struct dce_hwseq *hwseq;
  227. /* temp store of dm_pp_display_configuration
  228. * to compare to see if display config changed
  229. */
  230. struct dm_pp_display_configuration prev_display_config;
  231. /* FBC compressor */
  232. #if defined(CONFIG_DRM_AMD_DC_FBC)
  233. struct compressor *fbc_compressor;
  234. #endif
  235. };
  236. enum frame_buffer_mode {
  237. FRAME_BUFFER_MODE_LOCAL_ONLY = 0,
  238. FRAME_BUFFER_MODE_ZFB_ONLY,
  239. FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL,
  240. } ;
  241. struct dchub_init_data {
  242. int64_t zfb_phys_addr_base;
  243. int64_t zfb_mc_base_addr;
  244. uint64_t zfb_size_in_byte;
  245. enum frame_buffer_mode fb_mode;
  246. bool dchub_initialzied;
  247. bool dchub_info_valid;
  248. };
  249. struct dc_init_data {
  250. struct hw_asic_id asic_id;
  251. void *driver; /* ctx */
  252. struct cgs_device *cgs_device;
  253. int num_virtual_links;
  254. /*
  255. * If 'vbios_override' not NULL, it will be called instead
  256. * of the real VBIOS. Intended use is Diagnostics on FPGA.
  257. */
  258. struct dc_bios *vbios_override;
  259. enum dce_environment dce_environment;
  260. struct dc_config flags;
  261. uint32_t log_mask;
  262. #if defined(CONFIG_DRM_AMD_DC_FBC)
  263. uint64_t fbc_gpu_addr;
  264. #endif
  265. };
  266. struct dc *dc_create(const struct dc_init_data *init_params);
  267. void dc_destroy(struct dc **dc);
  268. /*******************************************************************************
  269. * Surface Interfaces
  270. ******************************************************************************/
  271. enum {
  272. TRANSFER_FUNC_POINTS = 1025
  273. };
  274. // Moved here from color module for linux
  275. enum color_transfer_func {
  276. transfer_func_unknown,
  277. transfer_func_srgb,
  278. transfer_func_bt709,
  279. transfer_func_pq2084,
  280. transfer_func_pq2084_interim,
  281. transfer_func_linear_0_1,
  282. transfer_func_linear_0_125,
  283. transfer_func_dolbyvision,
  284. transfer_func_gamma_22,
  285. transfer_func_gamma_26
  286. };
  287. enum color_color_space {
  288. color_space_unsupported,
  289. color_space_srgb,
  290. color_space_bt601,
  291. color_space_bt709,
  292. color_space_xv_ycc_bt601,
  293. color_space_xv_ycc_bt709,
  294. color_space_xr_rgb,
  295. color_space_bt2020,
  296. color_space_adobe,
  297. color_space_dci_p3,
  298. color_space_sc_rgb_ms_ref,
  299. color_space_display_native,
  300. color_space_app_ctrl,
  301. color_space_dolby_vision,
  302. color_space_custom_coordinates
  303. };
  304. struct dc_hdr_static_metadata {
  305. /* display chromaticities and white point in units of 0.00001 */
  306. unsigned int chromaticity_green_x;
  307. unsigned int chromaticity_green_y;
  308. unsigned int chromaticity_blue_x;
  309. unsigned int chromaticity_blue_y;
  310. unsigned int chromaticity_red_x;
  311. unsigned int chromaticity_red_y;
  312. unsigned int chromaticity_white_point_x;
  313. unsigned int chromaticity_white_point_y;
  314. uint32_t min_luminance;
  315. uint32_t max_luminance;
  316. uint32_t maximum_content_light_level;
  317. uint32_t maximum_frame_average_light_level;
  318. bool hdr_supported;
  319. bool is_hdr;
  320. };
  321. enum dc_transfer_func_type {
  322. TF_TYPE_PREDEFINED,
  323. TF_TYPE_DISTRIBUTED_POINTS,
  324. TF_TYPE_BYPASS
  325. };
  326. struct dc_transfer_func_distributed_points {
  327. struct fixed31_32 red[TRANSFER_FUNC_POINTS];
  328. struct fixed31_32 green[TRANSFER_FUNC_POINTS];
  329. struct fixed31_32 blue[TRANSFER_FUNC_POINTS];
  330. uint16_t end_exponent;
  331. uint16_t x_point_at_y1_red;
  332. uint16_t x_point_at_y1_green;
  333. uint16_t x_point_at_y1_blue;
  334. };
  335. enum dc_transfer_func_predefined {
  336. TRANSFER_FUNCTION_SRGB,
  337. TRANSFER_FUNCTION_BT709,
  338. TRANSFER_FUNCTION_PQ,
  339. TRANSFER_FUNCTION_LINEAR,
  340. };
  341. struct dc_transfer_func {
  342. struct kref refcount;
  343. struct dc_transfer_func_distributed_points tf_pts;
  344. enum dc_transfer_func_type type;
  345. enum dc_transfer_func_predefined tf;
  346. struct dc_context *ctx;
  347. };
  348. /*
  349. * This structure is filled in by dc_surface_get_status and contains
  350. * the last requested address and the currently active address so the called
  351. * can determine if there are any outstanding flips
  352. */
  353. struct dc_plane_status {
  354. struct dc_plane_address requested_address;
  355. struct dc_plane_address current_address;
  356. bool is_flip_pending;
  357. bool is_right_eye;
  358. };
  359. struct dc_plane_state {
  360. struct dc_plane_address address;
  361. struct scaling_taps scaling_quality;
  362. struct rect src_rect;
  363. struct rect dst_rect;
  364. struct rect clip_rect;
  365. union plane_size plane_size;
  366. union dc_tiling_info tiling_info;
  367. struct dc_plane_dcc_param dcc;
  368. struct dc_hdr_static_metadata hdr_static_ctx;
  369. struct dc_gamma *gamma_correction;
  370. struct dc_transfer_func *in_transfer_func;
  371. // sourceContentAttribute cache
  372. bool is_source_input_valid;
  373. struct dc_hdr_static_metadata source_input_mastering_info;
  374. enum color_color_space source_input_color_space;
  375. enum color_transfer_func source_input_tf;
  376. enum dc_color_space color_space;
  377. enum surface_pixel_format format;
  378. enum dc_rotation_angle rotation;
  379. enum plane_stereo_format stereo_format;
  380. bool per_pixel_alpha;
  381. bool visible;
  382. bool flip_immediate;
  383. bool horizontal_mirror;
  384. /* private to DC core */
  385. struct dc_plane_status status;
  386. struct dc_context *ctx;
  387. /* private to dc_surface.c */
  388. enum dc_irq_source irq_source;
  389. struct kref refcount;
  390. };
  391. struct dc_plane_info {
  392. union plane_size plane_size;
  393. union dc_tiling_info tiling_info;
  394. struct dc_plane_dcc_param dcc;
  395. enum surface_pixel_format format;
  396. enum dc_rotation_angle rotation;
  397. enum plane_stereo_format stereo_format;
  398. enum dc_color_space color_space; /*todo: wrong place, fits in scaling info*/
  399. bool horizontal_mirror;
  400. bool visible;
  401. bool per_pixel_alpha;
  402. };
  403. struct dc_scaling_info {
  404. struct rect src_rect;
  405. struct rect dst_rect;
  406. struct rect clip_rect;
  407. struct scaling_taps scaling_quality;
  408. };
  409. struct dc_surface_update {
  410. struct dc_plane_state *surface;
  411. /* isr safe update parameters. null means no updates */
  412. struct dc_flip_addrs *flip_addr;
  413. struct dc_plane_info *plane_info;
  414. struct dc_scaling_info *scaling_info;
  415. /* following updates require alloc/sleep/spin that is not isr safe,
  416. * null means no updates
  417. */
  418. /* gamma TO BE REMOVED */
  419. struct dc_gamma *gamma;
  420. struct dc_transfer_func *in_transfer_func;
  421. struct dc_hdr_static_metadata *hdr_static_metadata;
  422. };
  423. /*
  424. * Create a new surface with default parameters;
  425. */
  426. struct dc_plane_state *dc_create_plane_state(struct dc *dc);
  427. const struct dc_plane_status *dc_plane_get_status(
  428. const struct dc_plane_state *plane_state);
  429. void dc_plane_state_retain(struct dc_plane_state *plane_state);
  430. void dc_plane_state_release(struct dc_plane_state *plane_state);
  431. void dc_gamma_retain(struct dc_gamma *dc_gamma);
  432. void dc_gamma_release(struct dc_gamma **dc_gamma);
  433. struct dc_gamma *dc_create_gamma(void);
  434. void dc_transfer_func_retain(struct dc_transfer_func *dc_tf);
  435. void dc_transfer_func_release(struct dc_transfer_func *dc_tf);
  436. struct dc_transfer_func *dc_create_transfer_func(void);
  437. /*
  438. * This structure holds a surface address. There could be multiple addresses
  439. * in cases such as Stereo 3D, Planar YUV, etc. Other per-flip attributes such
  440. * as frame durations and DCC format can also be set.
  441. */
  442. struct dc_flip_addrs {
  443. struct dc_plane_address address;
  444. bool flip_immediate;
  445. /* TODO: add flip duration for FreeSync */
  446. };
  447. bool dc_post_update_surfaces_to_stream(
  448. struct dc *dc);
  449. /* Surface update type is used by dc_update_surfaces_and_stream
  450. * The update type is determined at the very beginning of the function based
  451. * on parameters passed in and decides how much programming (or updating) is
  452. * going to be done during the call.
  453. *
  454. * UPDATE_TYPE_FAST is used for really fast updates that do not require much
  455. * logical calculations or hardware register programming. This update MUST be
  456. * ISR safe on windows. Currently fast update will only be used to flip surface
  457. * address.
  458. *
  459. * UPDATE_TYPE_MED is used for slower updates which require significant hw
  460. * re-programming however do not affect bandwidth consumption or clock
  461. * requirements. At present, this is the level at which front end updates
  462. * that do not require us to run bw_calcs happen. These are in/out transfer func
  463. * updates, viewport offset changes, recout size changes and pixel depth changes.
  464. * This update can be done at ISR, but we want to minimize how often this happens.
  465. *
  466. * UPDATE_TYPE_FULL is slow. Really slow. This requires us to recalculate our
  467. * bandwidth and clocks, possibly rearrange some pipes and reprogram anything front
  468. * end related. Any time viewport dimensions, recout dimensions, scaling ratios or
  469. * gamma need to be adjusted or pipe needs to be turned on (or disconnected) we do
  470. * a full update. This cannot be done at ISR level and should be a rare event.
  471. * Unless someone is stress testing mpo enter/exit, playing with colour or adjusting
  472. * underscan we don't expect to see this call at all.
  473. */
  474. enum surface_update_type {
  475. UPDATE_TYPE_FAST, /* super fast, safe to execute in isr */
  476. UPDATE_TYPE_MED, /* ISR safe, most of programming needed, no bw/clk change*/
  477. UPDATE_TYPE_FULL, /* may need to shuffle resources */
  478. };
  479. /*******************************************************************************
  480. * Stream Interfaces
  481. ******************************************************************************/
  482. struct dc_stream_status {
  483. int primary_otg_inst;
  484. int stream_enc_inst;
  485. int plane_count;
  486. struct dc_plane_state *plane_states[MAX_SURFACE_NUM];
  487. /*
  488. * link this stream passes through
  489. */
  490. struct dc_link *link;
  491. };
  492. struct dc_stream_state {
  493. struct dc_sink *sink;
  494. struct dc_crtc_timing timing;
  495. struct rect src; /* composition area */
  496. struct rect dst; /* stream addressable area */
  497. struct audio_info audio_info;
  498. struct freesync_context freesync_ctx;
  499. struct dc_transfer_func *out_transfer_func;
  500. struct colorspace_transform gamut_remap_matrix;
  501. struct csc_transform csc_color_matrix;
  502. enum signal_type output_signal;
  503. enum dc_color_space output_color_space;
  504. enum dc_dither_option dither_option;
  505. enum view_3d_format view_format;
  506. bool ignore_msa_timing_param;
  507. /* TODO: custom INFO packets */
  508. /* TODO: ABM info (DMCU) */
  509. /* TODO: PSR info */
  510. /* TODO: CEA VIC */
  511. /* from core_stream struct */
  512. struct dc_context *ctx;
  513. /* used by DCP and FMT */
  514. struct bit_depth_reduction_params bit_depth_params;
  515. struct clamping_and_pixel_encoding_params clamping;
  516. int phy_pix_clk;
  517. enum signal_type signal;
  518. bool dpms_off;
  519. struct dc_stream_status status;
  520. struct dc_cursor_attributes cursor_attributes;
  521. /* from stream struct */
  522. struct kref refcount;
  523. };
  524. struct dc_stream_update {
  525. struct rect src;
  526. struct rect dst;
  527. struct dc_transfer_func *out_transfer_func;
  528. };
  529. bool dc_is_stream_unchanged(
  530. struct dc_stream_state *old_stream, struct dc_stream_state *stream);
  531. bool dc_is_stream_scaling_unchanged(
  532. struct dc_stream_state *old_stream, struct dc_stream_state *stream);
  533. /*
  534. * Set up surface attributes and associate to a stream
  535. * The surfaces parameter is an absolute set of all surface active for the stream.
  536. * If no surfaces are provided, the stream will be blanked; no memory read.
  537. * Any flip related attribute changes must be done through this interface.
  538. *
  539. * After this call:
  540. * Surfaces attributes are programmed and configured to be composed into stream.
  541. * This does not trigger a flip. No surface address is programmed.
  542. */
  543. bool dc_commit_planes_to_stream(
  544. struct dc *dc,
  545. struct dc_plane_state **plane_states,
  546. uint8_t new_plane_count,
  547. struct dc_stream_state *dc_stream,
  548. struct dc_state *state);
  549. void dc_commit_updates_for_stream(struct dc *dc,
  550. struct dc_surface_update *srf_updates,
  551. int surface_count,
  552. struct dc_stream_state *stream,
  553. struct dc_stream_update *stream_update,
  554. struct dc_plane_state **plane_states,
  555. struct dc_state *state);
  556. /*
  557. * Log the current stream state.
  558. */
  559. void dc_stream_log(
  560. const struct dc_stream_state *stream,
  561. struct dal_logger *dc_logger,
  562. enum dc_log_type log_type);
  563. uint8_t dc_get_current_stream_count(struct dc *dc);
  564. struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);
  565. /*
  566. * Return the current frame counter.
  567. */
  568. uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);
  569. /* TODO: Return parsed values rather than direct register read
  570. * This has a dependency on the caller (amdgpu_get_crtc_scanoutpos)
  571. * being refactored properly to be dce-specific
  572. */
  573. bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
  574. uint32_t *v_blank_start,
  575. uint32_t *v_blank_end,
  576. uint32_t *h_position,
  577. uint32_t *v_position);
  578. enum dc_status dc_add_stream_to_ctx(
  579. struct dc *dc,
  580. struct dc_state *new_ctx,
  581. struct dc_stream_state *stream);
  582. enum dc_status dc_remove_stream_from_ctx(
  583. struct dc *dc,
  584. struct dc_state *new_ctx,
  585. struct dc_stream_state *stream);
  586. bool dc_add_plane_to_context(
  587. const struct dc *dc,
  588. struct dc_stream_state *stream,
  589. struct dc_plane_state *plane_state,
  590. struct dc_state *context);
  591. bool dc_remove_plane_from_context(
  592. const struct dc *dc,
  593. struct dc_stream_state *stream,
  594. struct dc_plane_state *plane_state,
  595. struct dc_state *context);
  596. bool dc_rem_all_planes_for_stream(
  597. const struct dc *dc,
  598. struct dc_stream_state *stream,
  599. struct dc_state *context);
  600. bool dc_add_all_planes_for_stream(
  601. const struct dc *dc,
  602. struct dc_stream_state *stream,
  603. struct dc_plane_state * const *plane_states,
  604. int plane_count,
  605. struct dc_state *context);
  606. /*
  607. * Structure to store surface/stream associations for validation
  608. */
  609. struct dc_validation_set {
  610. struct dc_stream_state *stream;
  611. struct dc_plane_state *plane_states[MAX_SURFACES];
  612. uint8_t plane_count;
  613. };
  614. enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream);
  615. enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state);
  616. enum dc_status dc_validate_global_state(
  617. struct dc *dc,
  618. struct dc_state *new_ctx);
  619. /*
  620. * This function takes a stream and checks if it is guaranteed to be supported.
  621. * Guaranteed means that MAX_COFUNC similar streams are supported.
  622. *
  623. * After this call:
  624. * No hardware is programmed for call. Only validation is done.
  625. */
  626. void dc_resource_state_construct(
  627. const struct dc *dc,
  628. struct dc_state *dst_ctx);
  629. void dc_resource_state_copy_construct(
  630. const struct dc_state *src_ctx,
  631. struct dc_state *dst_ctx);
  632. void dc_resource_state_copy_construct_current(
  633. const struct dc *dc,
  634. struct dc_state *dst_ctx);
  635. void dc_resource_state_destruct(struct dc_state *context);
  636. /*
  637. * TODO update to make it about validation sets
  638. * Set up streams and links associated to drive sinks
  639. * The streams parameter is an absolute set of all active streams.
  640. *
  641. * After this call:
  642. * Phy, Encoder, Timing Generator are programmed and enabled.
  643. * New streams are enabled with blank stream; no memory read.
  644. */
  645. bool dc_commit_state(struct dc *dc, struct dc_state *context);
  646. /*
  647. * Set up streams and links associated to drive sinks
  648. * The streams parameter is an absolute set of all active streams.
  649. *
  650. * After this call:
  651. * Phy, Encoder, Timing Generator are programmed and enabled.
  652. * New streams are enabled with blank stream; no memory read.
  653. */
  654. /*
  655. * Enable stereo when commit_streams is not required,
  656. * for example, frame alternate.
  657. */
  658. bool dc_enable_stereo(
  659. struct dc *dc,
  660. struct dc_state *context,
  661. struct dc_stream_state *streams[],
  662. uint8_t stream_count);
  663. /**
  664. * Create a new default stream for the requested sink
  665. */
  666. struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);
  667. void dc_stream_retain(struct dc_stream_state *dc_stream);
  668. void dc_stream_release(struct dc_stream_state *dc_stream);
  669. struct dc_stream_status *dc_stream_get_status(
  670. struct dc_stream_state *dc_stream);
  671. enum surface_update_type dc_check_update_surfaces_for_stream(
  672. struct dc *dc,
  673. struct dc_surface_update *updates,
  674. int surface_count,
  675. struct dc_stream_update *stream_update,
  676. const struct dc_stream_status *stream_status);
  677. struct dc_state *dc_create_state(void);
  678. void dc_retain_state(struct dc_state *context);
  679. void dc_release_state(struct dc_state *context);
  680. /*******************************************************************************
  681. * Link Interfaces
  682. ******************************************************************************/
  683. struct dpcd_caps {
  684. union dpcd_rev dpcd_rev;
  685. union max_lane_count max_ln_count;
  686. union max_down_spread max_down_spread;
  687. /* dongle type (DP converter, CV smart dongle) */
  688. enum display_dongle_type dongle_type;
  689. /* Dongle's downstream count. */
  690. union sink_count sink_count;
  691. /* If dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER,
  692. indicates 'Frame Sequential-to-lllFrame Pack' conversion capability.*/
  693. struct dc_dongle_caps dongle_caps;
  694. uint32_t sink_dev_id;
  695. uint32_t branch_dev_id;
  696. int8_t branch_dev_name[6];
  697. int8_t branch_hw_revision;
  698. bool allow_invalid_MSA_timing_param;
  699. bool panel_mode_edp;
  700. bool dpcd_display_control_capable;
  701. };
  702. struct dc_link_status {
  703. struct dpcd_caps *dpcd_caps;
  704. };
  705. /* DP MST stream allocation (payload bandwidth number) */
  706. struct link_mst_stream_allocation {
  707. /* DIG front */
  708. const struct stream_encoder *stream_enc;
  709. /* associate DRM payload table with DC stream encoder */
  710. uint8_t vcp_id;
  711. /* number of slots required for the DP stream in transport packet */
  712. uint8_t slot_count;
  713. };
  714. /* DP MST stream allocation table */
  715. struct link_mst_stream_allocation_table {
  716. /* number of DP video streams */
  717. int stream_count;
  718. /* array of stream allocations */
  719. struct link_mst_stream_allocation stream_allocations[MAX_CONTROLLER_NUM];
  720. };
  721. /*
  722. * A link contains one or more sinks and their connected status.
  723. * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
  724. */
  725. struct dc_link {
  726. struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
  727. unsigned int sink_count;
  728. struct dc_sink *local_sink;
  729. unsigned int link_index;
  730. enum dc_connection_type type;
  731. enum signal_type connector_signal;
  732. enum dc_irq_source irq_source_hpd;
  733. enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */
  734. /* caps is the same as reported_link_cap. link_traing use
  735. * reported_link_cap. Will clean up. TODO
  736. */
  737. struct dc_link_settings reported_link_cap;
  738. struct dc_link_settings verified_link_cap;
  739. struct dc_link_settings cur_link_settings;
  740. struct dc_lane_settings cur_lane_setting;
  741. struct dc_link_settings preferred_link_setting;
  742. uint8_t ddc_hw_inst;
  743. uint8_t hpd_src;
  744. uint8_t link_enc_hw_inst;
  745. bool test_pattern_enabled;
  746. union compliance_test_state compliance_test_state;
  747. void *priv;
  748. struct ddc_service *ddc;
  749. bool aux_mode;
  750. /* Private to DC core */
  751. const struct dc *dc;
  752. struct dc_context *ctx;
  753. struct link_encoder *link_enc;
  754. struct graphics_object_id link_id;
  755. union ddi_channel_mapping ddi_channel_mapping;
  756. struct connector_device_tag_info device_tag;
  757. struct dpcd_caps dpcd_caps;
  758. unsigned short chip_caps;
  759. unsigned int dpcd_sink_count;
  760. enum edp_revision edp_revision;
  761. bool psr_enabled;
  762. /* MST record stream using this link */
  763. struct link_flags {
  764. bool dp_keep_receiver_powered;
  765. } wa_flags;
  766. struct link_mst_stream_allocation_table mst_stream_alloc_table;
  767. struct dc_link_status link_status;
  768. };
  769. const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link);
  770. /*
  771. * Return an enumerated dc_link. dc_link order is constant and determined at
  772. * boot time. They cannot be created or destroyed.
  773. * Use dc_get_caps() to get number of links.
  774. */
  775. static inline struct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index)
  776. {
  777. return dc->links[link_index];
  778. }
  779. /* Set backlight level of an embedded panel (eDP, LVDS). */
  780. bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level,
  781. uint32_t frame_ramp, const struct dc_stream_state *stream);
  782. bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable, bool wait);
  783. bool dc_link_get_psr_state(const struct dc_link *dc_link, uint32_t *psr_state);
  784. bool dc_link_setup_psr(struct dc_link *dc_link,
  785. const struct dc_stream_state *stream, struct psr_config *psr_config,
  786. struct psr_context *psr_context);
  787. /* Request DC to detect if there is a Panel connected.
  788. * boot - If this call is during initial boot.
  789. * Return false for any type of detection failure or MST detection
  790. * true otherwise. True meaning further action is required (status update
  791. * and OS notification).
  792. */
  793. enum dc_detect_reason {
  794. DETECT_REASON_BOOT,
  795. DETECT_REASON_HPD,
  796. DETECT_REASON_HPDRX,
  797. };
  798. bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason);
  799. /* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt).
  800. * Return:
  801. * true - Downstream port status changed. DM should call DC to do the
  802. * detection.
  803. * false - no change in Downstream port status. No further action required
  804. * from DM. */
  805. bool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link,
  806. union hpd_irq_data *hpd_irq_dpcd_data);
  807. struct dc_sink_init_data;
  808. struct dc_sink *dc_link_add_remote_sink(
  809. struct dc_link *dc_link,
  810. const uint8_t *edid,
  811. int len,
  812. struct dc_sink_init_data *init_data);
  813. void dc_link_remove_remote_sink(
  814. struct dc_link *link,
  815. struct dc_sink *sink);
  816. /* Used by diagnostics for virtual link at the moment */
  817. void dc_link_dp_set_drive_settings(
  818. struct dc_link *link,
  819. struct link_training_settings *lt_settings);
  820. enum link_training_result dc_link_dp_perform_link_training(
  821. struct dc_link *link,
  822. const struct dc_link_settings *link_setting,
  823. bool skip_video_pattern);
  824. void dc_link_dp_enable_hpd(const struct dc_link *link);
  825. void dc_link_dp_disable_hpd(const struct dc_link *link);
  826. bool dc_link_dp_set_test_pattern(
  827. struct dc_link *link,
  828. enum dp_test_pattern test_pattern,
  829. const struct link_training_settings *p_link_settings,
  830. const unsigned char *p_custom_pattern,
  831. unsigned int cust_pattern_size);
  832. /*******************************************************************************
  833. * Sink Interfaces - A sink corresponds to a display output device
  834. ******************************************************************************/
  835. struct dc_container_id {
  836. // 128bit GUID in binary form
  837. unsigned char guid[16];
  838. // 8 byte port ID -> ELD.PortID
  839. unsigned int portId[2];
  840. // 128bit GUID in binary formufacturer name -> ELD.ManufacturerName
  841. unsigned short manufacturerName;
  842. // 2 byte product code -> ELD.ProductCode
  843. unsigned short productCode;
  844. };
  845. /*
  846. * The sink structure contains EDID and other display device properties
  847. */
  848. struct dc_sink {
  849. enum signal_type sink_signal;
  850. struct dc_edid dc_edid; /* raw edid */
  851. struct dc_edid_caps edid_caps; /* parse display caps */
  852. struct dc_container_id *dc_container_id;
  853. uint32_t dongle_max_pix_clk;
  854. void *priv;
  855. struct stereo_3d_features features_3d[TIMING_3D_FORMAT_MAX];
  856. bool converter_disable_audio;
  857. /* private to DC core */
  858. struct dc_link *link;
  859. struct dc_context *ctx;
  860. /* private to dc_sink.c */
  861. struct kref refcount;
  862. };
  863. void dc_sink_retain(struct dc_sink *sink);
  864. void dc_sink_release(struct dc_sink *sink);
  865. struct dc_sink_init_data {
  866. enum signal_type sink_signal;
  867. struct dc_link *link;
  868. uint32_t dongle_max_pix_clk;
  869. bool converter_disable_audio;
  870. };
  871. struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params);
  872. /*******************************************************************************
  873. * Cursor interfaces - To manages the cursor within a stream
  874. ******************************************************************************/
  875. /* TODO: Deprecated once we switch to dc_set_cursor_position */
  876. bool dc_stream_set_cursor_attributes(
  877. struct dc_stream_state *stream,
  878. const struct dc_cursor_attributes *attributes);
  879. bool dc_stream_set_cursor_position(
  880. struct dc_stream_state *stream,
  881. const struct dc_cursor_position *position);
  882. /* Newer interfaces */
  883. struct dc_cursor {
  884. struct dc_plane_address address;
  885. struct dc_cursor_attributes attributes;
  886. };
  887. /*******************************************************************************
  888. * Interrupt interfaces
  889. ******************************************************************************/
  890. enum dc_irq_source dc_interrupt_to_irq_source(
  891. struct dc *dc,
  892. uint32_t src_id,
  893. uint32_t ext_id);
  894. void dc_interrupt_set(struct dc *dc, enum dc_irq_source src, bool enable);
  895. void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src);
  896. enum dc_irq_source dc_get_hpd_irq_source_at_index(
  897. struct dc *dc, uint32_t link_index);
  898. /*******************************************************************************
  899. * Power Interfaces
  900. ******************************************************************************/
  901. void dc_set_power_state(
  902. struct dc *dc,
  903. enum dc_acpi_cm_power_state power_state);
  904. void dc_resume(struct dc *dc);
  905. /*
  906. * DPCD access interfaces
  907. */
  908. bool dc_submit_i2c(
  909. struct dc *dc,
  910. uint32_t link_index,
  911. struct i2c_command *cmd);
  912. #endif /* DC_INTERFACE_H_ */