2 * Copyright 2015 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #ifndef _CORE_TYPES_H_
27 #define _CORE_TYPES_H_
30 #include "dce_calcs.h"
31 #include "dcn_calcs.h"
32 #include "ddc_service_types.h"
33 #include "dc_bios_types.h"
34 #include "mem_input.h"
39 #include "panel_cntl.h"
41 #define MAX_CLOCK_SOURCES 7
43 void enable_surface_flip_reporting(struct dc_plane_state *plane_state,
44 uint32_t controller_id);
46 #include "grph_object_id.h"
47 #include "link_encoder.h"
48 #include "stream_encoder.h"
49 #include "clock_source.h"
51 #include "dm_pp_smu.h"
52 #ifdef CONFIG_DRM_AMD_DC_HDCP
53 #include "dm_cp_psp.h"
55 #include "link_hwss.h"
57 /************ link *****************/
58 struct link_init_data {
60 struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */
61 uint32_t connector_index; /* this will be mapped to the HPD pins */
62 uint32_t link_index; /* this is mapped to DAL display_index
63 TODO: remove it when DC is complete. */
67 struct dc_link *link_create(const struct link_init_data *init_params);
68 void link_destroy(struct dc_link **link);
70 enum dc_status dc_link_validate_mode_timing(
71 const struct dc_stream_state *stream,
73 const struct dc_crtc_timing *timing);
75 void core_link_resume(struct dc_link *link);
77 void core_link_enable_stream(
78 struct dc_state *state,
79 struct pipe_ctx *pipe_ctx);
81 void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
83 void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable);
84 /********** DAL Core*********************/
85 #include "transform.h"
90 struct resource_context;
93 struct resource_funcs {
94 void (*destroy)(struct resource_pool **pool);
95 void (*link_init)(struct dc_link *link);
96 struct panel_cntl*(*panel_cntl_create)(
97 const struct panel_cntl_init_data *panel_cntl_init_data);
98 struct link_encoder *(*link_enc_create)(
99 const struct encoder_init_data *init);
100 /* Create a minimal link encoder object with no dc_link object
101 * associated with it. */
102 struct link_encoder *(*link_enc_create_minimal)(struct dc_context *ctx, enum engine_id eng_id);
104 bool (*validate_bandwidth)(
106 struct dc_state *context,
108 void (*calculate_wm_and_dlg)(
109 struct dc *dc, struct dc_state *context,
110 display_e2e_pipe_params_st *pipes,
113 void (*update_soc_for_wm_a)(
114 struct dc *dc, struct dc_state *context);
115 int (*populate_dml_pipes)(
117 struct dc_state *context,
118 display_e2e_pipe_params_st *pipes,
122 * Algorithm for assigning available link encoders to links.
124 * Update link_enc_assignments table and link_enc_avail list accordingly in
125 * struct resource_context.
127 void (*link_encs_assign)(
129 struct dc_state *state,
130 struct dc_stream_state *streams[],
131 uint8_t stream_count);
133 * Unassign a link encoder from a stream.
135 * Update link_enc_assignments table and link_enc_avail list accordingly in
136 * struct resource_context.
138 void (*link_enc_unassign)(
139 struct dc_state *state,
140 struct dc_stream_state *stream);
142 enum dc_status (*validate_global)(
144 struct dc_state *context);
146 struct pipe_ctx *(*acquire_idle_pipe_for_layer)(
147 struct dc_state *context,
148 const struct resource_pool *pool,
149 struct dc_stream_state *stream);
151 enum dc_status (*validate_plane)(const struct dc_plane_state *plane_state, struct dc_caps *caps);
153 enum dc_status (*add_stream_to_ctx)(
155 struct dc_state *new_ctx,
156 struct dc_stream_state *dc_stream);
158 enum dc_status (*remove_stream_from_ctx)(
160 struct dc_state *new_ctx,
161 struct dc_stream_state *stream);
162 enum dc_status (*patch_unknown_plane_state)(
163 struct dc_plane_state *plane_state);
165 struct stream_encoder *(*find_first_free_match_stream_enc_for_link)(
166 struct resource_context *res_ctx,
167 const struct resource_pool *pool,
168 struct dc_stream_state *stream);
169 void (*populate_dml_writeback_from_context)(
171 struct resource_context *res_ctx,
172 display_e2e_pipe_params_st *pipes);
174 void (*set_mcif_arb_params)(
176 struct dc_state *context,
177 display_e2e_pipe_params_st *pipes,
179 void (*update_bw_bounding_box)(
181 struct clk_bw_params *bw_params);
182 bool (*acquire_post_bldn_3dlut)(
183 struct resource_context *res_ctx,
184 const struct resource_pool *pool,
186 struct dc_3dlut **lut,
187 struct dc_transfer_func **shaper);
189 bool (*release_post_bldn_3dlut)(
190 struct resource_context *res_ctx,
191 const struct resource_pool *pool,
192 struct dc_3dlut **lut,
193 struct dc_transfer_func **shaper);
195 enum dc_status (*add_dsc_to_stream_resource)(
196 struct dc *dc, struct dc_state *state,
197 struct dc_stream_state *stream);
199 void (*add_phantom_pipes)(
201 struct dc_state *context,
202 display_e2e_pipe_params_st *pipes,
203 unsigned int pipe_cnt,
205 void (*remove_phantom_pipes)(
207 struct dc_state *context);
210 struct audio_support{
212 bool hdmi_audio_on_dongle;
213 bool hdmi_audio_native;
216 #define NO_UNDERLAY_PIPE -1
218 struct resource_pool {
219 struct mem_input *mis[MAX_PIPES];
220 struct hubp *hubps[MAX_PIPES];
221 struct input_pixel_processor *ipps[MAX_PIPES];
222 struct transform *transforms[MAX_PIPES];
223 struct dpp *dpps[MAX_PIPES];
224 struct output_pixel_processor *opps[MAX_PIPES];
225 struct timing_generator *timing_generators[MAX_PIPES];
226 struct stream_encoder *stream_enc[MAX_PIPES * 2];
227 struct hubbub *hubbub;
229 struct pp_smu_funcs *pp_smu;
230 struct dce_aux *engines[MAX_PIPES];
231 struct dce_i2c_hw *hw_i2cs[MAX_PIPES];
232 struct dce_i2c_sw *sw_i2cs[MAX_PIPES];
233 bool i2c_hw_buffer_in_use;
235 struct dwbc *dwbc[MAX_DWB_PIPES];
236 struct mcif_wb *mcif_wb[MAX_DWB_PIPES];
238 unsigned int gsl_0:1;
239 unsigned int gsl_1:1;
240 unsigned int gsl_2:1;
243 struct display_stream_compressor *dscs[MAX_PIPES];
245 unsigned int pipe_count;
246 unsigned int underlay_pipe_index;
247 unsigned int stream_enc_count;
249 /* An array for accessing the link encoder objects that have been created.
250 * Index in array corresponds to engine ID - viz. 0: ENGINE_ID_DIGA
252 struct link_encoder *link_encoders[MAX_DIG_LINK_ENCODERS];
253 /* Number of DIG link encoder objects created - i.e. number of valid
254 * entries in link_encoders array.
256 unsigned int dig_link_enc_count;
257 /* Number of USB4 DPIA (DisplayPort Input Adapter) link objects created.*/
258 unsigned int usb4_dpia_count;
260 unsigned int hpo_dp_stream_enc_count;
261 struct hpo_dp_stream_encoder *hpo_dp_stream_enc[MAX_HPO_DP2_ENCODERS];
262 unsigned int hpo_dp_link_enc_count;
263 struct hpo_dp_link_encoder *hpo_dp_link_enc[MAX_HPO_DP2_LINK_ENCODERS];
264 struct dc_3dlut *mpc_lut[MAX_PIPES];
265 struct dc_transfer_func *mpc_shaper[MAX_PIPES];
268 unsigned int xtalin_clock_inKhz;
269 unsigned int dccg_ref_clock_inKhz;
270 unsigned int dchub_ref_clock_inKhz;
272 unsigned int timing_generator_count;
273 unsigned int mpcc_count;
275 unsigned int writeback_pipe_count;
277 * reserved clock source for DP
279 struct clock_source *dp_clock_source;
281 struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
282 unsigned int clk_src_count;
284 struct audio *audios[MAX_AUDIOS];
285 unsigned int audio_count;
286 struct audio_support audio_support;
289 struct irq_service *irqs;
293 struct dmub_psr *psr;
295 struct abm *multiple_abms[MAX_PIPES];
297 const struct resource_funcs *funcs;
298 const struct resource_caps *res_cap;
300 struct ddc_service *oem_device;
303 struct dcn_fe_bandwidth {
308 struct stream_resource {
309 struct output_pixel_processor *opp;
310 struct display_stream_compressor *dsc;
311 struct timing_generator *tg;
312 struct stream_encoder *stream_enc;
313 struct hpo_dp_stream_encoder *hpo_dp_stream_enc;
316 struct pixel_clk_params pix_clk_params;
317 struct encoder_info_frame encoder_info_frame;
320 /* There are only (num_pipes+1)/2 groups. 0 means unassigned,
321 * otherwise it's using group number 'gsl_group-1'
326 struct plane_resource {
327 struct scaler_data scl_data;
329 struct mem_input *mi;
330 struct input_pixel_processor *ipp;
331 struct transform *xfm;
335 struct dcn_fe_bandwidth bw;
338 #define LINK_RES_HPO_DP_REC_MAP__MASK 0xFFFF
339 #define LINK_RES_HPO_DP_REC_MAP__SHIFT 0
341 /* all mappable hardware resources used to enable a link */
342 struct link_resource {
343 struct hpo_dp_link_encoder *hpo_dp_link_enc;
346 union pipe_update_flags {
349 uint32_t disable : 1;
351 uint32_t global_sync : 1;
352 uint32_t opp_changed : 1;
353 uint32_t tg_changed : 1;
356 uint32_t hubp_interdependent : 1;
357 uint32_t hubp_rq_dlg_ttu : 1;
358 uint32_t gamut_remap : 1;
360 uint32_t viewport : 1;
361 uint32_t plane_changed : 1;
362 uint32_t det_size : 1;
368 struct dc_plane_state *plane_state;
369 struct dc_stream_state *stream;
371 struct plane_resource plane_res;
372 struct stream_resource stream_res;
373 struct link_resource link_res;
375 struct clock_source *clock_source;
377 struct pll_settings pll_settings;
380 uint8_t pipe_idx_syncd;
382 struct pipe_ctx *top_pipe;
383 struct pipe_ctx *bottom_pipe;
384 struct pipe_ctx *next_odm_pipe;
385 struct pipe_ctx *prev_odm_pipe;
387 struct _vcs_dpi_display_dlg_regs_st dlg_regs;
388 struct _vcs_dpi_display_ttu_regs_st ttu_regs;
389 struct _vcs_dpi_display_rq_regs_st rq_regs;
390 struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param;
391 struct _vcs_dpi_display_rq_params_st dml_rq_param;
392 struct _vcs_dpi_display_dlg_sys_params_st dml_dlg_sys_param;
393 struct _vcs_dpi_display_e2e_pipe_params_st dml_input;
394 int det_buffer_size_kb;
397 union pipe_update_flags update_flags;
399 struct mcif_wb *mcif_wb;
403 /* Data used for dynamic link encoder assignment.
404 * Tracks current and future assignments; available link encoders;
405 * and mode of operation (whether to use current or future assignments).
407 struct link_enc_cfg_context {
408 enum link_enc_cfg_mode mode;
409 struct link_enc_assignment link_enc_assignments[MAX_PIPES];
410 enum engine_id link_enc_avail[MAX_DIG_LINK_ENCODERS];
411 struct link_enc_assignment transient_assignments[MAX_PIPES];
414 struct resource_context {
415 struct pipe_ctx pipe_ctx[MAX_PIPES];
416 bool is_stream_enc_acquired[MAX_PIPES * 2];
417 bool is_audio_acquired[MAX_PIPES];
418 uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES];
419 uint8_t dp_clock_source_ref_count;
420 bool is_dsc_acquired[MAX_PIPES];
421 struct link_enc_cfg_context link_enc_cfg_ctx;
422 bool is_hpo_dp_stream_enc_acquired[MAX_HPO_DP2_ENCODERS];
423 unsigned int hpo_dp_link_enc_to_link_idx[MAX_HPO_DP2_LINK_ENCODERS];
424 int hpo_dp_link_enc_ref_cnts[MAX_HPO_DP2_LINK_ENCODERS];
425 bool is_mpc_3dlut_acquired[MAX_PIPES];
428 struct dce_bw_output {
429 bool cpuc_state_change_enable;
430 bool cpup_state_change_enable;
431 bool stutter_mode_enable;
432 bool nbp_state_change_enable;
433 bool all_displays_in_sync;
434 struct dce_watermarks urgent_wm_ns[MAX_PIPES];
435 struct dce_watermarks stutter_exit_wm_ns[MAX_PIPES];
436 struct dce_watermarks stutter_entry_wm_ns[MAX_PIPES];
437 struct dce_watermarks nbp_state_change_wm_ns[MAX_PIPES];
439 int sclk_deep_sleep_khz;
442 int blackout_recovery_time_us;
445 struct dcn_bw_writeback {
446 struct mcif_arb_params mcif_wb_arb[MAX_DWB_PIPES];
449 struct dcn_bw_output {
450 struct dc_clocks clk;
451 struct dcn_watermark_set watermarks;
452 struct dcn_bw_writeback bw_writeback;
457 struct dcn_bw_output dcn;
458 struct dce_bw_output dce;
463 struct display_mode_lib dml;
466 * struct dc_state - The full description of a state requested by a user
468 * @streams: Stream properties
469 * @stream_status: The planes on a given stream
470 * @res_ctx: Persistent state of resources
471 * @bw_ctx: The output from bandwidth and watermark calculations and the DML
472 * @pp_display_cfg: PowerPlay clocks and settings
473 * @dcn_bw_vars: non-stack memory to support bandwidth calculations
477 struct dc_stream_state *streams[MAX_PIPES];
478 struct dc_stream_status stream_status[MAX_PIPES];
479 uint8_t stream_count;
482 struct resource_context res_ctx;
484 struct bw_context bw_ctx;
486 /* Note: these are big structures, do *not* put on stack! */
487 struct dm_pp_display_configuration pp_display_cfg;
488 struct dcn_bw_internal_vars dcn_bw_vars;
490 struct clk_mgr *clk_mgr;
492 struct kref refcount;
495 unsigned int stutter_period_us;
499 struct dc_bounding_box_max_clk {
506 #endif /* _CORE_TYPES_H_ */