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_DCN)
41 #include "panel_cntl.h"
43 #define MAX_CLOCK_SOURCES 7
45 void enable_surface_flip_reporting(struct dc_plane_state *plane_state,
46 uint32_t controller_id);
48 #include "grph_object_id.h"
49 #include "link_encoder.h"
50 #include "stream_encoder.h"
51 #include "clock_source.h"
53 #include "dm_pp_smu.h"
54 #ifdef CONFIG_DRM_AMD_DC_HDCP
55 #include "dm_cp_psp.h"
58 /************ link *****************/
59 struct link_init_data {
61 struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */
62 uint32_t connector_index; /* this will be mapped to the HPD pins */
63 uint32_t link_index; /* this is mapped to DAL display_index
64 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,
121 enum dc_status (*validate_global)(
123 struct dc_state *context);
125 struct pipe_ctx *(*acquire_idle_pipe_for_layer)(
126 struct dc_state *context,
127 const struct resource_pool *pool,
128 struct dc_stream_state *stream);
130 enum dc_status (*validate_plane)(const struct dc_plane_state *plane_state, struct dc_caps *caps);
132 enum dc_status (*add_stream_to_ctx)(
134 struct dc_state *new_ctx,
135 struct dc_stream_state *dc_stream);
137 enum dc_status (*remove_stream_from_ctx)(
139 struct dc_state *new_ctx,
140 struct dc_stream_state *stream);
141 enum dc_status (*patch_unknown_plane_state)(
142 struct dc_plane_state *plane_state);
144 struct stream_encoder *(*find_first_free_match_stream_enc_for_link)(
145 struct resource_context *res_ctx,
146 const struct resource_pool *pool,
147 struct dc_stream_state *stream);
148 void (*populate_dml_writeback_from_context)(
150 struct resource_context *res_ctx,
151 display_e2e_pipe_params_st *pipes);
153 void (*set_mcif_arb_params)(
155 struct dc_state *context,
156 display_e2e_pipe_params_st *pipes,
158 void (*update_bw_bounding_box)(
160 struct clk_bw_params *bw_params);
161 #if defined(CONFIG_DRM_AMD_DC_DCN)
162 bool (*acquire_post_bldn_3dlut)(
163 struct resource_context *res_ctx,
164 const struct resource_pool *pool,
166 struct dc_3dlut **lut,
167 struct dc_transfer_func **shaper);
169 bool (*release_post_bldn_3dlut)(
170 struct resource_context *res_ctx,
171 const struct resource_pool *pool,
172 struct dc_3dlut **lut,
173 struct dc_transfer_func **shaper);
175 enum dc_status (*add_dsc_to_stream_resource)(
176 struct dc *dc, struct dc_state *state,
177 struct dc_stream_state *stream);
180 struct audio_support{
182 bool hdmi_audio_on_dongle;
183 bool hdmi_audio_native;
186 #define NO_UNDERLAY_PIPE -1
188 struct resource_pool {
189 struct mem_input *mis[MAX_PIPES];
190 struct hubp *hubps[MAX_PIPES];
191 struct input_pixel_processor *ipps[MAX_PIPES];
192 struct transform *transforms[MAX_PIPES];
193 struct dpp *dpps[MAX_PIPES];
194 struct output_pixel_processor *opps[MAX_PIPES];
195 struct timing_generator *timing_generators[MAX_PIPES];
196 struct stream_encoder *stream_enc[MAX_PIPES * 2];
197 struct hubbub *hubbub;
199 struct pp_smu_funcs *pp_smu;
200 struct dce_aux *engines[MAX_PIPES];
201 struct dce_i2c_hw *hw_i2cs[MAX_PIPES];
202 struct dce_i2c_sw *sw_i2cs[MAX_PIPES];
203 bool i2c_hw_buffer_in_use;
205 struct dwbc *dwbc[MAX_DWB_PIPES];
206 struct mcif_wb *mcif_wb[MAX_DWB_PIPES];
208 unsigned int gsl_0:1;
209 unsigned int gsl_1:1;
210 unsigned int gsl_2:1;
213 struct display_stream_compressor *dscs[MAX_PIPES];
215 unsigned int pipe_count;
216 unsigned int underlay_pipe_index;
217 unsigned int stream_enc_count;
219 /* An array for accessing the link encoder objects that have been created.
220 * Index in array corresponds to engine ID - viz. 0: ENGINE_ID_DIGA
222 struct link_encoder *link_encoders[MAX_DIG_LINK_ENCODERS];
223 /* Number of DIG link encoder objects created - i.e. number of valid
224 * entries in link_encoders array.
226 unsigned int dig_link_enc_count;
228 #if defined(CONFIG_DRM_AMD_DC_DCN)
229 struct dc_3dlut *mpc_lut[MAX_PIPES];
230 struct dc_transfer_func *mpc_shaper[MAX_PIPES];
233 unsigned int xtalin_clock_inKhz;
234 unsigned int dccg_ref_clock_inKhz;
235 unsigned int dchub_ref_clock_inKhz;
237 unsigned int timing_generator_count;
238 unsigned int mpcc_count;
240 unsigned int writeback_pipe_count;
242 * reserved clock source for DP
244 struct clock_source *dp_clock_source;
246 struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
247 unsigned int clk_src_count;
249 struct audio *audios[MAX_AUDIOS];
250 unsigned int audio_count;
251 struct audio_support audio_support;
254 struct irq_service *irqs;
258 struct dmub_psr *psr;
260 #if defined(CONFIG_DRM_AMD_DC_DCN)
261 struct abm *multiple_abms[MAX_PIPES];
264 const struct resource_funcs *funcs;
265 const struct resource_caps *res_cap;
267 struct ddc_service *oem_device;
270 struct dcn_fe_bandwidth {
275 struct stream_resource {
276 struct output_pixel_processor *opp;
277 struct display_stream_compressor *dsc;
278 struct timing_generator *tg;
279 struct stream_encoder *stream_enc;
282 struct pixel_clk_params pix_clk_params;
283 struct encoder_info_frame encoder_info_frame;
286 /* There are only (num_pipes+1)/2 groups. 0 means unassigned,
287 * otherwise it's using group number 'gsl_group-1'
292 struct plane_resource {
293 struct scaler_data scl_data;
295 struct mem_input *mi;
296 struct input_pixel_processor *ipp;
297 struct transform *xfm;
301 struct dcn_fe_bandwidth bw;
304 union pipe_update_flags {
307 uint32_t disable : 1;
309 uint32_t global_sync : 1;
310 uint32_t opp_changed : 1;
311 uint32_t tg_changed : 1;
314 uint32_t hubp_interdependent : 1;
315 uint32_t hubp_rq_dlg_ttu : 1;
316 uint32_t gamut_remap : 1;
318 uint32_t viewport : 1;
319 uint32_t plane_changed : 1;
325 struct dc_plane_state *plane_state;
326 struct dc_stream_state *stream;
328 struct plane_resource plane_res;
329 struct stream_resource stream_res;
331 struct clock_source *clock_source;
333 struct pll_settings pll_settings;
337 struct pipe_ctx *top_pipe;
338 struct pipe_ctx *bottom_pipe;
339 struct pipe_ctx *next_odm_pipe;
340 struct pipe_ctx *prev_odm_pipe;
342 #ifdef CONFIG_DRM_AMD_DC_DCN
343 struct _vcs_dpi_display_dlg_regs_st dlg_regs;
344 struct _vcs_dpi_display_ttu_regs_st ttu_regs;
345 struct _vcs_dpi_display_rq_regs_st rq_regs;
346 struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param;
348 union pipe_update_flags update_flags;
350 struct mcif_wb *mcif_wb;
354 struct resource_context {
355 struct pipe_ctx pipe_ctx[MAX_PIPES];
356 bool is_stream_enc_acquired[MAX_PIPES * 2];
357 bool is_audio_acquired[MAX_PIPES];
358 uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES];
359 uint8_t dp_clock_source_ref_count;
360 bool is_dsc_acquired[MAX_PIPES];
361 #if defined(CONFIG_DRM_AMD_DC_DCN)
362 bool is_mpc_3dlut_acquired[MAX_PIPES];
366 struct dce_bw_output {
367 bool cpuc_state_change_enable;
368 bool cpup_state_change_enable;
369 bool stutter_mode_enable;
370 bool nbp_state_change_enable;
371 bool all_displays_in_sync;
372 struct dce_watermarks urgent_wm_ns[MAX_PIPES];
373 struct dce_watermarks stutter_exit_wm_ns[MAX_PIPES];
374 struct dce_watermarks stutter_entry_wm_ns[MAX_PIPES];
375 struct dce_watermarks nbp_state_change_wm_ns[MAX_PIPES];
377 int sclk_deep_sleep_khz;
380 int blackout_recovery_time_us;
383 struct dcn_bw_writeback {
384 struct mcif_arb_params mcif_wb_arb[MAX_DWB_PIPES];
387 struct dcn_bw_output {
388 struct dc_clocks clk;
389 struct dcn_watermark_set watermarks;
390 struct dcn_bw_writeback bw_writeback;
394 struct dcn_bw_output dcn;
395 struct dce_bw_output dce;
400 struct display_mode_lib dml;
403 * struct dc_state - The full description of a state requested by a user
405 * @streams: Stream properties
406 * @stream_status: The planes on a given stream
407 * @res_ctx: Persistent state of resources
408 * @bw_ctx: The output from bandwidth and watermark calculations and the DML
409 * @pp_display_cfg: PowerPlay clocks and settings
410 * @dcn_bw_vars: non-stack memory to support bandwidth calculations
414 struct dc_stream_state *streams[MAX_PIPES];
415 struct dc_stream_status stream_status[MAX_PIPES];
416 uint8_t stream_count;
419 struct resource_context res_ctx;
421 struct bw_context bw_ctx;
423 /* Note: these are big structures, do *not* put on stack! */
424 struct dm_pp_display_configuration pp_display_cfg;
425 #ifdef CONFIG_DRM_AMD_DC_DCN
426 struct dcn_bw_internal_vars dcn_bw_vars;
429 struct clk_mgr *clk_mgr;
431 struct kref refcount;
434 unsigned int stutter_period_us;
438 #endif /* _CORE_TYPES_H_ */