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"
36 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
39 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
44 #define MAX_CLOCK_SOURCES 7
46 void enable_surface_flip_reporting(struct dc_plane_state *plane_state,
47 uint32_t controller_id);
49 #include "grph_object_id.h"
50 #include "link_encoder.h"
51 #include "stream_encoder.h"
52 #include "clock_source.h"
54 #include "dm_pp_smu.h"
55 #ifdef CONFIG_DRM_AMD_DC_HDCP
56 #include "dm_cp_psp.h"
59 /************ link *****************/
60 struct link_init_data {
62 struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */
63 uint32_t connector_index; /* this will be mapped to the HPD pins */
64 uint32_t link_index; /* this is mapped to DAL display_index
65 TODO: remove it when DC is complete. */
68 struct dc_link *link_create(const struct link_init_data *init_params);
69 void link_destroy(struct dc_link **link);
71 enum dc_status dc_link_validate_mode_timing(
72 const struct dc_stream_state *stream,
74 const struct dc_crtc_timing *timing);
76 void core_link_resume(struct dc_link *link);
78 void core_link_enable_stream(
79 struct dc_state *state,
80 struct pipe_ctx *pipe_ctx);
82 void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
84 void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable);
85 /********** DAL Core*********************/
86 #include "transform.h"
91 struct resource_context;
92 #if defined(CONFIG_DRM_AMD_DC_DCN2_1)
96 struct resource_funcs {
97 void (*destroy)(struct resource_pool **pool);
98 void (*link_init)(struct dc_link *link);
99 struct link_encoder *(*link_enc_create)(
100 const struct encoder_init_data *init);
101 bool (*validate_bandwidth)(
103 struct dc_state *context,
106 int (*populate_dml_pipes)(
108 struct resource_context *res_ctx,
109 display_e2e_pipe_params_st *pipes);
111 enum dc_status (*validate_global)(
113 struct dc_state *context);
115 struct pipe_ctx *(*acquire_idle_pipe_for_layer)(
116 struct dc_state *context,
117 const struct resource_pool *pool,
118 struct dc_stream_state *stream);
120 enum dc_status (*validate_plane)(const struct dc_plane_state *plane_state, struct dc_caps *caps);
122 enum dc_status (*add_stream_to_ctx)(
124 struct dc_state *new_ctx,
125 struct dc_stream_state *dc_stream);
127 enum dc_status (*remove_stream_from_ctx)(
129 struct dc_state *new_ctx,
130 struct dc_stream_state *stream);
131 enum dc_status (*get_default_swizzle_mode)(
132 struct dc_plane_state *plane_state);
134 struct stream_encoder *(*find_first_free_match_stream_enc_for_link)(
135 struct resource_context *res_ctx,
136 const struct resource_pool *pool,
137 struct dc_stream_state *stream);
138 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
139 void (*populate_dml_writeback_from_context)(
141 struct resource_context *res_ctx,
142 display_e2e_pipe_params_st *pipes);
144 void (*set_mcif_arb_params)(
146 struct dc_state *context,
147 display_e2e_pipe_params_st *pipes,
150 #if defined(CONFIG_DRM_AMD_DC_DCN2_1)
151 void (*update_bw_bounding_box)(
153 struct clk_bw_params *bw_params);
158 struct audio_support{
160 bool hdmi_audio_on_dongle;
161 bool hdmi_audio_native;
164 #define NO_UNDERLAY_PIPE -1
166 struct resource_pool {
167 struct mem_input *mis[MAX_PIPES];
168 struct hubp *hubps[MAX_PIPES];
169 struct input_pixel_processor *ipps[MAX_PIPES];
170 struct transform *transforms[MAX_PIPES];
171 struct dpp *dpps[MAX_PIPES];
172 struct output_pixel_processor *opps[MAX_PIPES];
173 struct timing_generator *timing_generators[MAX_PIPES];
174 struct stream_encoder *stream_enc[MAX_PIPES * 2];
175 struct hubbub *hubbub;
177 struct pp_smu_funcs *pp_smu;
178 struct dce_aux *engines[MAX_PIPES];
179 struct dce_i2c_hw *hw_i2cs[MAX_PIPES];
180 struct dce_i2c_sw *sw_i2cs[MAX_PIPES];
181 bool i2c_hw_buffer_in_use;
183 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
184 struct dwbc *dwbc[MAX_DWB_PIPES];
185 struct mcif_wb *mcif_wb[MAX_DWB_PIPES];
187 unsigned int gsl_0:1;
188 unsigned int gsl_1:1;
189 unsigned int gsl_2:1;
193 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
194 struct display_stream_compressor *dscs[MAX_PIPES];
197 unsigned int pipe_count;
198 unsigned int underlay_pipe_index;
199 unsigned int stream_enc_count;
202 unsigned int xtalin_clock_inKhz;
203 unsigned int dccg_ref_clock_inKhz;
204 unsigned int dchub_ref_clock_inKhz;
206 unsigned int timing_generator_count;
207 unsigned int mpcc_count;
209 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
210 unsigned int writeback_pipe_count;
213 * reserved clock source for DP
215 struct clock_source *dp_clock_source;
217 struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
218 unsigned int clk_src_count;
220 struct audio *audios[MAX_AUDIOS];
221 unsigned int audio_count;
222 struct audio_support audio_support;
225 struct irq_service *irqs;
230 const struct resource_funcs *funcs;
231 const struct resource_caps *res_cap;
233 struct ddc_service *oem_device;
236 struct dcn_fe_bandwidth {
241 struct stream_resource {
242 struct output_pixel_processor *opp;
243 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
244 struct display_stream_compressor *dsc;
246 struct timing_generator *tg;
247 struct stream_encoder *stream_enc;
250 struct pixel_clk_params pix_clk_params;
251 struct encoder_info_frame encoder_info_frame;
254 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
255 /* There are only (num_pipes+1)/2 groups. 0 means unassigned,
256 * otherwise it's using group number 'gsl_group-1'
262 struct plane_resource {
263 struct scaler_data scl_data;
265 struct mem_input *mi;
266 struct input_pixel_processor *ipp;
267 struct transform *xfm;
271 struct dcn_fe_bandwidth bw;
274 union pipe_update_flags {
277 uint32_t disable : 1;
279 uint32_t global_sync : 1;
280 uint32_t opp_changed : 1;
281 uint32_t tg_changed : 1;
284 uint32_t hubp_interdependent : 1;
285 uint32_t hubp_rq_dlg_ttu : 1;
286 uint32_t gamut_remap : 1;
288 uint32_t viewport : 1;
294 struct dc_plane_state *plane_state;
295 struct dc_stream_state *stream;
297 struct plane_resource plane_res;
298 struct stream_resource stream_res;
300 struct clock_source *clock_source;
302 struct pll_settings pll_settings;
306 struct pipe_ctx *top_pipe;
307 struct pipe_ctx *bottom_pipe;
308 struct pipe_ctx *next_odm_pipe;
309 struct pipe_ctx *prev_odm_pipe;
311 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
312 struct _vcs_dpi_display_dlg_regs_st dlg_regs;
313 struct _vcs_dpi_display_ttu_regs_st ttu_regs;
314 struct _vcs_dpi_display_rq_regs_st rq_regs;
315 struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param;
317 union pipe_update_flags update_flags;
318 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
320 struct mcif_wb *mcif_wb;
324 struct resource_context {
325 struct pipe_ctx pipe_ctx[MAX_PIPES];
326 bool is_stream_enc_acquired[MAX_PIPES * 2];
327 bool is_audio_acquired[MAX_PIPES];
328 uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES];
329 uint8_t dp_clock_source_ref_count;
330 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
331 bool is_dsc_acquired[MAX_PIPES];
335 struct dce_bw_output {
336 bool cpuc_state_change_enable;
337 bool cpup_state_change_enable;
338 bool stutter_mode_enable;
339 bool nbp_state_change_enable;
340 bool all_displays_in_sync;
341 struct dce_watermarks urgent_wm_ns[MAX_PIPES];
342 struct dce_watermarks stutter_exit_wm_ns[MAX_PIPES];
343 struct dce_watermarks stutter_entry_wm_ns[MAX_PIPES];
344 struct dce_watermarks nbp_state_change_wm_ns[MAX_PIPES];
346 int sclk_deep_sleep_khz;
349 int blackout_recovery_time_us;
352 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
353 struct dcn_bw_writeback {
354 struct mcif_arb_params mcif_wb_arb[MAX_DWB_PIPES];
358 struct dcn_bw_output {
359 struct dc_clocks clk;
360 struct dcn_watermark_set watermarks;
361 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
362 struct dcn_bw_writeback bw_writeback;
367 struct dcn_bw_output dcn;
368 struct dce_bw_output dce;
373 struct display_mode_lib dml;
376 * struct dc_state - The full description of a state requested by a user
378 * @streams: Stream properties
379 * @stream_status: The planes on a given stream
380 * @res_ctx: Persistent state of resources
381 * @bw_ctx: The output from bandwidth and watermark calculations and the DML
382 * @pp_display_cfg: PowerPlay clocks and settings
383 * @dcn_bw_vars: non-stack memory to support bandwidth calculations
387 struct dc_stream_state *streams[MAX_PIPES];
388 struct dc_stream_status stream_status[MAX_PIPES];
389 uint8_t stream_count;
391 struct resource_context res_ctx;
393 struct bw_context bw_ctx;
395 /* Note: these are big structures, do *not* put on stack! */
396 struct dm_pp_display_configuration pp_display_cfg;
397 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
398 struct dcn_bw_internal_vars dcn_bw_vars;
401 struct clk_mgr *clk_mgr;
403 struct kref refcount;
406 #endif /* _CORE_TYPES_H_ */