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"
35 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
41 #define MAX_CLOCK_SOURCES 7
43 /********* core_surface **********/
44 #define DC_SURFACE_TO_CORE(dc_surface) \
45 container_of(dc_surface, struct core_surface, public)
47 #define DC_GAMMA_TO_CORE(dc_gamma) \
48 container_of(dc_gamma, struct core_gamma, public)
51 struct dc_surface public;
52 struct dc_surface_status status;
53 struct dc_context *ctx;
55 /* private to dc_surface.c */
56 enum dc_irq_source irq_source;
61 struct dc_gamma public;
62 struct dc_context *ctx;
65 void enable_surface_flip_reporting(struct dc_surface *dc_surface,
66 uint32_t controller_id);
68 /********* core_stream ************/
69 #include "grph_object_id.h"
70 #include "link_encoder.h"
71 #include "stream_encoder.h"
72 #include "clock_source.h"
74 #include "hw_sequencer_types.h"
77 #define DC_STREAM_TO_CORE(dc_stream) container_of( \
78 dc_stream, struct core_stream, public)
81 struct dc_stream public;
83 /* field internal to DC */
84 struct dc_context *ctx;
85 const struct core_sink *sink;
87 /* used by DCP and FMT */
88 struct bit_depth_reduction_params bit_depth_params;
89 struct clamping_and_pixel_encoding_params clamping;
92 enum signal_type signal;
94 struct dc_stream_status status;
97 /************ core_sink *****************/
99 #define DC_SINK_TO_CORE(dc_sink) \
100 container_of(dc_sink, struct core_sink, public)
103 /** The public, read-only (for DM) area of sink. **/
104 struct dc_sink public;
105 /** End-of-public area. **/
107 /** The 'protected' area - read/write access, for use only inside DC **/
108 /* not used for now */
109 struct core_link *link;
110 struct dc_context *ctx;
113 /************ link *****************/
114 #define DC_LINK_TO_CORE(dc_link) container_of(dc_link, struct core_link, public)
116 struct link_init_data {
117 const struct core_dc *dc;
118 struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */
119 uint32_t connector_index; /* this will be mapped to the HPD pins */
120 uint32_t link_index; /* this is mapped to DAL display_index
121 TODO: remove it when DC is complete. */
124 /* DP MST stream allocation (payload bandwidth number) */
125 struct link_mst_stream_allocation {
127 const struct stream_encoder *stream_enc;
128 /* associate DRM payload table with DC stream encoder */
130 /* number of slots required for the DP stream in transport packet */
134 /* DP MST stream allocation table */
135 struct link_mst_stream_allocation_table {
136 /* number of DP video streams */
138 /* array of stream allocations */
139 struct link_mst_stream_allocation
140 stream_allocations[MAX_CONTROLLER_NUM];
144 struct dc_link public;
145 const struct core_dc *dc;
147 struct dc_context *ctx; /* TODO: AUTO remove 'dal' when DC is complete*/
149 struct link_encoder *link_enc;
150 struct graphics_object_id link_id;
151 union ddi_channel_mapping ddi_channel_mapping;
152 struct connector_device_tag_info device_tag;
153 struct dpcd_caps dpcd_caps;
154 unsigned int dpcd_sink_count;
156 enum edp_revision edp_revision;
159 /* MST record stream using this link */
161 bool dp_keep_receiver_powered;
163 struct link_mst_stream_allocation_table mst_stream_alloc_table;
165 struct dc_link_status link_status;
168 #define DC_LINK_TO_LINK(dc_link) container_of(dc_link, struct core_link, public)
170 struct core_link *link_create(const struct link_init_data *init_params);
171 void link_destroy(struct core_link **link);
173 enum dc_status dc_link_validate_mode_timing(
174 const struct core_stream *stream,
175 struct core_link *link,
176 const struct dc_crtc_timing *timing);
178 void core_link_resume(struct core_link *link);
180 void core_link_enable_stream(struct pipe_ctx *pipe_ctx);
182 void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
184 void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable);
185 /********** DAL Core*********************/
186 #include "display_clock.h"
187 #include "transform.h"
189 struct resource_pool;
190 struct validate_context;
191 struct resource_context;
193 struct resource_funcs {
194 void (*destroy)(struct resource_pool **pool);
195 struct link_encoder *(*link_enc_create)(
196 const struct encoder_init_data *init);
197 enum dc_status (*validate_with_context)(
198 const struct core_dc *dc,
199 const struct dc_validation_set set[],
201 struct validate_context *context,
202 struct validate_context *old_context);
204 enum dc_status (*validate_guaranteed)(
205 const struct core_dc *dc,
206 const struct dc_stream *stream,
207 struct validate_context *context);
209 bool (*validate_bandwidth)(
210 const struct core_dc *dc,
211 struct validate_context *context);
213 struct pipe_ctx *(*acquire_idle_pipe_for_layer)(
214 struct validate_context *context,
215 const struct resource_pool *pool,
216 struct core_stream *stream);
219 struct audio_support{
221 bool hdmi_audio_on_dongle;
222 bool hdmi_audio_native;
225 #define NO_UNDERLAY_PIPE -1
227 struct resource_pool {
228 struct mem_input *mis[MAX_PIPES];
229 struct input_pixel_processor *ipps[MAX_PIPES];
230 struct transform *transforms[MAX_PIPES];
231 struct output_pixel_processor *opps[MAX_PIPES];
232 struct timing_generator *timing_generators[MAX_PIPES];
233 struct stream_encoder *stream_enc[MAX_PIPES * 2];
234 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
235 struct mpcc *mpcc[MAX_PIPES];
238 unsigned int pipe_count;
239 unsigned int underlay_pipe_index;
240 unsigned int stream_enc_count;
241 unsigned int ref_clock_inKhz;
244 * reserved clock source for DP
246 struct clock_source *dp_clock_source;
248 struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
249 unsigned int clk_src_count;
251 struct audio *audios[MAX_PIPES];
252 unsigned int audio_count;
253 struct audio_support audio_support;
255 struct display_clock *display_clock;
256 struct irq_service *irqs;
261 const struct resource_funcs *funcs;
262 const struct resource_caps *res_cap;
266 struct core_surface *surface;
267 struct core_stream *stream;
269 struct mem_input *mi;
270 struct input_pixel_processor *ipp;
271 struct transform *xfm;
272 struct output_pixel_processor *opp;
273 struct timing_generator *tg;
275 struct scaler_data scl_data;
277 struct stream_encoder *stream_enc;
278 struct display_clock *dis_clk;
279 struct clock_source *clock_source;
283 struct pixel_clk_params pix_clk_params;
284 struct pll_settings pll_settings;
287 struct encoder_info_frame encoder_info_frame;
291 struct pipe_ctx *top_pipe;
292 struct pipe_ctx *bottom_pipe;
294 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
296 struct _vcs_dpi_display_dlg_regs_st dlg_regs;
297 struct _vcs_dpi_display_ttu_regs_st ttu_regs;
298 struct _vcs_dpi_display_rq_regs_st rq_regs;
299 struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param;
303 struct resource_context {
304 struct pipe_ctx pipe_ctx[MAX_PIPES];
305 bool is_stream_enc_acquired[MAX_PIPES * 2];
306 bool is_audio_acquired[MAX_PIPES];
307 uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES];
308 uint8_t dp_clock_source_ref_count;
311 struct dce_bw_output {
312 bool cpuc_state_change_enable;
313 bool cpup_state_change_enable;
314 bool stutter_mode_enable;
315 bool nbp_state_change_enable;
316 bool all_displays_in_sync;
317 struct dce_watermarks urgent_wm_ns[MAX_PIPES];
318 struct dce_watermarks stutter_exit_wm_ns[MAX_PIPES];
319 struct dce_watermarks nbp_state_change_wm_ns[MAX_PIPES];
321 int sclk_deep_sleep_khz;
324 int blackout_recovery_time_us;
327 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
328 struct dcn_bw_clocks {
332 int dcfclk_deep_sleep_khz;
335 int min_active_dram_ccm_us;
338 struct dcn_bw_output {
339 struct dcn_bw_clocks cur_clk;
340 struct dcn_bw_clocks calc_clk;
341 struct dcn_watermark_set watermarks;
346 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
347 struct dcn_bw_output dcn;
349 struct dce_bw_output dce;
352 struct validate_context {
353 struct core_stream *streams[MAX_PIPES];
354 struct dc_stream_status stream_status[MAX_PIPES];
355 uint8_t stream_count;
357 struct resource_context res_ctx;
359 /* The output from BW and WM calculations. */
362 /* Note: these are big structures, do *not* put on stack! */
363 struct dm_pp_display_configuration pp_display_cfg;
364 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
365 struct dcn_bw_internal_vars dcn_bw_vars;
371 #endif /* _CORE_TYPES_H_ */