]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/gpu/drm/amd/display/dc/inc/core_types.h
drm/amd/dc: Add dc display driver (v2)
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / amd / display / dc / inc / core_types.h
CommitLineData
4562236b
HW
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 "bandwidth_calcs.h"
31#include "ddc_service_types.h"
32#include "dc_bios_types.h"
33
34struct core_stream;
35/********* core_target *************/
36
37#define CONST_DC_TARGET_TO_CORE(dc_target) \
38 container_of(dc_target, const struct core_target, public)
39#define DC_TARGET_TO_CORE(dc_target) \
40 container_of(dc_target, struct core_target, public)
41
42#define MAX_PIPES 6
43#define MAX_CLOCK_SOURCES 7
44
45struct core_target {
46 struct dc_target public;
47
48 struct dc_context *ctx;
49};
50
51/********* core_surface **********/
52#define DC_SURFACE_TO_CORE(dc_surface) \
53 container_of(dc_surface, struct core_surface, public)
54
55#define DC_GAMMA_TO_CORE(dc_gamma) \
56 container_of(dc_gamma, struct core_gamma, public)
57
58struct core_surface {
59 struct dc_surface public;
60 struct dc_surface_status status;
61 struct dc_context *ctx;
62};
63
64struct core_gamma {
65 struct dc_gamma public;
66 struct dc_context *ctx;
67};
68
69void enable_surface_flip_reporting(struct dc_surface *dc_surface,
70 uint32_t controller_id);
71
72/********* core_stream ************/
73#include "grph_object_id.h"
74#include "link_encoder.h"
75#include "stream_encoder.h"
76#include "clock_source.h"
77#include "audio.h"
78#include "hw_sequencer_types.h"
79#include "opp.h"
80
81#define DC_STREAM_TO_CORE(dc_stream) container_of( \
82 dc_stream, struct core_stream, public)
83
84struct core_stream {
85 struct dc_stream public;
86
87 /* field internal to DC */
88 struct dc_context *ctx;
89 const struct core_sink *sink;
90
91 /* used by DCP and FMT */
92 struct bit_depth_reduction_params bit_depth_params;
93 struct clamping_and_pixel_encoding_params clamping;
94
95 int phy_pix_clk;
96 enum signal_type signal;
97
98 struct dc_stream_status status;
99};
100
101/************ core_sink *****************/
102
103#define DC_SINK_TO_CORE(dc_sink) \
104 container_of(dc_sink, struct core_sink, public)
105
106struct core_sink {
107 /** The public, read-only (for DM) area of sink. **/
108 struct dc_sink public;
109 /** End-of-public area. **/
110
111 /** The 'protected' area - read/write access, for use only inside DC **/
112 /* not used for now */
113 struct core_link *link;
114 struct dc_context *ctx;
115 uint32_t dongle_max_pix_clk;
116 bool converter_disable_audio;
117};
118
119/************ link *****************/
120#define DC_LINK_TO_CORE(dc_link) container_of(dc_link, struct core_link, public)
121
122struct link_init_data {
123 const struct core_dc *dc;
124 struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */
125 uint32_t connector_index; /* this will be mapped to the HPD pins */
126 uint32_t link_index; /* this is mapped to DAL display_index
127 TODO: remove it when DC is complete. */
128};
129
130/* DP MST stream allocation (payload bandwidth number) */
131struct link_mst_stream_allocation {
132 /* DIG front */
133 const struct stream_encoder *stream_enc;
134 /* associate DRM payload table with DC stream encoder */
135 uint8_t vcp_id;
136 /* number of slots required for the DP stream in transport packet */
137 uint8_t slot_count;
138};
139
140/* DP MST stream allocation table */
141struct link_mst_stream_allocation_table {
142 /* number of DP video streams */
143 int stream_count;
144 /* array of stream allocations */
145 struct link_mst_stream_allocation
146 stream_allocations[MAX_CONTROLLER_NUM];
147};
148
149struct core_link {
150 struct dc_link public;
151 const struct core_dc *dc;
152
153 struct dc_context *ctx; /* TODO: AUTO remove 'dal' when DC is complete*/
154
155 struct link_encoder *link_enc;
156 struct ddc_service *ddc;
157 struct graphics_object_id link_id;
158 union ddi_channel_mapping ddi_channel_mapping;
159 struct connector_device_tag_info device_tag;
160 struct dpcd_caps dpcd_caps;
161 unsigned int dpcd_sink_count;
162
163 enum edp_revision edp_revision;
164
165 /* MST record stream using this link */
166 struct link_flags {
167 bool dp_keep_receiver_powered;
168 } wa_flags;
169 struct link_mst_stream_allocation_table mst_stream_alloc_table;
170
171 struct dc_link_status link_status;
172};
173
174#define DC_LINK_TO_LINK(dc_link) container_of(dc_link, struct core_link, public)
175
176struct core_link *link_create(const struct link_init_data *init_params);
177void link_destroy(struct core_link **link);
178
179enum dc_status dc_link_validate_mode_timing(
180 const struct core_stream *stream,
181 struct core_link *link,
182 const struct dc_crtc_timing *timing);
183
184void core_link_resume(struct core_link *link);
185
186void core_link_enable_stream(struct pipe_ctx *pipe_ctx);
187
188void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
189
190/********** DAL Core*********************/
191#include "display_clock_interface.h"
192#include "transform.h"
193
194struct resource_pool;
195struct validate_context;
196struct resource_context;
197
198struct resource_funcs {
199 void (*destroy)(struct resource_pool **pool);
200 struct link_encoder *(*link_enc_create)(
201 const struct encoder_init_data *init);
202 enum dc_status (*validate_with_context)(
203 const struct core_dc *dc,
204 const struct dc_validation_set set[],
205 int set_count,
206 struct validate_context *context);
207
208 enum dc_status (*validate_guaranteed)(
209 const struct core_dc *dc,
210 const struct dc_target *dc_target,
211 struct validate_context *context);
212
213 enum dc_status (*validate_bandwidth)(
214 const struct core_dc *dc,
215 struct validate_context *context);
216
217 struct validate_context *(*apply_clk_constraints)(
218 const struct core_dc *dc,
219 struct validate_context *context);
220
221 struct pipe_ctx *(*acquire_idle_pipe_for_layer)(
222 struct resource_context *res_ctx,
223 struct core_stream *stream);
224
225 void (*build_bit_depth_reduction_params)(
226 const struct core_stream *stream,
227 struct bit_depth_reduction_params *fmt_bit_depth);
228};
229
230struct audio_support{
231 bool dp_audio;
232 bool hdmi_audio_on_dongle;
233 bool hdmi_audio_native;
234};
235
236struct resource_pool {
237 struct mem_input *mis[MAX_PIPES];
238 struct input_pixel_processor *ipps[MAX_PIPES];
239 struct transform *transforms[MAX_PIPES];
240 struct output_pixel_processor *opps[MAX_PIPES];
241 struct timing_generator *timing_generators[MAX_PIPES];
242 struct stream_encoder *stream_enc[MAX_PIPES * 2];
243
244 unsigned int pipe_count;
245 unsigned int underlay_pipe_index;
246 unsigned int stream_enc_count;
247
248 /*
249 * reserved clock source for DP
250 */
251 struct clock_source *dp_clock_source;
252
253 struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
254 unsigned int clk_src_count;
255
256 struct audio *audios[MAX_PIPES];
257 unsigned int audio_count;
258 struct audio_support audio_support;
259
260 struct display_clock *display_clock;
261 struct irq_service *irqs;
262
263 const struct resource_funcs *funcs;
264 const struct resource_caps *res_cap;
265};
266
267struct pipe_ctx {
268 struct core_surface *surface;
269 struct core_stream *stream;
270
271 struct mem_input *mi;
272 struct input_pixel_processor *ipp;
273 struct transform *xfm;
274 struct output_pixel_processor *opp;
275 struct timing_generator *tg;
276
277 struct scaler_data scl_data;
278
279 struct stream_encoder *stream_enc;
280 struct display_clock *dis_clk;
281 struct clock_source *clock_source;
282
283 struct audio *audio;
284
285 struct pixel_clk_params pix_clk_params;
286 struct pll_settings pll_settings;
287
288 /*fmt*/
289 struct encoder_info_frame encoder_info_frame;
290
291 uint8_t pipe_idx;
292
293 struct pipe_ctx *top_pipe;
294 struct pipe_ctx *bottom_pipe;
295};
296
297struct resource_context {
298 const struct resource_pool *pool;
299 struct pipe_ctx pipe_ctx[MAX_PIPES];
300 bool is_stream_enc_acquired[MAX_PIPES * 2];
301 bool is_audio_acquired[MAX_PIPES];
302 uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES];
303 uint8_t dp_clock_source_ref_count;
304 };
305
306struct validate_context {
307 struct core_target *targets[MAX_PIPES];
308 struct dc_target_status target_status[MAX_PIPES];
309 uint8_t target_count;
310
311 struct resource_context res_ctx;
312
313 /* The output from BW and WM calculations. */
314 struct bw_calcs_output bw_results;
315 /* Note: this is a big structure, do *not* put on stack! */
316 struct dm_pp_display_configuration pp_display_cfg;
317};
318
319#endif /* _CORE_TYPES_H_ */