drm/amd/display: add idle wait for passive surface update and modeset
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / display / dc / inc / core_types.h
1 /*
2  * Copyright 2015 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 _CORE_TYPES_H_
27 #define _CORE_TYPES_H_
28
29 #include "dc.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)
36 #include "mpc.h"
37 #endif
38
39 struct core_stream;
40
41 #define MAX_CLOCK_SOURCES 7
42
43 /********* core_surface **********/
44 #define DC_SURFACE_TO_CORE(dc_surface) \
45         container_of(dc_surface, struct core_surface, public)
46
47 #define DC_GAMMA_TO_CORE(dc_gamma) \
48         container_of(dc_gamma, struct core_gamma, public)
49
50 struct core_surface {
51         struct dc_surface public;
52         struct dc_surface_status status;
53         struct dc_context *ctx;
54
55         /* private to dc_surface.c */
56         enum dc_irq_source irq_source;
57         int ref_count;
58 };
59
60 struct core_gamma {
61         struct dc_gamma public;
62         struct dc_context *ctx;
63 };
64
65 void enable_surface_flip_reporting(struct dc_surface *dc_surface,
66                 uint32_t controller_id);
67
68 /********* core_stream ************/
69 #include "grph_object_id.h"
70 #include "link_encoder.h"
71 #include "stream_encoder.h"
72 #include "clock_source.h"
73 #include "audio.h"
74 #include "hw_sequencer_types.h"
75 #include "opp.h"
76
77 #define DC_STREAM_TO_CORE(dc_stream) container_of( \
78         dc_stream, struct core_stream, public)
79
80 struct core_stream {
81         struct dc_stream public;
82
83         /* field internal to DC */
84         struct dc_context *ctx;
85         const struct core_sink *sink;
86
87         /* used by DCP and FMT */
88         struct bit_depth_reduction_params bit_depth_params;
89         struct clamping_and_pixel_encoding_params clamping;
90
91         int phy_pix_clk;
92         enum signal_type signal;
93
94         struct dc_stream_status status;
95 };
96
97 /************ core_sink *****************/
98
99 #define DC_SINK_TO_CORE(dc_sink) \
100         container_of(dc_sink, struct core_sink, public)
101
102 struct core_sink {
103         /** The public, read-only (for DM) area of sink. **/
104         struct dc_sink public;
105         /** End-of-public area. **/
106
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;
111 };
112
113 /************ link *****************/
114 #define DC_LINK_TO_CORE(dc_link) container_of(dc_link, struct core_link, public)
115
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. */
122 };
123
124 /* DP MST stream allocation (payload bandwidth number) */
125 struct link_mst_stream_allocation {
126         /* DIG front */
127         const struct stream_encoder *stream_enc;
128         /* associate DRM payload table with DC stream encoder */
129         uint8_t vcp_id;
130         /* number of slots required for the DP stream in transport packet */
131         uint8_t slot_count;
132 };
133
134 /* DP MST stream allocation table */
135 struct link_mst_stream_allocation_table {
136         /* number of DP video streams */
137         int stream_count;
138         /* array of stream allocations */
139         struct link_mst_stream_allocation
140         stream_allocations[MAX_CONTROLLER_NUM];
141 };
142
143 struct core_link {
144         struct dc_link public;
145         const struct core_dc *dc;
146
147         struct dc_context *ctx; /* TODO: AUTO remove 'dal' when DC is complete*/
148
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;
155
156         enum edp_revision edp_revision;
157         bool psr_enabled;
158
159         /* MST record stream using this link */
160         struct link_flags {
161                 bool dp_keep_receiver_powered;
162         } wa_flags;
163         struct link_mst_stream_allocation_table mst_stream_alloc_table;
164
165         struct dc_link_status link_status;
166 };
167
168 #define DC_LINK_TO_LINK(dc_link) container_of(dc_link, struct core_link, public)
169
170 struct core_link *link_create(const struct link_init_data *init_params);
171 void link_destroy(struct core_link **link);
172
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);
177
178 void core_link_resume(struct core_link *link);
179
180 void core_link_enable_stream(struct pipe_ctx *pipe_ctx);
181
182 void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
183
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"
188
189 struct resource_pool;
190 struct validate_context;
191 struct resource_context;
192
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[],
200                                         int set_count,
201                                         struct validate_context *context,
202                                         struct validate_context *old_context);
203
204         enum dc_status (*validate_guaranteed)(
205                                         const struct core_dc *dc,
206                                         const struct dc_stream *stream,
207                                         struct validate_context *context);
208
209         bool (*validate_bandwidth)(
210                                         const struct core_dc *dc,
211                                         struct validate_context *context);
212
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);
217 };
218
219 struct audio_support{
220         bool dp_audio;
221         bool hdmi_audio_on_dongle;
222         bool hdmi_audio_native;
223 };
224
225 #define NO_UNDERLAY_PIPE -1
226
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];
236 #endif
237
238         unsigned int pipe_count;
239         unsigned int underlay_pipe_index;
240         unsigned int stream_enc_count;
241         unsigned int ref_clock_inKhz;
242
243         /*
244          * reserved clock source for DP
245          */
246         struct clock_source *dp_clock_source;
247
248         struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
249         unsigned int clk_src_count;
250
251         struct audio *audios[MAX_PIPES];
252         unsigned int audio_count;
253         struct audio_support audio_support;
254
255         struct display_clock *display_clock;
256         struct irq_service *irqs;
257
258         struct abm *abm;
259         struct dmcu *dmcu;
260
261         const struct resource_funcs *funcs;
262         const struct resource_caps *res_cap;
263 };
264
265 struct pipe_ctx {
266         struct core_surface *surface;
267         struct core_stream *stream;
268
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;
274
275         struct scaler_data scl_data;
276
277         struct stream_encoder *stream_enc;
278         struct display_clock *dis_clk;
279         struct clock_source *clock_source;
280
281         struct audio *audio;
282
283         struct pixel_clk_params pix_clk_params;
284         struct pll_settings pll_settings;
285
286         /*fmt*/
287         struct encoder_info_frame encoder_info_frame;
288
289         uint8_t pipe_idx;
290
291         struct pipe_ctx *top_pipe;
292         struct pipe_ctx *bottom_pipe;
293
294 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
295         struct mpcc *mpcc;
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;
300 #endif
301 };
302
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;
309 };
310
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];
320         int sclk_khz;
321         int sclk_deep_sleep_khz;
322         int yclk_khz;
323         int dispclk_khz;
324         int blackout_recovery_time_us;
325 };
326
327 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
328 struct dcn_bw_clocks {
329         int dispclk_khz;
330         bool dppclk_div;
331         int dcfclk_khz;
332         int dcfclk_deep_sleep_khz;
333         int fclk_khz;
334         int dram_ccm_us;
335         int min_active_dram_ccm_us;
336 };
337
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;
342 };
343 #endif
344
345 union bw_context {
346 #ifdef CONFIG_DRM_AMD_DC_DCN1_0
347         struct dcn_bw_output dcn;
348 #endif
349         struct dce_bw_output dce;
350 };
351
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;
356
357         struct resource_context res_ctx;
358
359         /* The output from BW and WM calculations. */
360         union bw_context bw;
361
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;
366 #endif
367
368         int ref_count;
369 };
370
371 #endif /* _CORE_TYPES_H_ */