blob: 647c095e0ae9b932db19d74808ed7cd2c0afef6d [file] [log] [blame]
Harry Wentland45622362017-09-12 15:58:20 -04001/*
2 * Copyright 2012-14 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 DC_INTERFACE_H_
27#define DC_INTERFACE_H_
28
29#include "dc_types.h"
Harry Wentland45622362017-09-12 15:58:20 -040030#include "grph_object_defs.h"
31#include "logger_types.h"
32#include "gpio_types.h"
33#include "link_service_types.h"
34
Harry Wentland091a97e2016-12-06 12:25:52 -050035#define MAX_SURFACES 3
Aric Cyrab2541b2016-12-29 15:27:12 -050036#define MAX_STREAMS 6
Harry Wentland45622362017-09-12 15:58:20 -040037#define MAX_SINKS_PER_LINK 4
38
39/*******************************************************************************
40 * Display Core Interfaces
41 ******************************************************************************/
42
43struct dc_caps {
Aric Cyrab2541b2016-12-29 15:27:12 -050044 uint32_t max_streams;
Harry Wentland45622362017-09-12 15:58:20 -040045 uint32_t max_links;
46 uint32_t max_audios;
47 uint32_t max_slave_planes;
Alex Deucherd4e13b02017-06-15 16:24:01 -040048 uint32_t max_surfaces;
Harry Wentland45622362017-09-12 15:58:20 -040049 uint32_t max_downscale_ratio;
50 uint32_t i2c_speed_in_khz;
Tony Chenga37656b2017-02-08 22:13:52 -050051
52 unsigned int max_cursor_size;
Harry Wentland45622362017-09-12 15:58:20 -040053};
54
55
56struct dc_dcc_surface_param {
57 enum surface_pixel_format format;
58 struct dc_size surface_size;
Alex Deucher2c8ad2d2017-06-15 16:20:24 -040059 enum swizzle_mode_values swizzle_mode;
Harry Wentland45622362017-09-12 15:58:20 -040060 enum dc_scan_direction scan;
61};
62
63struct dc_dcc_setting {
64 unsigned int max_compressed_blk_size;
65 unsigned int max_uncompressed_blk_size;
66 bool independent_64b_blks;
67};
68
69struct dc_surface_dcc_cap {
70 bool capable;
71 bool const_color_support;
72
73 union {
74 struct {
75 struct dc_dcc_setting rgb;
76 } grph;
77
78 struct {
79 struct dc_dcc_setting luma;
80 struct dc_dcc_setting chroma;
81 } video;
82 };
83};
84
Sylvia Tsai94267b32017-04-21 15:29:55 -040085struct dc_static_screen_events {
86 bool cursor_update;
87 bool surface_update;
88 bool overlay_update;
89};
90
Harry Wentland45622362017-09-12 15:58:20 -040091/* Forward declaration*/
92struct dc;
93struct dc_surface;
94struct validate_context;
95
96struct dc_cap_funcs {
97 int i;
98};
99
100struct dc_stream_funcs {
101 bool (*adjust_vmin_vmax)(struct dc *dc,
102 const struct dc_stream **stream,
103 int num_streams,
104 int vmin,
105 int vmax);
Eric Cook72ada5f2017-04-18 15:24:50 -0400106 bool (*get_crtc_position)(struct dc *dc,
107 const struct dc_stream **stream,
108 int num_streams,
109 unsigned int *v_pos,
110 unsigned int *nom_v_pos);
111
Harry Wentland45622362017-09-12 15:58:20 -0400112
113 void (*stream_update_scaling)(const struct dc *dc,
114 const struct dc_stream *dc_stream,
115 const struct rect *src,
116 const struct rect *dst);
Sylvia Tsai94267b32017-04-21 15:29:55 -0400117
Harry Wentland45622362017-09-12 15:58:20 -0400118 bool (*set_gamut_remap)(struct dc *dc,
119 const struct dc_stream **stream, int num_streams);
Sylvia Tsai94267b32017-04-21 15:29:55 -0400120
121 void (*set_static_screen_events)(struct dc *dc,
122 const struct dc_stream **stream,
123 int num_streams,
124 const struct dc_static_screen_events *events);
Harry Wentland45622362017-09-12 15:58:20 -0400125};
126
127struct link_training_settings;
128
129struct dc_link_funcs {
130 void (*set_drive_settings)(struct dc *dc,
Hersen Wubf5cda32017-01-04 10:22:35 -0500131 struct link_training_settings *lt_settings,
132 const struct dc_link *link);
Harry Wentland45622362017-09-12 15:58:20 -0400133 void (*perform_link_training)(struct dc *dc,
134 struct dc_link_settings *link_setting,
135 bool skip_video_pattern);
136 void (*set_preferred_link_settings)(struct dc *dc,
Zeyu Fan88639162016-12-23 16:53:12 -0500137 struct dc_link_settings *link_setting,
138 const struct dc_link *link);
Harry Wentland45622362017-09-12 15:58:20 -0400139 void (*enable_hpd)(const struct dc_link *link);
140 void (*disable_hpd)(const struct dc_link *link);
141 void (*set_test_pattern)(
142 const struct dc_link *link,
143 enum dp_test_pattern test_pattern,
144 const struct link_training_settings *p_link_settings,
145 const unsigned char *p_custom_pattern,
146 unsigned int cust_pattern_size);
147};
148
149/* Structure to hold configuration flags set by dm at dc creation. */
150struct dc_config {
151 bool gpu_vm_support;
152 bool disable_disp_pll_sharing;
153};
154
155struct dc_debug {
156 bool surface_visual_confirm;
157 bool max_disp_clk;
Harry Wentland45622362017-09-12 15:58:20 -0400158 bool surface_trace;
Yongqiang Sun94749802016-12-08 09:47:11 -0500159 bool timing_trace;
Harry Wentland45622362017-09-12 15:58:20 -0400160 bool validation_trace;
161 bool disable_stutter;
162 bool disable_dcc;
163 bool disable_dfs_bypass;
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400164 bool disable_pplib_clock_request;
Harry Wentland45622362017-09-12 15:58:20 -0400165 bool disable_clock_gate;
Yongqiang Sunaa66df52016-12-15 10:50:48 -0500166 bool disable_dmcu;
Anthony Koo70814f62017-01-27 17:50:03 -0500167 bool force_abm_enable;
Harry Wentland45622362017-09-12 15:58:20 -0400168};
169
170struct dc {
171 struct dc_caps caps;
172 struct dc_cap_funcs cap_funcs;
173 struct dc_stream_funcs stream_funcs;
174 struct dc_link_funcs link_funcs;
175 struct dc_config config;
176 struct dc_debug debug;
177};
178
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400179enum frame_buffer_mode {
180 FRAME_BUFFER_MODE_LOCAL_ONLY = 0,
181 FRAME_BUFFER_MODE_ZFB_ONLY,
182 FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL,
183} ;
184
185struct dchub_init_data {
186 bool dchub_initialzied;
187 bool dchub_info_valid;
188 int64_t zfb_phys_addr_base;
189 int64_t zfb_mc_base_addr;
190 uint64_t zfb_size_in_byte;
191 enum frame_buffer_mode fb_mode;
192};
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400193
Harry Wentland45622362017-09-12 15:58:20 -0400194struct dc_init_data {
195 struct hw_asic_id asic_id;
196 void *driver; /* ctx */
197 struct cgs_device *cgs_device;
198
199 int num_virtual_links;
200 /*
201 * If 'vbios_override' not NULL, it will be called instead
202 * of the real VBIOS. Intended use is Diagnostics on FPGA.
203 */
204 struct dc_bios *vbios_override;
205 enum dce_environment dce_environment;
206
207 struct dc_config flags;
208};
209
210struct dc *dc_create(const struct dc_init_data *init_params);
211
212void dc_destroy(struct dc **dc);
213
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400214bool dc_init_dchub(struct dc *dc, struct dchub_init_data *dh_data);
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400215
Harry Wentland45622362017-09-12 15:58:20 -0400216/*******************************************************************************
217 * Surface Interfaces
218 ******************************************************************************/
219
220enum {
Anthony Koofb735a92016-12-13 13:59:41 -0500221 TRANSFER_FUNC_POINTS = 1025
Harry Wentland45622362017-09-12 15:58:20 -0400222};
223
Andrew Wong1646a6fe2016-12-22 15:41:30 -0500224struct dc_hdr_static_metadata {
Amy Zhang70063a52017-02-16 11:04:48 -0500225 bool hdr_supported;
Andrew Wong1646a6fe2016-12-22 15:41:30 -0500226 bool is_hdr;
227
228 /* display chromaticities and white point in units of 0.00001 */
229 unsigned int chromaticity_green_x;
230 unsigned int chromaticity_green_y;
231 unsigned int chromaticity_blue_x;
232 unsigned int chromaticity_blue_y;
233 unsigned int chromaticity_red_x;
234 unsigned int chromaticity_red_y;
235 unsigned int chromaticity_white_point_x;
236 unsigned int chromaticity_white_point_y;
237
238 uint32_t min_luminance;
239 uint32_t max_luminance;
240 uint32_t maximum_content_light_level;
241 uint32_t maximum_frame_average_light_level;
242};
243
Anthony Koofb735a92016-12-13 13:59:41 -0500244enum dc_transfer_func_type {
245 TF_TYPE_PREDEFINED,
246 TF_TYPE_DISTRIBUTED_POINTS,
Amy Zhang70063a52017-02-16 11:04:48 -0500247 TF_TYPE_BYPASS
Anthony Koofb735a92016-12-13 13:59:41 -0500248};
249
250struct dc_transfer_func_distributed_points {
Amy Zhangfcd2f4b2017-01-05 17:12:20 -0500251 struct fixed31_32 red[TRANSFER_FUNC_POINTS];
252 struct fixed31_32 green[TRANSFER_FUNC_POINTS];
253 struct fixed31_32 blue[TRANSFER_FUNC_POINTS];
254
Anthony Koofb735a92016-12-13 13:59:41 -0500255 uint16_t end_exponent;
Amy Zhangfcd2f4b2017-01-05 17:12:20 -0500256 uint16_t x_point_at_y1_red;
257 uint16_t x_point_at_y1_green;
258 uint16_t x_point_at_y1_blue;
Anthony Koofb735a92016-12-13 13:59:41 -0500259};
260
261enum dc_transfer_func_predefined {
262 TRANSFER_FUNCTION_SRGB,
263 TRANSFER_FUNCTION_BT709,
Anthony Koo90e508b2016-12-15 12:09:46 -0500264 TRANSFER_FUNCTION_PQ,
Anthony Koofb735a92016-12-13 13:59:41 -0500265 TRANSFER_FUNCTION_LINEAR,
266};
267
268struct dc_transfer_func {
269 enum dc_transfer_func_type type;
270 enum dc_transfer_func_predefined tf;
271 struct dc_transfer_func_distributed_points tf_pts;
272};
273
Harry Wentland45622362017-09-12 15:58:20 -0400274struct dc_surface {
275 bool visible;
276 bool flip_immediate;
277 struct dc_plane_address address;
278
279 struct scaling_taps scaling_quality;
280 struct rect src_rect;
281 struct rect dst_rect;
282 struct rect clip_rect;
283
284 union plane_size plane_size;
285 union dc_tiling_info tiling_info;
286 struct dc_plane_dcc_param dcc;
287 enum dc_color_space color_space;
288
289 enum surface_pixel_format format;
290 enum dc_rotation_angle rotation;
291 bool horizontal_mirror;
292 enum plane_stereo_format stereo_format;
293
Andrew Wong1646a6fe2016-12-22 15:41:30 -0500294 struct dc_hdr_static_metadata hdr_static_ctx;
295
Harry Wentland45622362017-09-12 15:58:20 -0400296 const struct dc_gamma *gamma_correction;
Anthony Koofb735a92016-12-13 13:59:41 -0500297 const struct dc_transfer_func *in_transfer_func;
Harry Wentland45622362017-09-12 15:58:20 -0400298};
299
300struct dc_plane_info {
301 union plane_size plane_size;
302 union dc_tiling_info tiling_info;
Leon Elazar9cd09bf2016-12-19 12:00:05 -0500303 struct dc_plane_dcc_param dcc;
Harry Wentland45622362017-09-12 15:58:20 -0400304 enum surface_pixel_format format;
305 enum dc_rotation_angle rotation;
306 bool horizontal_mirror;
307 enum plane_stereo_format stereo_format;
308 enum dc_color_space color_space; /*todo: wrong place, fits in scaling info*/
309 bool visible;
310};
311
312struct dc_scaling_info {
313 struct rect src_rect;
314 struct rect dst_rect;
315 struct rect clip_rect;
316 struct scaling_taps scaling_quality;
317};
318
319struct dc_surface_update {
320 const struct dc_surface *surface;
321
322 /* isr safe update parameters. null means no updates */
323 struct dc_flip_addrs *flip_addr;
324 struct dc_plane_info *plane_info;
325 struct dc_scaling_info *scaling_info;
326 /* following updates require alloc/sleep/spin that is not isr safe,
327 * null means no updates
328 */
Anthony Koofb735a92016-12-13 13:59:41 -0500329 /* gamma TO BE REMOVED */
Harry Wentland45622362017-09-12 15:58:20 -0400330 struct dc_gamma *gamma;
Andrew Wong1646a6fe2016-12-22 15:41:30 -0500331 struct dc_hdr_static_metadata *hdr_static_metadata;
Anthony Koofb735a92016-12-13 13:59:41 -0500332 struct dc_transfer_func *in_transfer_func;
333 struct dc_transfer_func *out_transfer_func;
334
Harry Wentland45622362017-09-12 15:58:20 -0400335
336};
337/*
338 * This structure is filled in by dc_surface_get_status and contains
339 * the last requested address and the currently active address so the called
340 * can determine if there are any outstanding flips
341 */
342struct dc_surface_status {
343 struct dc_plane_address requested_address;
344 struct dc_plane_address current_address;
345 bool is_flip_pending;
346};
347
348/*
349 * Create a new surface with default parameters;
350 */
351struct dc_surface *dc_create_surface(const struct dc *dc);
352const struct dc_surface_status *dc_surface_get_status(
353 const struct dc_surface *dc_surface);
354
355void dc_surface_retain(const struct dc_surface *dc_surface);
356void dc_surface_release(const struct dc_surface *dc_surface);
357
Amy Zhang89e89632016-12-12 10:32:24 -0500358void dc_gamma_retain(const struct dc_gamma *dc_gamma);
Yongqiang Sunaff20232016-12-23 10:18:08 -0500359void dc_gamma_release(const struct dc_gamma **dc_gamma);
Harry Wentland45622362017-09-12 15:58:20 -0400360struct dc_gamma *dc_create_gamma(void);
361
Anthony Koofb735a92016-12-13 13:59:41 -0500362void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf);
363void dc_transfer_func_release(const struct dc_transfer_func *dc_tf);
Anthony Koo90e508b2016-12-15 12:09:46 -0500364struct dc_transfer_func *dc_create_transfer_func(void);
Anthony Koofb735a92016-12-13 13:59:41 -0500365
Harry Wentland45622362017-09-12 15:58:20 -0400366/*
367 * This structure holds a surface address. There could be multiple addresses
368 * in cases such as Stereo 3D, Planar YUV, etc. Other per-flip attributes such
369 * as frame durations and DCC format can also be set.
370 */
371struct dc_flip_addrs {
372 struct dc_plane_address address;
373 bool flip_immediate;
Harry Wentland45622362017-09-12 15:58:20 -0400374 /* TODO: add flip duration for FreeSync */
375};
376
377/*
378 * Optimized flip address update function.
379 *
380 * After this call:
381 * Surface addresses and flip attributes are programmed.
382 * Surface flip occur at next configured time (h_sync or v_sync flip)
383 */
384void dc_flip_surface_addrs(struct dc *dc,
385 const struct dc_surface *const surfaces[],
386 struct dc_flip_addrs flip_addrs[],
387 uint32_t count);
388
389/*
Aric Cyrab2541b2016-12-29 15:27:12 -0500390 * Set up surface attributes and associate to a stream
391 * The surfaces parameter is an absolute set of all surface active for the stream.
392 * If no surfaces are provided, the stream will be blanked; no memory read.
Harry Wentland45622362017-09-12 15:58:20 -0400393 * Any flip related attribute changes must be done through this interface.
394 *
395 * After this call:
Aric Cyrab2541b2016-12-29 15:27:12 -0500396 * Surfaces attributes are programmed and configured to be composed into stream.
Harry Wentland45622362017-09-12 15:58:20 -0400397 * This does not trigger a flip. No surface address is programmed.
398 */
399
Aric Cyrab2541b2016-12-29 15:27:12 -0500400bool dc_commit_surfaces_to_stream(
Harry Wentland45622362017-09-12 15:58:20 -0400401 struct dc *dc,
402 const struct dc_surface **dc_surfaces,
403 uint8_t surface_count,
Aric Cyrab2541b2016-12-29 15:27:12 -0500404 const struct dc_stream *stream);
Harry Wentland45622362017-09-12 15:58:20 -0400405
Aric Cyrab2541b2016-12-29 15:27:12 -0500406bool dc_pre_update_surfaces_to_stream(
Harry Wentland45622362017-09-12 15:58:20 -0400407 struct dc *dc,
408 const struct dc_surface *const *new_surfaces,
409 uint8_t new_surface_count,
Aric Cyrab2541b2016-12-29 15:27:12 -0500410 const struct dc_stream *stream);
Harry Wentland45622362017-09-12 15:58:20 -0400411
Aric Cyrab2541b2016-12-29 15:27:12 -0500412bool dc_post_update_surfaces_to_stream(
Harry Wentland45622362017-09-12 15:58:20 -0400413 struct dc *dc);
414
Aric Cyrab2541b2016-12-29 15:27:12 -0500415void dc_update_surfaces_for_stream(struct dc *dc, struct dc_surface_update *updates,
416 int surface_count, const struct dc_stream *stream);
Harry Wentland45622362017-09-12 15:58:20 -0400417
Leon Elazar5869b0f2017-03-01 12:30:11 -0500418enum surface_update_type {
419 UPDATE_TYPE_FAST, /* super fast, safe to execute in isr */
420 UPDATE_TYPE_MED, /* a lot of programming needed. may need to alloc */
421 UPDATE_TYPE_FULL, /* may need to shuffle resources */
422};
423
Harry Wentland45622362017-09-12 15:58:20 -0400424/*******************************************************************************
425 * Stream Interfaces
426 ******************************************************************************/
427struct dc_stream {
428 const struct dc_sink *sink;
429 struct dc_crtc_timing timing;
Sylvia Tsai8b320762017-04-04 17:28:17 -0400430 enum signal_type output_signal;
Harry Wentland45622362017-09-12 15:58:20 -0400431
432 enum dc_color_space output_color_space;
433
Aric Cyrab2541b2016-12-29 15:27:12 -0500434 struct rect src; /* composition area */
Harry Wentland45622362017-09-12 15:58:20 -0400435 struct rect dst; /* stream addressable area */
436
437 struct audio_info audio_info;
438
439 bool ignore_msa_timing_param;
440
441 struct freesync_context freesync_ctx;
442
Anthony Koo90e508b2016-12-15 12:09:46 -0500443 const struct dc_transfer_func *out_transfer_func;
Harry Wentland45622362017-09-12 15:58:20 -0400444 struct colorspace_transform gamut_remap_matrix;
445 struct csc_transform csc_color_matrix;
Anthony Koo90e508b2016-12-15 12:09:46 -0500446
447 /* TODO: dithering */
Harry Wentland45622362017-09-12 15:58:20 -0400448 /* TODO: custom INFO packets */
449 /* TODO: ABM info (DMCU) */
450 /* TODO: PSR info */
451 /* TODO: CEA VIC */
452};
453
Leon Elazara783e7b2017-03-09 14:38:15 -0500454struct dc_stream_update {
455
456 struct rect src;
457
458 struct rect dst;
459
460};
461
462
463/*
464 * Setup stream attributes if no stream updates are provided
465 * there will be no impact on the stream parameters
466 *
467 * Set up surface attributes and associate to a stream
468 * The surfaces parameter is an absolute set of all surface active for the stream.
469 * If no surfaces are provided, the stream will be blanked; no memory read.
470 * Any flip related attribute changes must be done through this interface.
471 *
472 * After this call:
473 * Surfaces attributes are programmed and configured to be composed into stream.
474 * This does not trigger a flip. No surface address is programmed.
475 *
476 */
477
478void dc_update_surfaces_and_stream(struct dc *dc,
479 struct dc_surface_update *surface_updates, int surface_count,
480 const struct dc_stream *dc_stream,
481 struct dc_stream_update *stream_update);
482
Aric Cyrab2541b2016-12-29 15:27:12 -0500483/*
484 * Log the current stream state.
485 */
486void dc_stream_log(
487 const struct dc_stream *stream,
488 struct dal_logger *dc_logger,
489 enum dc_log_type log_type);
490
491uint8_t dc_get_current_stream_count(const struct dc *dc);
492struct dc_stream *dc_get_stream_at_index(const struct dc *dc, uint8_t i);
493
494/*
495 * Return the current frame counter.
496 */
497uint32_t dc_stream_get_vblank_counter(const struct dc_stream *stream);
498
499/* TODO: Return parsed values rather than direct register read
500 * This has a dependency on the caller (amdgpu_get_crtc_scanoutpos)
501 * being refactored properly to be dce-specific
502 */
Sylvia Tsai81c50962017-04-11 15:15:28 -0400503bool dc_stream_get_scanoutpos(const struct dc_stream *stream,
504 uint32_t *v_blank_start,
505 uint32_t *v_blank_end,
506 uint32_t *h_position,
507 uint32_t *v_position);
Aric Cyrab2541b2016-12-29 15:27:12 -0500508
509/*
510 * Structure to store surface/stream associations for validation
511 */
512struct dc_validation_set {
513 const struct dc_stream *stream;
514 const struct dc_surface *surfaces[MAX_SURFACES];
515 uint8_t surface_count;
516};
517
518/*
519 * This function takes a set of resources and checks that they are cofunctional.
520 *
521 * After this call:
522 * No hardware is programmed for call. Only validation is done.
523 */
Harry Wentland07d72b32017-03-29 11:22:05 -0400524struct validate_context *dc_get_validate_context(
525 const struct dc *dc,
526 const struct dc_validation_set set[],
527 uint8_t set_count);
528
Aric Cyrab2541b2016-12-29 15:27:12 -0500529bool dc_validate_resources(
530 const struct dc *dc,
531 const struct dc_validation_set set[],
532 uint8_t set_count);
533
534/*
535 * This function takes a stream and checks if it is guaranteed to be supported.
536 * Guaranteed means that MAX_COFUNC similar streams are supported.
537 *
538 * After this call:
539 * No hardware is programmed for call. Only validation is done.
540 */
541
542bool dc_validate_guaranteed(
543 const struct dc *dc,
544 const struct dc_stream *stream);
545
Harry Wentland8122a252017-03-29 11:15:14 -0400546void dc_resource_validate_ctx_copy_construct(
547 const struct validate_context *src_ctx,
548 struct validate_context *dst_ctx);
549
550void dc_resource_validate_ctx_destruct(struct validate_context *context);
551
Aric Cyrab2541b2016-12-29 15:27:12 -0500552/*
553 * Set up streams and links associated to drive sinks
554 * The streams parameter is an absolute set of all active streams.
555 *
556 * After this call:
557 * Phy, Encoder, Timing Generator are programmed and enabled.
558 * New streams are enabled with blank stream; no memory read.
559 */
560bool dc_commit_streams(
561 struct dc *dc,
562 const struct dc_stream *streams[],
563 uint8_t stream_count);
564
Harry Wentland45622362017-09-12 15:58:20 -0400565/**
566 * Create a new default stream for the requested sink
567 */
568struct dc_stream *dc_create_stream_for_sink(const struct dc_sink *dc_sink);
569
570void dc_stream_retain(const struct dc_stream *dc_stream);
571void dc_stream_release(const struct dc_stream *dc_stream);
572
573struct dc_stream_status {
Aric Cyrab2541b2016-12-29 15:27:12 -0500574 int primary_otg_inst;
575 int surface_count;
576 const struct dc_surface *surfaces[MAX_SURFACE_NUM];
577
Harry Wentland45622362017-09-12 15:58:20 -0400578 /*
579 * link this stream passes through
580 */
581 const struct dc_link *link;
582};
583
584const struct dc_stream_status *dc_stream_get_status(
585 const struct dc_stream *dc_stream);
586
Leon Elazar5869b0f2017-03-01 12:30:11 -0500587enum surface_update_type dc_check_update_surfaces_for_stream(
588 struct dc *dc,
589 struct dc_surface_update *updates,
590 int surface_count,
Leon Elazaree8f63e2017-03-14 11:54:31 -0400591 struct dc_stream_update *stream_update,
Leon Elazar5869b0f2017-03-01 12:30:11 -0500592 const struct dc_stream_status *stream_status);
593
Harry Wentland45622362017-09-12 15:58:20 -0400594/*******************************************************************************
595 * Link Interfaces
596 ******************************************************************************/
597
598/*
599 * A link contains one or more sinks and their connected status.
600 * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
601 */
602struct dc_link {
603 const struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
604 unsigned int sink_count;
605 const struct dc_sink *local_sink;
606 unsigned int link_index;
607 enum dc_connection_type type;
608 enum signal_type connector_signal;
609 enum dc_irq_source irq_source_hpd;
610 enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */
611 /* caps is the same as reported_link_cap. link_traing use
612 * reported_link_cap. Will clean up. TODO
613 */
614 struct dc_link_settings reported_link_cap;
615 struct dc_link_settings verified_link_cap;
616 struct dc_link_settings max_link_setting;
617 struct dc_link_settings cur_link_settings;
618 struct dc_lane_settings cur_lane_setting;
619
620 uint8_t ddc_hw_inst;
621 uint8_t link_enc_hw_inst;
622
Harry Wentland45622362017-09-12 15:58:20 -0400623 bool test_pattern_enabled;
624 union compliance_test_state compliance_test_state;
Andrey Grodzovsky9fb8de72017-02-14 13:50:17 -0500625
626 void *priv;
Andrey Grodzovsky7c7f5b12017-03-28 16:57:52 -0400627 bool aux_mode;
Harry Wentland45622362017-09-12 15:58:20 -0400628};
629
630struct dpcd_caps {
631 union dpcd_rev dpcd_rev;
632 union max_lane_count max_ln_count;
633 union max_down_spread max_down_spread;
634
635 /* dongle type (DP converter, CV smart dongle) */
636 enum display_dongle_type dongle_type;
637 /* Dongle's downstream count. */
638 union sink_count sink_count;
639 /* If dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER,
640 indicates 'Frame Sequential-to-lllFrame Pack' conversion capability.*/
Charlene Liu03f5c682017-04-21 17:15:40 -0400641 struct dc_dongle_caps dongle_caps;
Harry Wentland45622362017-09-12 15:58:20 -0400642
643 bool allow_invalid_MSA_timing_param;
644 bool panel_mode_edp;
645 uint32_t sink_dev_id;
646 uint32_t branch_dev_id;
647 int8_t branch_dev_name[6];
648 int8_t branch_hw_revision;
649};
650
651struct dc_link_status {
652 struct dpcd_caps *dpcd_caps;
653};
654
655const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link);
656
657/*
658 * Return an enumerated dc_link. dc_link order is constant and determined at
659 * boot time. They cannot be created or destroyed.
660 * Use dc_get_caps() to get number of links.
661 */
662const struct dc_link *dc_get_link_at_index(const struct dc *dc, uint32_t link_index);
663
664/* Return id of physical connector represented by a dc_link at link_index.*/
665const struct graphics_object_id dc_get_link_id_at_index(
666 struct dc *dc, uint32_t link_index);
667
668/* Set backlight level of an embedded panel (eDP, LVDS). */
669bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level,
670 uint32_t frame_ramp, const struct dc_stream *stream);
671
Harry Wentland45622362017-09-12 15:58:20 -0400672bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable);
673
674bool dc_link_setup_psr(const struct dc_link *dc_link,
Sylvia Tsai94267b32017-04-21 15:29:55 -0400675 const struct dc_stream *stream, struct psr_config *psr_config);
Harry Wentland45622362017-09-12 15:58:20 -0400676
677/* Request DC to detect if there is a Panel connected.
678 * boot - If this call is during initial boot.
679 * Return false for any type of detection failure or MST detection
680 * true otherwise. True meaning further action is required (status update
681 * and OS notification).
682 */
683bool dc_link_detect(const struct dc_link *dc_link, bool boot);
684
685/* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt).
686 * Return:
687 * true - Downstream port status changed. DM should call DC to do the
688 * detection.
689 * false - no change in Downstream port status. No further action required
690 * from DM. */
691bool dc_link_handle_hpd_rx_irq(const struct dc_link *dc_link);
692
693struct dc_sink_init_data;
694
695struct dc_sink *dc_link_add_remote_sink(
696 const struct dc_link *dc_link,
697 const uint8_t *edid,
698 int len,
699 struct dc_sink_init_data *init_data);
700
701void dc_link_remove_remote_sink(
702 const struct dc_link *link,
703 const struct dc_sink *sink);
704
705/* Used by diagnostics for virtual link at the moment */
706void dc_link_set_sink(const struct dc_link *link, struct dc_sink *sink);
707
708void dc_link_dp_set_drive_settings(
Zeyu Fand27383a2017-04-21 10:55:01 -0400709 const struct dc_link *link,
Harry Wentland45622362017-09-12 15:58:20 -0400710 struct link_training_settings *lt_settings);
711
712bool dc_link_dp_perform_link_training(
713 struct dc_link *link,
714 const struct dc_link_settings *link_setting,
715 bool skip_video_pattern);
716
717void dc_link_dp_enable_hpd(const struct dc_link *link);
718
719void dc_link_dp_disable_hpd(const struct dc_link *link);
720
721bool dc_link_dp_set_test_pattern(
722 const struct dc_link *link,
723 enum dp_test_pattern test_pattern,
724 const struct link_training_settings *p_link_settings,
725 const unsigned char *p_custom_pattern,
726 unsigned int cust_pattern_size);
727
728/*******************************************************************************
729 * Sink Interfaces - A sink corresponds to a display output device
730 ******************************************************************************/
731
xhdu8c895312017-03-21 11:05:32 -0400732struct dc_container_id {
733 // 128bit GUID in binary form
734 unsigned char guid[16];
735 // 8 byte port ID -> ELD.PortID
736 unsigned int portId[2];
737 // 128bit GUID in binary formufacturer name -> ELD.ManufacturerName
738 unsigned short manufacturerName;
739 // 2 byte product code -> ELD.ProductCode
740 unsigned short productCode;
741};
742
Harry Wentland45622362017-09-12 15:58:20 -0400743/*
744 * The sink structure contains EDID and other display device properties
745 */
746struct dc_sink {
747 enum signal_type sink_signal;
748 struct dc_edid dc_edid; /* raw edid */
749 struct dc_edid_caps edid_caps; /* parse display caps */
xhdu8c895312017-03-21 11:05:32 -0400750 struct dc_container_id *dc_container_id;
Zeyu Fan4a9a5d62017-03-07 11:48:50 -0500751 uint32_t dongle_max_pix_clk;
752 bool converter_disable_audio;
Andrey Grodzovsky5c4e980642017-02-14 15:47:24 -0500753 void *priv;
Harry Wentland45622362017-09-12 15:58:20 -0400754};
755
756void dc_sink_retain(const struct dc_sink *sink);
757void dc_sink_release(const struct dc_sink *sink);
758
759const struct audio **dc_get_audios(struct dc *dc);
760
761struct dc_sink_init_data {
762 enum signal_type sink_signal;
763 const struct dc_link *link;
764 uint32_t dongle_max_pix_clk;
765 bool converter_disable_audio;
766};
767
768struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params);
xhdu8c895312017-03-21 11:05:32 -0400769bool dc_sink_get_container_id(struct dc_sink *dc_sink, struct dc_container_id *container_id);
770bool dc_sink_set_container_id(struct dc_sink *dc_sink, const struct dc_container_id *container_id);
Harry Wentland45622362017-09-12 15:58:20 -0400771
772/*******************************************************************************
Aric Cyrab2541b2016-12-29 15:27:12 -0500773 * Cursor interfaces - To manages the cursor within a stream
Harry Wentland45622362017-09-12 15:58:20 -0400774 ******************************************************************************/
775/* TODO: Deprecated once we switch to dc_set_cursor_position */
Aric Cyrab2541b2016-12-29 15:27:12 -0500776bool dc_stream_set_cursor_attributes(
777 const struct dc_stream *stream,
Harry Wentland45622362017-09-12 15:58:20 -0400778 const struct dc_cursor_attributes *attributes);
779
Aric Cyrab2541b2016-12-29 15:27:12 -0500780bool dc_stream_set_cursor_position(
781 const struct dc_stream *stream,
Dmytro Laktyushkinbeb16b62017-04-21 09:34:09 -0400782 const struct dc_cursor_position *position);
Harry Wentland45622362017-09-12 15:58:20 -0400783
784/* Newer interfaces */
785struct dc_cursor {
786 struct dc_plane_address address;
787 struct dc_cursor_attributes attributes;
788};
789
Harry Wentland45622362017-09-12 15:58:20 -0400790/*******************************************************************************
791 * Interrupt interfaces
792 ******************************************************************************/
793enum dc_irq_source dc_interrupt_to_irq_source(
794 struct dc *dc,
795 uint32_t src_id,
796 uint32_t ext_id);
797void dc_interrupt_set(const struct dc *dc, enum dc_irq_source src, bool enable);
798void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src);
799enum dc_irq_source dc_get_hpd_irq_source_at_index(
800 struct dc *dc, uint32_t link_index);
801
802/*******************************************************************************
803 * Power Interfaces
804 ******************************************************************************/
805
806void dc_set_power_state(
807 struct dc *dc,
Andrey Grodzovskya3621482017-04-20 15:59:25 -0400808 enum dc_acpi_cm_power_state power_state);
Harry Wentland45622362017-09-12 15:58:20 -0400809void dc_resume(const struct dc *dc);
810
811/*******************************************************************************
812 * DDC Interfaces
813 ******************************************************************************/
814
815const struct ddc_service *dc_get_ddc_at_index(
816 struct dc *dc, uint32_t link_index);
817
818/*
819 * DPCD access interfaces
820 */
821
Andrey Grodzovsky7c7f5b12017-03-28 16:57:52 -0400822bool dc_read_aux_dpcd(
Harry Wentland45622362017-09-12 15:58:20 -0400823 struct dc *dc,
824 uint32_t link_index,
825 uint32_t address,
826 uint8_t *data,
827 uint32_t size);
828
Andrey Grodzovsky7c7f5b12017-03-28 16:57:52 -0400829bool dc_write_aux_dpcd(
Harry Wentland45622362017-09-12 15:58:20 -0400830 struct dc *dc,
831 uint32_t link_index,
832 uint32_t address,
833 const uint8_t *data,
Zeyu Fan2b230ea2017-02-16 16:15:30 -0500834 uint32_t size);
835
Andrey Grodzovsky7c7f5b12017-03-28 16:57:52 -0400836bool dc_read_aux_i2c(
837 struct dc *dc,
838 uint32_t link_index,
839 enum i2c_mot_mode mot,
840 uint32_t address,
841 uint8_t *data,
842 uint32_t size);
843
844bool dc_write_aux_i2c(
845 struct dc *dc,
846 uint32_t link_index,
847 enum i2c_mot_mode mot,
848 uint32_t address,
849 const uint8_t *data,
850 uint32_t size);
851
Zeyu Fan2b230ea2017-02-16 16:15:30 -0500852bool dc_query_ddc_data(
853 struct dc *dc,
854 uint32_t link_index,
855 uint32_t address,
856 uint8_t *write_buf,
857 uint32_t write_size,
858 uint8_t *read_buf,
859 uint32_t read_size);
Harry Wentland45622362017-09-12 15:58:20 -0400860
861bool dc_submit_i2c(
862 struct dc *dc,
863 uint32_t link_index,
864 struct i2c_command *cmd);
865
Anthony Koo5e7773a2017-01-23 16:55:20 -0500866
Harry Wentland45622362017-09-12 15:58:20 -0400867#endif /* DC_INTERFACE_H_ */