Merge tag 'drm-misc-next-2021-10-14' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / display / dc / dc.h
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
26 #ifndef DC_INTERFACE_H_
27 #define DC_INTERFACE_H_
28
29 #include "dc_types.h"
30 #include "grph_object_defs.h"
31 #include "logger_types.h"
32 #if defined(CONFIG_DRM_AMD_DC_HDCP)
33 #include "hdcp_types.h"
34 #endif
35 #include "gpio_types.h"
36 #include "link_service_types.h"
37 #include "grph_object_ctrl_defs.h"
38 #include <inc/hw/opp.h>
39
40 #include "inc/hw_sequencer.h"
41 #include "inc/compressor.h"
42 #include "inc/hw/dmcu.h"
43 #include "dml/display_mode_lib.h"
44
45 /* forward declaration */
46 struct aux_payload;
47 struct set_config_cmd_payload;
48 struct dmub_notification;
49
50 #define DC_VER "3.2.159"
51
52 #define MAX_SURFACES 3
53 #define MAX_PLANES 6
54 #define MAX_STREAMS 6
55 #define MAX_SINKS_PER_LINK 4
56 #define MIN_VIEWPORT_SIZE 12
57 #define MAX_NUM_EDP 2
58
59 /*******************************************************************************
60  * Display Core Interfaces
61  ******************************************************************************/
62 struct dc_versions {
63         const char *dc_ver;
64         struct dmcu_version dmcu_version;
65 };
66
67 enum dp_protocol_version {
68         DP_VERSION_1_4,
69 };
70
71 enum dc_plane_type {
72         DC_PLANE_TYPE_INVALID,
73         DC_PLANE_TYPE_DCE_RGB,
74         DC_PLANE_TYPE_DCE_UNDERLAY,
75         DC_PLANE_TYPE_DCN_UNIVERSAL,
76 };
77
78 struct dc_plane_cap {
79         enum dc_plane_type type;
80         uint32_t blends_with_above : 1;
81         uint32_t blends_with_below : 1;
82         uint32_t per_pixel_alpha : 1;
83         struct {
84                 uint32_t argb8888 : 1;
85                 uint32_t nv12 : 1;
86                 uint32_t fp16 : 1;
87                 uint32_t p010 : 1;
88                 uint32_t ayuv : 1;
89         } pixel_format_support;
90         // max upscaling factor x1000
91         // upscaling factors are always >= 1
92         // for example, 1080p -> 8K is 4.0, or 4000 raw value
93         struct {
94                 uint32_t argb8888;
95                 uint32_t nv12;
96                 uint32_t fp16;
97         } max_upscale_factor;
98         // max downscale factor x1000
99         // downscale factors are always <= 1
100         // for example, 8K -> 1080p is 0.25, or 250 raw value
101         struct {
102                 uint32_t argb8888;
103                 uint32_t nv12;
104                 uint32_t fp16;
105         } max_downscale_factor;
106         // minimal width/height
107         uint32_t min_width;
108         uint32_t min_height;
109 };
110
111 // Color management caps (DPP and MPC)
112 struct rom_curve_caps {
113         uint16_t srgb : 1;
114         uint16_t bt2020 : 1;
115         uint16_t gamma2_2 : 1;
116         uint16_t pq : 1;
117         uint16_t hlg : 1;
118 };
119
120 struct dpp_color_caps {
121         uint16_t dcn_arch : 1; // all DCE generations treated the same
122         // input lut is different than most LUTs, just plain 256-entry lookup
123         uint16_t input_lut_shared : 1; // shared with DGAM
124         uint16_t icsc : 1;
125         uint16_t dgam_ram : 1;
126         uint16_t post_csc : 1; // before gamut remap
127         uint16_t gamma_corr : 1;
128
129         // hdr_mult and gamut remap always available in DPP (in that order)
130         // 3d lut implies shaper LUT,
131         // it may be shared with MPC - check MPC:shared_3d_lut flag
132         uint16_t hw_3d_lut : 1;
133         uint16_t ogam_ram : 1; // blnd gam
134         uint16_t ocsc : 1;
135         uint16_t dgam_rom_for_yuv : 1;
136         struct rom_curve_caps dgam_rom_caps;
137         struct rom_curve_caps ogam_rom_caps;
138 };
139
140 struct mpc_color_caps {
141         uint16_t gamut_remap : 1;
142         uint16_t ogam_ram : 1;
143         uint16_t ocsc : 1;
144         uint16_t num_3dluts : 3; //3d lut always assumes a preceding shaper LUT
145         uint16_t shared_3d_lut:1; //can be in either DPP or MPC, but single instance
146
147         struct rom_curve_caps ogam_rom_caps;
148 };
149
150 struct dc_color_caps {
151         struct dpp_color_caps dpp;
152         struct mpc_color_caps mpc;
153 };
154
155 struct dc_caps {
156         uint32_t max_streams;
157         uint32_t max_links;
158         uint32_t max_audios;
159         uint32_t max_slave_planes;
160         uint32_t max_slave_yuv_planes;
161         uint32_t max_slave_rgb_planes;
162         uint32_t max_planes;
163         uint32_t max_downscale_ratio;
164         uint32_t i2c_speed_in_khz;
165         uint32_t i2c_speed_in_khz_hdcp;
166         uint32_t dmdata_alloc_size;
167         unsigned int max_cursor_size;
168         unsigned int max_video_width;
169         unsigned int min_horizontal_blanking_period;
170         int linear_pitch_alignment;
171         bool dcc_const_color;
172         bool dynamic_audio;
173         bool is_apu;
174         bool dual_link_dvi;
175         bool post_blend_color_processing;
176         bool force_dp_tps4_for_cp2520;
177         bool disable_dp_clk_share;
178         bool psp_setup_panel_mode;
179         bool extended_aux_timeout_support;
180         bool dmcub_support;
181         uint32_t num_of_internal_disp;
182         enum dp_protocol_version max_dp_protocol_version;
183         unsigned int mall_size_per_mem_channel;
184         unsigned int mall_size_total;
185         unsigned int cursor_cache_size;
186         struct dc_plane_cap planes[MAX_PLANES];
187         struct dc_color_caps color;
188 #if defined(CONFIG_DRM_AMD_DC_DCN)
189         bool dp_hpo;
190 #endif
191         bool vbios_lttpr_aware;
192         bool vbios_lttpr_enable;
193 };
194
195 struct dc_bug_wa {
196         bool no_connect_phy_config;
197         bool dedcn20_305_wa;
198         bool skip_clock_update;
199         bool lt_early_cr_pattern;
200 };
201
202 struct dc_dcc_surface_param {
203         struct dc_size surface_size;
204         enum surface_pixel_format format;
205         enum swizzle_mode_values swizzle_mode;
206         enum dc_scan_direction scan;
207 };
208
209 struct dc_dcc_setting {
210         unsigned int max_compressed_blk_size;
211         unsigned int max_uncompressed_blk_size;
212         bool independent_64b_blks;
213 #if defined(CONFIG_DRM_AMD_DC_DCN)
214         //These bitfields to be used starting with DCN
215         struct {
216                 uint32_t dcc_256_64_64 : 1;//available in ASICs before DCN (the worst compression case)
217                 uint32_t dcc_128_128_uncontrained : 1;  //available in ASICs before DCN
218                 uint32_t dcc_256_128_128 : 1;           //available starting with DCN
219                 uint32_t dcc_256_256_unconstrained : 1;  //available in ASICs before DCN (the best compression case)
220         } dcc_controls;
221 #endif
222 };
223
224 struct dc_surface_dcc_cap {
225         union {
226                 struct {
227                         struct dc_dcc_setting rgb;
228                 } grph;
229
230                 struct {
231                         struct dc_dcc_setting luma;
232                         struct dc_dcc_setting chroma;
233                 } video;
234         };
235
236         bool capable;
237         bool const_color_support;
238 };
239
240 struct dc_static_screen_params {
241         struct {
242                 bool force_trigger;
243                 bool cursor_update;
244                 bool surface_update;
245                 bool overlay_update;
246         } triggers;
247         unsigned int num_frames;
248 };
249
250
251 /* Surface update type is used by dc_update_surfaces_and_stream
252  * The update type is determined at the very beginning of the function based
253  * on parameters passed in and decides how much programming (or updating) is
254  * going to be done during the call.
255  *
256  * UPDATE_TYPE_FAST is used for really fast updates that do not require much
257  * logical calculations or hardware register programming. This update MUST be
258  * ISR safe on windows. Currently fast update will only be used to flip surface
259  * address.
260  *
261  * UPDATE_TYPE_MED is used for slower updates which require significant hw
262  * re-programming however do not affect bandwidth consumption or clock
263  * requirements. At present, this is the level at which front end updates
264  * that do not require us to run bw_calcs happen. These are in/out transfer func
265  * updates, viewport offset changes, recout size changes and pixel depth changes.
266  * This update can be done at ISR, but we want to minimize how often this happens.
267  *
268  * UPDATE_TYPE_FULL is slow. Really slow. This requires us to recalculate our
269  * bandwidth and clocks, possibly rearrange some pipes and reprogram anything front
270  * end related. Any time viewport dimensions, recout dimensions, scaling ratios or
271  * gamma need to be adjusted or pipe needs to be turned on (or disconnected) we do
272  * a full update. This cannot be done at ISR level and should be a rare event.
273  * Unless someone is stress testing mpo enter/exit, playing with colour or adjusting
274  * underscan we don't expect to see this call at all.
275  */
276
277 enum surface_update_type {
278         UPDATE_TYPE_FAST, /* super fast, safe to execute in isr */
279         UPDATE_TYPE_MED,  /* ISR safe, most of programming needed, no bw/clk change*/
280         UPDATE_TYPE_FULL, /* may need to shuffle resources */
281 };
282
283 /* Forward declaration*/
284 struct dc;
285 struct dc_plane_state;
286 struct dc_state;
287
288
289 struct dc_cap_funcs {
290         bool (*get_dcc_compression_cap)(const struct dc *dc,
291                         const struct dc_dcc_surface_param *input,
292                         struct dc_surface_dcc_cap *output);
293 };
294
295 struct link_training_settings;
296
297 #if defined(CONFIG_DRM_AMD_DC_DCN)
298 union allow_lttpr_non_transparent_mode {
299         struct {
300                 bool DP1_4A : 1;
301                 bool DP2_0 : 1;
302         } bits;
303         unsigned char raw;
304 };
305 #endif
306 /* Structure to hold configuration flags set by dm at dc creation. */
307 struct dc_config {
308         bool gpu_vm_support;
309         bool disable_disp_pll_sharing;
310         bool fbc_support;
311         bool disable_fractional_pwm;
312         bool allow_seamless_boot_optimization;
313         bool power_down_display_on_boot;
314         bool edp_not_connected;
315         bool edp_no_power_sequencing;
316         bool force_enum_edp;
317         bool forced_clocks;
318 #if defined(CONFIG_DRM_AMD_DC_DCN)
319         union allow_lttpr_non_transparent_mode allow_lttpr_non_transparent_mode;
320 #else
321         bool allow_lttpr_non_transparent_mode;
322 #endif
323         bool multi_mon_pp_mclk_switch;
324         bool disable_dmcu;
325         bool enable_4to1MPC;
326         bool enable_windowed_mpo_odm;
327         bool allow_edp_hotplug_detection;
328 #if defined(CONFIG_DRM_AMD_DC_DCN)
329         bool clamp_min_dcfclk;
330 #endif
331         uint64_t vblank_alignment_dto_params;
332         uint8_t  vblank_alignment_max_frame_time_diff;
333         bool is_asymmetric_memory;
334         bool is_single_rank_dimm;
335 };
336
337 enum visual_confirm {
338         VISUAL_CONFIRM_DISABLE = 0,
339         VISUAL_CONFIRM_SURFACE = 1,
340         VISUAL_CONFIRM_HDR = 2,
341         VISUAL_CONFIRM_MPCTREE = 4,
342         VISUAL_CONFIRM_PSR = 5,
343         VISUAL_CONFIRM_SWIZZLE = 9,
344 };
345
346 enum dc_psr_power_opts {
347         psr_power_opt_invalid = 0x0,
348         psr_power_opt_smu_opt_static_screen = 0x1,
349         psr_power_opt_z10_static_screen = 0x10,
350 };
351
352 enum dcc_option {
353         DCC_ENABLE = 0,
354         DCC_DISABLE = 1,
355         DCC_HALF_REQ_DISALBE = 2,
356 };
357
358 enum pipe_split_policy {
359         MPC_SPLIT_DYNAMIC = 0,
360         MPC_SPLIT_AVOID = 1,
361         MPC_SPLIT_AVOID_MULT_DISP = 2,
362 };
363
364 enum wm_report_mode {
365         WM_REPORT_DEFAULT = 0,
366         WM_REPORT_OVERRIDE = 1,
367 };
368 enum dtm_pstate{
369         dtm_level_p0 = 0,/*highest voltage*/
370         dtm_level_p1,
371         dtm_level_p2,
372         dtm_level_p3,
373         dtm_level_p4,/*when active_display_count = 0*/
374 };
375
376 enum dcn_pwr_state {
377         DCN_PWR_STATE_UNKNOWN = -1,
378         DCN_PWR_STATE_MISSION_MODE = 0,
379         DCN_PWR_STATE_LOW_POWER = 3,
380 };
381
382 #if defined(CONFIG_DRM_AMD_DC_DCN)
383 enum dcn_zstate_support_state {
384         DCN_ZSTATE_SUPPORT_UNKNOWN,
385         DCN_ZSTATE_SUPPORT_ALLOW,
386         DCN_ZSTATE_SUPPORT_DISALLOW,
387 };
388 #endif
389 /*
390  * For any clocks that may differ per pipe
391  * only the max is stored in this structure
392  */
393 struct dc_clocks {
394         int dispclk_khz;
395         int actual_dispclk_khz;
396         int dppclk_khz;
397         int actual_dppclk_khz;
398         int disp_dpp_voltage_level_khz;
399         int dcfclk_khz;
400         int socclk_khz;
401         int dcfclk_deep_sleep_khz;
402         int fclk_khz;
403         int phyclk_khz;
404         int dramclk_khz;
405         bool p_state_change_support;
406 #if defined(CONFIG_DRM_AMD_DC_DCN)
407         enum dcn_zstate_support_state zstate_support;
408         bool dtbclk_en;
409 #endif
410         enum dcn_pwr_state pwr_state;
411         /*
412          * Elements below are not compared for the purposes of
413          * optimization required
414          */
415         bool prev_p_state_change_support;
416         enum dtm_pstate dtm_level;
417         int max_supported_dppclk_khz;
418         int max_supported_dispclk_khz;
419         int bw_dppclk_khz; /*a copy of dppclk_khz*/
420         int bw_dispclk_khz;
421 };
422
423 struct dc_bw_validation_profile {
424         bool enable;
425
426         unsigned long long total_ticks;
427         unsigned long long voltage_level_ticks;
428         unsigned long long watermark_ticks;
429         unsigned long long rq_dlg_ticks;
430
431         unsigned long long total_count;
432         unsigned long long skip_fast_count;
433         unsigned long long skip_pass_count;
434         unsigned long long skip_fail_count;
435 };
436
437 #define BW_VAL_TRACE_SETUP() \
438                 unsigned long long end_tick = 0; \
439                 unsigned long long voltage_level_tick = 0; \
440                 unsigned long long watermark_tick = 0; \
441                 unsigned long long start_tick = dc->debug.bw_val_profile.enable ? \
442                                 dm_get_timestamp(dc->ctx) : 0
443
444 #define BW_VAL_TRACE_COUNT() \
445                 if (dc->debug.bw_val_profile.enable) \
446                         dc->debug.bw_val_profile.total_count++
447
448 #define BW_VAL_TRACE_SKIP(status) \
449                 if (dc->debug.bw_val_profile.enable) { \
450                         if (!voltage_level_tick) \
451                                 voltage_level_tick = dm_get_timestamp(dc->ctx); \
452                         dc->debug.bw_val_profile.skip_ ## status ## _count++; \
453                 }
454
455 #define BW_VAL_TRACE_END_VOLTAGE_LEVEL() \
456                 if (dc->debug.bw_val_profile.enable) \
457                         voltage_level_tick = dm_get_timestamp(dc->ctx)
458
459 #define BW_VAL_TRACE_END_WATERMARKS() \
460                 if (dc->debug.bw_val_profile.enable) \
461                         watermark_tick = dm_get_timestamp(dc->ctx)
462
463 #define BW_VAL_TRACE_FINISH() \
464                 if (dc->debug.bw_val_profile.enable) { \
465                         end_tick = dm_get_timestamp(dc->ctx); \
466                         dc->debug.bw_val_profile.total_ticks += end_tick - start_tick; \
467                         dc->debug.bw_val_profile.voltage_level_ticks += voltage_level_tick - start_tick; \
468                         if (watermark_tick) { \
469                                 dc->debug.bw_val_profile.watermark_ticks += watermark_tick - voltage_level_tick; \
470                                 dc->debug.bw_val_profile.rq_dlg_ticks += end_tick - watermark_tick; \
471                         } \
472                 }
473
474 union mem_low_power_enable_options {
475         struct {
476                 bool vga: 1;
477                 bool i2c: 1;
478                 bool dmcu: 1;
479                 bool dscl: 1;
480                 bool cm: 1;
481                 bool mpc: 1;
482                 bool optc: 1;
483                 bool vpg: 1;
484                 bool afmt: 1;
485         } bits;
486         uint32_t u32All;
487 };
488
489 union root_clock_optimization_options {
490         struct {
491                 bool dpp: 1;
492                 bool dsc: 1;
493                 bool hdmistream: 1;
494                 bool hdmichar: 1;
495                 bool dpstream: 1;
496                 bool symclk32_se: 1;
497                 bool symclk32_le: 1;
498                 bool symclk_fe: 1;
499                 bool physymclk: 1;
500                 bool dpiasymclk: 1;
501                 uint32_t reserved: 22;
502         } bits;
503         uint32_t u32All;
504 };
505
506 union dpia_debug_options {
507         struct {
508                 uint32_t disable_dpia:1;
509                 uint32_t force_non_lttpr:1;
510                 uint32_t extend_aux_rd_interval:1;
511                 uint32_t reserved:29;
512         } bits;
513         uint32_t raw;
514 };
515
516 struct dc_debug_data {
517         uint32_t ltFailCount;
518         uint32_t i2cErrorCount;
519         uint32_t auxErrorCount;
520 };
521
522 struct dc_phy_addr_space_config {
523         struct {
524                 uint64_t start_addr;
525                 uint64_t end_addr;
526                 uint64_t fb_top;
527                 uint64_t fb_offset;
528                 uint64_t fb_base;
529                 uint64_t agp_top;
530                 uint64_t agp_bot;
531                 uint64_t agp_base;
532         } system_aperture;
533
534         struct {
535                 uint64_t page_table_start_addr;
536                 uint64_t page_table_end_addr;
537                 uint64_t page_table_base_addr;
538                 bool base_addr_is_mc_addr;
539         } gart_config;
540
541         bool valid;
542         bool is_hvm_enabled;
543         uint64_t page_table_default_page_addr;
544 };
545
546 struct dc_virtual_addr_space_config {
547         uint64_t        page_table_base_addr;
548         uint64_t        page_table_start_addr;
549         uint64_t        page_table_end_addr;
550         uint32_t        page_table_block_size_in_bytes;
551         uint8_t         page_table_depth; // 1 = 1 level, 2 = 2 level, etc.  0 = invalid
552 };
553
554 struct dc_bounding_box_overrides {
555         int sr_exit_time_ns;
556         int sr_enter_plus_exit_time_ns;
557         int urgent_latency_ns;
558         int percent_of_ideal_drambw;
559         int dram_clock_change_latency_ns;
560         int dummy_clock_change_latency_ns;
561         /* This forces a hard min on the DCFCLK we use
562          * for DML.  Unlike the debug option for forcing
563          * DCFCLK, this override affects watermark calculations
564          */
565         int min_dcfclk_mhz;
566 };
567
568 struct dc_state;
569 struct resource_pool;
570 struct dce_hwseq;
571
572 struct dc_debug_options {
573         bool native422_support;
574         bool disable_dsc;
575         enum visual_confirm visual_confirm;
576         bool sanity_checks;
577         bool max_disp_clk;
578         bool surface_trace;
579         bool timing_trace;
580         bool clock_trace;
581         bool validation_trace;
582         bool bandwidth_calcs_trace;
583         int max_downscale_src_width;
584
585         /* stutter efficiency related */
586         bool disable_stutter;
587         bool use_max_lb;
588         enum dcc_option disable_dcc;
589         enum pipe_split_policy pipe_split_policy;
590         bool force_single_disp_pipe_split;
591         bool voltage_align_fclk;
592         bool disable_min_fclk;
593
594         bool disable_dfs_bypass;
595         bool disable_dpp_power_gate;
596         bool disable_hubp_power_gate;
597         bool disable_dsc_power_gate;
598         int dsc_min_slice_height_override;
599         int dsc_bpp_increment_div;
600         bool disable_pplib_wm_range;
601         enum wm_report_mode pplib_wm_report_mode;
602         unsigned int min_disp_clk_khz;
603         unsigned int min_dpp_clk_khz;
604         unsigned int min_dram_clk_khz;
605         int sr_exit_time_dpm0_ns;
606         int sr_enter_plus_exit_time_dpm0_ns;
607         int sr_exit_time_ns;
608         int sr_enter_plus_exit_time_ns;
609         int urgent_latency_ns;
610         uint32_t underflow_assert_delay_us;
611         int percent_of_ideal_drambw;
612         int dram_clock_change_latency_ns;
613         bool optimized_watermark;
614         int always_scale;
615         bool disable_pplib_clock_request;
616         bool disable_clock_gate;
617         bool disable_mem_low_power;
618 #if defined(CONFIG_DRM_AMD_DC_DCN)
619         bool pstate_enabled;
620 #endif
621         bool disable_dmcu;
622         bool disable_psr;
623         bool force_abm_enable;
624         bool disable_stereo_support;
625         bool vsr_support;
626         bool performance_trace;
627         bool az_endpoint_mute_only;
628         bool always_use_regamma;
629         bool recovery_enabled;
630         bool avoid_vbios_exec_table;
631         bool scl_reset_length10;
632         bool hdmi20_disable;
633         bool skip_detection_link_training;
634         uint32_t edid_read_retry_times;
635         bool remove_disconnect_edp;
636         unsigned int force_odm_combine; //bit vector based on otg inst
637 #if defined(CONFIG_DRM_AMD_DC_DCN)
638         unsigned int force_odm_combine_4to1; //bit vector based on otg inst
639         bool disable_z9_mpc;
640 #endif
641         unsigned int force_fclk_khz;
642         bool enable_tri_buf;
643         bool dmub_offload_enabled;
644         bool dmcub_emulation;
645 #if defined(CONFIG_DRM_AMD_DC_DCN)
646         bool disable_idle_power_optimizations;
647         unsigned int mall_size_override;
648         unsigned int mall_additional_timer_percent;
649         bool mall_error_as_fatal;
650 #endif
651         bool dmub_command_table; /* for testing only */
652         struct dc_bw_validation_profile bw_val_profile;
653         bool disable_fec;
654         bool disable_48mhz_pwrdwn;
655         /* This forces a hard min on the DCFCLK requested to SMU/PP
656          * watermarks are not affected.
657          */
658         unsigned int force_min_dcfclk_mhz;
659 #if defined(CONFIG_DRM_AMD_DC_DCN)
660         int dwb_fi_phase;
661 #endif
662         bool disable_timing_sync;
663         bool cm_in_bypass;
664         int force_clock_mode;/*every mode change.*/
665
666         bool disable_dram_clock_change_vactive_support;
667         bool validate_dml_output;
668         bool enable_dmcub_surface_flip;
669         bool usbc_combo_phy_reset_wa;
670         bool enable_dram_clock_change_one_display_vactive;
671 #if defined(CONFIG_DRM_AMD_DC_DCN)
672         /* TODO - remove once tested */
673         bool legacy_dp2_lt;
674         bool set_mst_en_for_sst;
675 #endif
676         union mem_low_power_enable_options enable_mem_low_power;
677         union root_clock_optimization_options root_clock_optimization;
678         bool force_vblank_alignment;
679
680         /* Enable dmub aux for legacy ddc */
681         bool enable_dmub_aux_for_legacy_ddc;
682         bool optimize_edp_link_rate; /* eDP ILR */
683         /* FEC/PSR1 sequence enable delay in 100us */
684         uint8_t fec_enable_delay_in100us;
685         bool enable_driver_sequence_debug;
686 #if defined(CONFIG_DRM_AMD_DC_DCN)
687         bool disable_z10;
688         bool enable_sw_cntl_psr;
689         union dpia_debug_options dpia_debug;
690 #endif
691 };
692
693 struct gpu_info_soc_bounding_box_v1_0;
694 struct dc {
695         struct dc_debug_options debug;
696         struct dc_versions versions;
697         struct dc_caps caps;
698         struct dc_cap_funcs cap_funcs;
699         struct dc_config config;
700         struct dc_bounding_box_overrides bb_overrides;
701         struct dc_bug_wa work_arounds;
702         struct dc_context *ctx;
703         struct dc_phy_addr_space_config vm_pa_config;
704
705         uint8_t link_count;
706         struct dc_link *links[MAX_PIPES * 2];
707
708         struct dc_state *current_state;
709         struct resource_pool *res_pool;
710
711         struct clk_mgr *clk_mgr;
712
713         /* Display Engine Clock levels */
714         struct dm_pp_clock_levels sclk_lvls;
715
716         /* Inputs into BW and WM calculations. */
717         struct bw_calcs_dceip *bw_dceip;
718         struct bw_calcs_vbios *bw_vbios;
719 #ifdef CONFIG_DRM_AMD_DC_DCN
720         struct dcn_soc_bounding_box *dcn_soc;
721         struct dcn_ip_params *dcn_ip;
722         struct display_mode_lib dml;
723 #endif
724
725         /* HW functions */
726         struct hw_sequencer_funcs hwss;
727         struct dce_hwseq *hwseq;
728
729         /* Require to optimize clocks and bandwidth for added/removed planes */
730         bool optimized_required;
731         bool wm_optimized_required;
732 #if defined(CONFIG_DRM_AMD_DC_DCN)
733         bool idle_optimizations_allowed;
734 #endif
735 #if defined(CONFIG_DRM_AMD_DC_DCN)
736         bool enable_c20_dtm_b0;
737 #endif
738
739         /* Require to maintain clocks and bandwidth for UEFI enabled HW */
740
741         /* FBC compressor */
742         struct compressor *fbc_compressor;
743
744         struct dc_debug_data debug_data;
745         struct dpcd_vendor_signature vendor_signature;
746
747         const char *build_id;
748         struct vm_helper *vm_helper;
749 };
750
751 enum frame_buffer_mode {
752         FRAME_BUFFER_MODE_LOCAL_ONLY = 0,
753         FRAME_BUFFER_MODE_ZFB_ONLY,
754         FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL,
755 } ;
756
757 struct dchub_init_data {
758         int64_t zfb_phys_addr_base;
759         int64_t zfb_mc_base_addr;
760         uint64_t zfb_size_in_byte;
761         enum frame_buffer_mode fb_mode;
762         bool dchub_initialzied;
763         bool dchub_info_valid;
764 };
765
766 struct dc_init_data {
767         struct hw_asic_id asic_id;
768         void *driver; /* ctx */
769         struct cgs_device *cgs_device;
770         struct dc_bounding_box_overrides bb_overrides;
771
772         int num_virtual_links;
773         /*
774          * If 'vbios_override' not NULL, it will be called instead
775          * of the real VBIOS. Intended use is Diagnostics on FPGA.
776          */
777         struct dc_bios *vbios_override;
778         enum dce_environment dce_environment;
779
780         struct dmub_offload_funcs *dmub_if;
781         struct dc_reg_helper_state *dmub_offload;
782
783         struct dc_config flags;
784         uint64_t log_mask;
785
786         struct dpcd_vendor_signature vendor_signature;
787 #if defined(CONFIG_DRM_AMD_DC_DCN)
788         bool force_smu_not_present;
789 #endif
790 };
791
792 struct dc_callback_init {
793 #ifdef CONFIG_DRM_AMD_DC_HDCP
794         struct cp_psp cp_psp;
795 #else
796         uint8_t reserved;
797 #endif
798 };
799
800 struct dc *dc_create(const struct dc_init_data *init_params);
801 void dc_hardware_init(struct dc *dc);
802
803 int dc_get_vmid_use_vector(struct dc *dc);
804 void dc_setup_vm_context(struct dc *dc, struct dc_virtual_addr_space_config *va_config, int vmid);
805 /* Returns the number of vmids supported */
806 int dc_setup_system_context(struct dc *dc, struct dc_phy_addr_space_config *pa_config);
807 void dc_init_callbacks(struct dc *dc,
808                 const struct dc_callback_init *init_params);
809 void dc_deinit_callbacks(struct dc *dc);
810 void dc_destroy(struct dc **dc);
811
812 /*******************************************************************************
813  * Surface Interfaces
814  ******************************************************************************/
815
816 enum {
817         TRANSFER_FUNC_POINTS = 1025
818 };
819
820 struct dc_hdr_static_metadata {
821         /* display chromaticities and white point in units of 0.00001 */
822         unsigned int chromaticity_green_x;
823         unsigned int chromaticity_green_y;
824         unsigned int chromaticity_blue_x;
825         unsigned int chromaticity_blue_y;
826         unsigned int chromaticity_red_x;
827         unsigned int chromaticity_red_y;
828         unsigned int chromaticity_white_point_x;
829         unsigned int chromaticity_white_point_y;
830
831         uint32_t min_luminance;
832         uint32_t max_luminance;
833         uint32_t maximum_content_light_level;
834         uint32_t maximum_frame_average_light_level;
835 };
836
837 enum dc_transfer_func_type {
838         TF_TYPE_PREDEFINED,
839         TF_TYPE_DISTRIBUTED_POINTS,
840         TF_TYPE_BYPASS,
841         TF_TYPE_HWPWL
842 };
843
844 struct dc_transfer_func_distributed_points {
845         struct fixed31_32 red[TRANSFER_FUNC_POINTS];
846         struct fixed31_32 green[TRANSFER_FUNC_POINTS];
847         struct fixed31_32 blue[TRANSFER_FUNC_POINTS];
848
849         uint16_t end_exponent;
850         uint16_t x_point_at_y1_red;
851         uint16_t x_point_at_y1_green;
852         uint16_t x_point_at_y1_blue;
853 };
854
855 enum dc_transfer_func_predefined {
856         TRANSFER_FUNCTION_SRGB,
857         TRANSFER_FUNCTION_BT709,
858         TRANSFER_FUNCTION_PQ,
859         TRANSFER_FUNCTION_LINEAR,
860         TRANSFER_FUNCTION_UNITY,
861         TRANSFER_FUNCTION_HLG,
862         TRANSFER_FUNCTION_HLG12,
863         TRANSFER_FUNCTION_GAMMA22,
864         TRANSFER_FUNCTION_GAMMA24,
865         TRANSFER_FUNCTION_GAMMA26
866 };
867
868
869 struct dc_transfer_func {
870         struct kref refcount;
871         enum dc_transfer_func_type type;
872         enum dc_transfer_func_predefined tf;
873         /* FP16 1.0 reference level in nits, default is 80 nits, only for PQ*/
874         uint32_t sdr_ref_white_level;
875         union {
876                 struct pwl_params pwl;
877                 struct dc_transfer_func_distributed_points tf_pts;
878         };
879 };
880
881
882 union dc_3dlut_state {
883         struct {
884                 uint32_t initialized:1;         /*if 3dlut is went through color module for initialization */
885                 uint32_t rmu_idx_valid:1;       /*if mux settings are valid*/
886                 uint32_t rmu_mux_num:3;         /*index of mux to use*/
887                 uint32_t mpc_rmu0_mux:4;        /*select mpcc on mux, one of the following : mpcc0, mpcc1, mpcc2, mpcc3*/
888                 uint32_t mpc_rmu1_mux:4;
889                 uint32_t mpc_rmu2_mux:4;
890                 uint32_t reserved:15;
891         } bits;
892         uint32_t raw;
893 };
894
895
896 struct dc_3dlut {
897         struct kref refcount;
898         struct tetrahedral_params lut_3d;
899         struct fixed31_32 hdr_multiplier;
900         union dc_3dlut_state state;
901 };
902 /*
903  * This structure is filled in by dc_surface_get_status and contains
904  * the last requested address and the currently active address so the called
905  * can determine if there are any outstanding flips
906  */
907 struct dc_plane_status {
908         struct dc_plane_address requested_address;
909         struct dc_plane_address current_address;
910         bool is_flip_pending;
911         bool is_right_eye;
912 };
913
914 union surface_update_flags {
915
916         struct {
917                 uint32_t addr_update:1;
918                 /* Medium updates */
919                 uint32_t dcc_change:1;
920                 uint32_t color_space_change:1;
921                 uint32_t horizontal_mirror_change:1;
922                 uint32_t per_pixel_alpha_change:1;
923                 uint32_t global_alpha_change:1;
924                 uint32_t hdr_mult:1;
925                 uint32_t rotation_change:1;
926                 uint32_t swizzle_change:1;
927                 uint32_t scaling_change:1;
928                 uint32_t position_change:1;
929                 uint32_t in_transfer_func_change:1;
930                 uint32_t input_csc_change:1;
931                 uint32_t coeff_reduction_change:1;
932                 uint32_t output_tf_change:1;
933                 uint32_t pixel_format_change:1;
934                 uint32_t plane_size_change:1;
935                 uint32_t gamut_remap_change:1;
936
937                 /* Full updates */
938                 uint32_t new_plane:1;
939                 uint32_t bpp_change:1;
940                 uint32_t gamma_change:1;
941                 uint32_t bandwidth_change:1;
942                 uint32_t clock_change:1;
943                 uint32_t stereo_format_change:1;
944                 uint32_t lut_3d:1;
945                 uint32_t full_update:1;
946         } bits;
947
948         uint32_t raw;
949 };
950
951 struct dc_plane_state {
952         struct dc_plane_address address;
953         struct dc_plane_flip_time time;
954         bool triplebuffer_flips;
955         struct scaling_taps scaling_quality;
956         struct rect src_rect;
957         struct rect dst_rect;
958         struct rect clip_rect;
959
960         struct plane_size plane_size;
961         union dc_tiling_info tiling_info;
962
963         struct dc_plane_dcc_param dcc;
964
965         struct dc_gamma *gamma_correction;
966         struct dc_transfer_func *in_transfer_func;
967         struct dc_bias_and_scale *bias_and_scale;
968         struct dc_csc_transform input_csc_color_matrix;
969         struct fixed31_32 coeff_reduction_factor;
970         struct fixed31_32 hdr_mult;
971         struct colorspace_transform gamut_remap_matrix;
972
973         // TODO: No longer used, remove
974         struct dc_hdr_static_metadata hdr_static_ctx;
975
976         enum dc_color_space color_space;
977
978         struct dc_3dlut *lut3d_func;
979         struct dc_transfer_func *in_shaper_func;
980         struct dc_transfer_func *blend_tf;
981
982 #if defined(CONFIG_DRM_AMD_DC_DCN)
983         struct dc_transfer_func *gamcor_tf;
984 #endif
985         enum surface_pixel_format format;
986         enum dc_rotation_angle rotation;
987         enum plane_stereo_format stereo_format;
988
989         bool is_tiling_rotated;
990         bool per_pixel_alpha;
991         bool global_alpha;
992         int  global_alpha_value;
993         bool visible;
994         bool flip_immediate;
995         bool horizontal_mirror;
996         int layer_index;
997
998         union surface_update_flags update_flags;
999         bool flip_int_enabled;
1000         bool skip_manual_trigger;
1001
1002         /* private to DC core */
1003         struct dc_plane_status status;
1004         struct dc_context *ctx;
1005
1006         /* HACK: Workaround for forcing full reprogramming under some conditions */
1007         bool force_full_update;
1008
1009         /* private to dc_surface.c */
1010         enum dc_irq_source irq_source;
1011         struct kref refcount;
1012 };
1013
1014 struct dc_plane_info {
1015         struct plane_size plane_size;
1016         union dc_tiling_info tiling_info;
1017         struct dc_plane_dcc_param dcc;
1018         enum surface_pixel_format format;
1019         enum dc_rotation_angle rotation;
1020         enum plane_stereo_format stereo_format;
1021         enum dc_color_space color_space;
1022         bool horizontal_mirror;
1023         bool visible;
1024         bool per_pixel_alpha;
1025         bool global_alpha;
1026         int  global_alpha_value;
1027         bool input_csc_enabled;
1028         int layer_index;
1029 };
1030
1031 struct dc_scaling_info {
1032         struct rect src_rect;
1033         struct rect dst_rect;
1034         struct rect clip_rect;
1035         struct scaling_taps scaling_quality;
1036 };
1037
1038 struct dc_surface_update {
1039         struct dc_plane_state *surface;
1040
1041         /* isr safe update parameters.  null means no updates */
1042         const struct dc_flip_addrs *flip_addr;
1043         const struct dc_plane_info *plane_info;
1044         const struct dc_scaling_info *scaling_info;
1045         struct fixed31_32 hdr_mult;
1046         /* following updates require alloc/sleep/spin that is not isr safe,
1047          * null means no updates
1048          */
1049         const struct dc_gamma *gamma;
1050         const struct dc_transfer_func *in_transfer_func;
1051
1052         const struct dc_csc_transform *input_csc_color_matrix;
1053         const struct fixed31_32 *coeff_reduction_factor;
1054         const struct dc_transfer_func *func_shaper;
1055         const struct dc_3dlut *lut3d_func;
1056         const struct dc_transfer_func *blend_tf;
1057         const struct colorspace_transform *gamut_remap_matrix;
1058 };
1059
1060 /*
1061  * Create a new surface with default parameters;
1062  */
1063 struct dc_plane_state *dc_create_plane_state(struct dc *dc);
1064 const struct dc_plane_status *dc_plane_get_status(
1065                 const struct dc_plane_state *plane_state);
1066
1067 void dc_plane_state_retain(struct dc_plane_state *plane_state);
1068 void dc_plane_state_release(struct dc_plane_state *plane_state);
1069
1070 void dc_gamma_retain(struct dc_gamma *dc_gamma);
1071 void dc_gamma_release(struct dc_gamma **dc_gamma);
1072 struct dc_gamma *dc_create_gamma(void);
1073
1074 void dc_transfer_func_retain(struct dc_transfer_func *dc_tf);
1075 void dc_transfer_func_release(struct dc_transfer_func *dc_tf);
1076 struct dc_transfer_func *dc_create_transfer_func(void);
1077
1078 struct dc_3dlut *dc_create_3dlut_func(void);
1079 void dc_3dlut_func_release(struct dc_3dlut *lut);
1080 void dc_3dlut_func_retain(struct dc_3dlut *lut);
1081 /*
1082  * This structure holds a surface address.  There could be multiple addresses
1083  * in cases such as Stereo 3D, Planar YUV, etc.  Other per-flip attributes such
1084  * as frame durations and DCC format can also be set.
1085  */
1086 struct dc_flip_addrs {
1087         struct dc_plane_address address;
1088         unsigned int flip_timestamp_in_us;
1089         bool flip_immediate;
1090         /* TODO: add flip duration for FreeSync */
1091         bool triplebuffer_flips;
1092 };
1093
1094 void dc_post_update_surfaces_to_stream(
1095                 struct dc *dc);
1096
1097 #include "dc_stream.h"
1098
1099 /*
1100  * Structure to store surface/stream associations for validation
1101  */
1102 struct dc_validation_set {
1103         struct dc_stream_state *stream;
1104         struct dc_plane_state *plane_states[MAX_SURFACES];
1105         uint8_t plane_count;
1106 };
1107
1108 bool dc_validate_seamless_boot_timing(const struct dc *dc,
1109                                 const struct dc_sink *sink,
1110                                 struct dc_crtc_timing *crtc_timing);
1111
1112 enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state);
1113
1114 void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info);
1115
1116 bool dc_set_generic_gpio_for_stereo(bool enable,
1117                 struct gpio_service *gpio_service);
1118
1119 /*
1120  * fast_validate: we return after determining if we can support the new state,
1121  * but before we populate the programming info
1122  */
1123 enum dc_status dc_validate_global_state(
1124                 struct dc *dc,
1125                 struct dc_state *new_ctx,
1126                 bool fast_validate);
1127
1128
1129 void dc_resource_state_construct(
1130                 const struct dc *dc,
1131                 struct dc_state *dst_ctx);
1132
1133 #if defined(CONFIG_DRM_AMD_DC_DCN)
1134 bool dc_acquire_release_mpc_3dlut(
1135                 struct dc *dc, bool acquire,
1136                 struct dc_stream_state *stream,
1137                 struct dc_3dlut **lut,
1138                 struct dc_transfer_func **shaper);
1139 #endif
1140
1141 void dc_resource_state_copy_construct(
1142                 const struct dc_state *src_ctx,
1143                 struct dc_state *dst_ctx);
1144
1145 void dc_resource_state_copy_construct_current(
1146                 const struct dc *dc,
1147                 struct dc_state *dst_ctx);
1148
1149 void dc_resource_state_destruct(struct dc_state *context);
1150
1151 bool dc_resource_is_dsc_encoding_supported(const struct dc *dc);
1152
1153 /*
1154  * TODO update to make it about validation sets
1155  * Set up streams and links associated to drive sinks
1156  * The streams parameter is an absolute set of all active streams.
1157  *
1158  * After this call:
1159  *   Phy, Encoder, Timing Generator are programmed and enabled.
1160  *   New streams are enabled with blank stream; no memory read.
1161  */
1162 bool dc_commit_state(struct dc *dc, struct dc_state *context);
1163
1164 struct dc_state *dc_create_state(struct dc *dc);
1165 struct dc_state *dc_copy_state(struct dc_state *src_ctx);
1166 void dc_retain_state(struct dc_state *context);
1167 void dc_release_state(struct dc_state *context);
1168
1169 /*******************************************************************************
1170  * Link Interfaces
1171  ******************************************************************************/
1172
1173 struct dpcd_caps {
1174         union dpcd_rev dpcd_rev;
1175         union max_lane_count max_ln_count;
1176         union max_down_spread max_down_spread;
1177         union dprx_feature dprx_feature;
1178
1179         /* valid only for eDP v1.4 or higher*/
1180         uint8_t edp_supported_link_rates_count;
1181         enum dc_link_rate edp_supported_link_rates[8];
1182
1183         /* dongle type (DP converter, CV smart dongle) */
1184         enum display_dongle_type dongle_type;
1185         /* branch device or sink device */
1186         bool is_branch_dev;
1187         /* Dongle's downstream count. */
1188         union sink_count sink_count;
1189         /* If dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER,
1190         indicates 'Frame Sequential-to-lllFrame Pack' conversion capability.*/
1191         struct dc_dongle_caps dongle_caps;
1192
1193         uint32_t sink_dev_id;
1194         int8_t sink_dev_id_str[6];
1195         int8_t sink_hw_revision;
1196         int8_t sink_fw_revision[2];
1197
1198         uint32_t branch_dev_id;
1199         int8_t branch_dev_name[6];
1200         int8_t branch_hw_revision;
1201         int8_t branch_fw_revision[2];
1202
1203         bool allow_invalid_MSA_timing_param;
1204         bool panel_mode_edp;
1205         bool dpcd_display_control_capable;
1206         bool ext_receiver_cap_field_present;
1207         bool dynamic_backlight_capable_edp;
1208         union dpcd_fec_capability fec_cap;
1209         struct dpcd_dsc_capabilities dsc_caps;
1210         struct dc_lttpr_caps lttpr_caps;
1211         struct psr_caps psr_caps;
1212         struct dpcd_usb4_dp_tunneling_info usb4_dp_tun_info;
1213
1214 #if defined(CONFIG_DRM_AMD_DC_DCN)
1215         union dp_128b_132b_supported_link_rates dp_128b_132b_supported_link_rates;
1216         union dp_main_line_channel_coding_cap channel_coding_cap;
1217         union dp_sink_video_fallback_formats fallback_formats;
1218         union dp_fec_capability1 fec_cap1;
1219 #endif
1220 };
1221
1222 union dpcd_sink_ext_caps {
1223         struct {
1224                 /* 0 - Sink supports backlight adjust via PWM during SDR/HDR mode
1225                  * 1 - Sink supports backlight adjust via AUX during SDR/HDR mode.
1226                  */
1227                 uint8_t sdr_aux_backlight_control : 1;
1228                 uint8_t hdr_aux_backlight_control : 1;
1229                 uint8_t reserved_1 : 2;
1230                 uint8_t oled : 1;
1231                 uint8_t reserved : 3;
1232         } bits;
1233         uint8_t raw;
1234 };
1235
1236 #if defined(CONFIG_DRM_AMD_DC_HDCP)
1237 union hdcp_rx_caps {
1238         struct {
1239                 uint8_t version;
1240                 uint8_t reserved;
1241                 struct {
1242                         uint8_t repeater        : 1;
1243                         uint8_t hdcp_capable    : 1;
1244                         uint8_t reserved        : 6;
1245                 } byte0;
1246         } fields;
1247         uint8_t raw[3];
1248 };
1249
1250 union hdcp_bcaps {
1251         struct {
1252                 uint8_t HDCP_CAPABLE:1;
1253                 uint8_t REPEATER:1;
1254                 uint8_t RESERVED:6;
1255         } bits;
1256         uint8_t raw;
1257 };
1258
1259 struct hdcp_caps {
1260         union hdcp_rx_caps rx_caps;
1261         union hdcp_bcaps bcaps;
1262 };
1263 #endif
1264
1265 #include "dc_link.h"
1266
1267 #if defined(CONFIG_DRM_AMD_DC_DCN)
1268 uint32_t dc_get_opp_for_plane(struct dc *dc, struct dc_plane_state *plane);
1269
1270 #endif
1271 /*******************************************************************************
1272  * Sink Interfaces - A sink corresponds to a display output device
1273  ******************************************************************************/
1274
1275 struct dc_container_id {
1276         // 128bit GUID in binary form
1277         unsigned char  guid[16];
1278         // 8 byte port ID -> ELD.PortID
1279         unsigned int   portId[2];
1280         // 128bit GUID in binary formufacturer name -> ELD.ManufacturerName
1281         unsigned short manufacturerName;
1282         // 2 byte product code -> ELD.ProductCode
1283         unsigned short productCode;
1284 };
1285
1286
1287 struct dc_sink_dsc_caps {
1288         // 'true' if these are virtual DPCD's DSC caps (immediately upstream of sink in MST topology),
1289         // 'false' if they are sink's DSC caps
1290         bool is_virtual_dpcd_dsc;
1291         struct dsc_dec_dpcd_caps dsc_dec_caps;
1292 };
1293
1294 struct dc_sink_fec_caps {
1295         bool is_rx_fec_supported;
1296         bool is_topology_fec_supported;
1297 };
1298
1299 /*
1300  * The sink structure contains EDID and other display device properties
1301  */
1302 struct dc_sink {
1303         enum signal_type sink_signal;
1304         struct dc_edid dc_edid; /* raw edid */
1305         struct dc_edid_caps edid_caps; /* parse display caps */
1306         struct dc_container_id *dc_container_id;
1307         uint32_t dongle_max_pix_clk;
1308         void *priv;
1309         struct stereo_3d_features features_3d[TIMING_3D_FORMAT_MAX];
1310         bool converter_disable_audio;
1311
1312         struct dc_sink_dsc_caps dsc_caps;
1313         struct dc_sink_fec_caps fec_caps;
1314
1315         bool is_vsc_sdp_colorimetry_supported;
1316
1317         /* private to DC core */
1318         struct dc_link *link;
1319         struct dc_context *ctx;
1320
1321         uint32_t sink_id;
1322
1323         /* private to dc_sink.c */
1324         // refcount must be the last member in dc_sink, since we want the
1325         // sink structure to be logically cloneable up to (but not including)
1326         // refcount
1327         struct kref refcount;
1328 };
1329
1330 void dc_sink_retain(struct dc_sink *sink);
1331 void dc_sink_release(struct dc_sink *sink);
1332
1333 struct dc_sink_init_data {
1334         enum signal_type sink_signal;
1335         struct dc_link *link;
1336         uint32_t dongle_max_pix_clk;
1337         bool converter_disable_audio;
1338 };
1339
1340 struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params);
1341
1342 /* Newer interfaces  */
1343 struct dc_cursor {
1344         struct dc_plane_address address;
1345         struct dc_cursor_attributes attributes;
1346 };
1347
1348
1349 /*******************************************************************************
1350  * Interrupt interfaces
1351  ******************************************************************************/
1352 enum dc_irq_source dc_interrupt_to_irq_source(
1353                 struct dc *dc,
1354                 uint32_t src_id,
1355                 uint32_t ext_id);
1356 bool dc_interrupt_set(struct dc *dc, enum dc_irq_source src, bool enable);
1357 void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src);
1358 enum dc_irq_source dc_get_hpd_irq_source_at_index(
1359                 struct dc *dc, uint32_t link_index);
1360
1361 void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bool enable);
1362
1363 /*******************************************************************************
1364  * Power Interfaces
1365  ******************************************************************************/
1366
1367 void dc_set_power_state(
1368                 struct dc *dc,
1369                 enum dc_acpi_cm_power_state power_state);
1370 void dc_resume(struct dc *dc);
1371
1372 void dc_power_down_on_boot(struct dc *dc);
1373
1374 #if defined(CONFIG_DRM_AMD_DC_HDCP)
1375 /*
1376  * HDCP Interfaces
1377  */
1378 enum hdcp_message_status dc_process_hdcp_msg(
1379                 enum signal_type signal,
1380                 struct dc_link *link,
1381                 struct hdcp_protection_message *message_info);
1382 #endif
1383 bool dc_is_dmcu_initialized(struct dc *dc);
1384
1385 enum dc_status dc_set_clock(struct dc *dc, enum dc_clock_type clock_type, uint32_t clk_khz, uint32_t stepping);
1386 void dc_get_clock(struct dc *dc, enum dc_clock_type clock_type, struct dc_clock_config *clock_cfg);
1387 #if defined(CONFIG_DRM_AMD_DC_DCN)
1388
1389 bool dc_is_plane_eligible_for_idle_optimizations(struct dc *dc, struct dc_plane_state *plane,
1390                                 struct dc_cursor_attributes *cursor_attr);
1391
1392 void dc_allow_idle_optimizations(struct dc *dc, bool allow);
1393
1394 /*
1395  * blank all streams, and set min and max memory clock to
1396  * lowest and highest DPM level, respectively
1397  */
1398 void dc_unlock_memory_clock_frequency(struct dc *dc);
1399
1400 /*
1401  * set min memory clock to the min required for current mode,
1402  * max to maxDPM, and unblank streams
1403  */
1404 void dc_lock_memory_clock_frequency(struct dc *dc);
1405
1406 /* cleanup on driver unload */
1407 void dc_hardware_release(struct dc *dc);
1408
1409 #endif
1410
1411 bool dc_set_psr_allow_active(struct dc *dc, bool enable);
1412 #if defined(CONFIG_DRM_AMD_DC_DCN)
1413 void dc_z10_restore(const struct dc *dc);
1414 void dc_z10_save_init(struct dc *dc);
1415 #endif
1416
1417 bool dc_enable_dmub_notifications(struct dc *dc);
1418
1419 bool dc_process_dmub_aux_transfer_async(struct dc *dc,
1420                                 uint32_t link_index,
1421                                 struct aux_payload *payload);
1422
1423 /* Get dc link index from dpia port index */
1424 uint8_t get_link_index_from_dpia_port_index(const struct dc *dc,
1425                                 uint8_t dpia_port_index);
1426
1427 bool dc_process_dmub_set_config_async(struct dc *dc,
1428                                 uint32_t link_index,
1429                                 struct set_config_cmd_payload *payload,
1430                                 struct dmub_notification *notify);
1431
1432 enum dc_status dc_process_dmub_set_mst_slots(const struct dc *dc,
1433                                 uint32_t link_index,
1434                                 uint8_t mst_alloc_slots,
1435                                 uint8_t *mst_slots_in_use);
1436
1437 /*******************************************************************************
1438  * DSC Interfaces
1439  ******************************************************************************/
1440 #include "dc_dsc.h"
1441
1442 /*******************************************************************************
1443  * Disable acc mode Interfaces
1444  ******************************************************************************/
1445 void dc_disable_accelerated_mode(struct dc *dc);
1446
1447 #endif /* DC_INTERFACE_H_ */