blob: 97af8f63eec337452b992304d8020b41da1964c4 [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
85/* Forward declaration*/
86struct dc;
87struct dc_surface;
88struct validate_context;
89
90struct dc_cap_funcs {
91 int i;
92};
93
94struct dc_stream_funcs {
95 bool (*adjust_vmin_vmax)(struct dc *dc,
96 const struct dc_stream **stream,
97 int num_streams,
98 int vmin,
99 int vmax);
100
101 void (*stream_update_scaling)(const struct dc *dc,
102 const struct dc_stream *dc_stream,
103 const struct rect *src,
104 const struct rect *dst);
105 bool (*set_gamut_remap)(struct dc *dc,
106 const struct dc_stream **stream, int num_streams);
Harry Wentland45622362017-09-12 15:58:20 -0400107 bool (*set_psr_enable)(struct dc *dc, bool enable);
108 bool (*setup_psr)(struct dc *dc, const struct dc_stream *stream);
109};
110
111struct link_training_settings;
112
113struct dc_link_funcs {
114 void (*set_drive_settings)(struct dc *dc,
Hersen Wubf5cda32017-01-04 10:22:35 -0500115 struct link_training_settings *lt_settings,
116 const struct dc_link *link);
Harry Wentland45622362017-09-12 15:58:20 -0400117 void (*perform_link_training)(struct dc *dc,
118 struct dc_link_settings *link_setting,
119 bool skip_video_pattern);
120 void (*set_preferred_link_settings)(struct dc *dc,
Zeyu Fan88639162016-12-23 16:53:12 -0500121 struct dc_link_settings *link_setting,
122 const struct dc_link *link);
Harry Wentland45622362017-09-12 15:58:20 -0400123 void (*enable_hpd)(const struct dc_link *link);
124 void (*disable_hpd)(const struct dc_link *link);
125 void (*set_test_pattern)(
126 const struct dc_link *link,
127 enum dp_test_pattern test_pattern,
128 const struct link_training_settings *p_link_settings,
129 const unsigned char *p_custom_pattern,
130 unsigned int cust_pattern_size);
131};
132
133/* Structure to hold configuration flags set by dm at dc creation. */
134struct dc_config {
135 bool gpu_vm_support;
136 bool disable_disp_pll_sharing;
137};
138
139struct dc_debug {
140 bool surface_visual_confirm;
141 bool max_disp_clk;
Harry Wentland45622362017-09-12 15:58:20 -0400142 bool surface_trace;
Yongqiang Sun94749802016-12-08 09:47:11 -0500143 bool timing_trace;
Harry Wentland45622362017-09-12 15:58:20 -0400144 bool validation_trace;
145 bool disable_stutter;
146 bool disable_dcc;
147 bool disable_dfs_bypass;
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400148 bool disable_pplib_clock_request;
Harry Wentland45622362017-09-12 15:58:20 -0400149 bool disable_clock_gate;
Yongqiang Sunaa66df52016-12-15 10:50:48 -0500150 bool disable_dmcu;
Anthony Koo70814f62017-01-27 17:50:03 -0500151 bool force_abm_enable;
Harry Wentland45622362017-09-12 15:58:20 -0400152};
153
154struct dc {
155 struct dc_caps caps;
156 struct dc_cap_funcs cap_funcs;
157 struct dc_stream_funcs stream_funcs;
158 struct dc_link_funcs link_funcs;
159 struct dc_config config;
160 struct dc_debug debug;
161};
162
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400163enum frame_buffer_mode {
164 FRAME_BUFFER_MODE_LOCAL_ONLY = 0,
165 FRAME_BUFFER_MODE_ZFB_ONLY,
166 FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL,
167} ;
168
169struct dchub_init_data {
170 bool dchub_initialzied;
171 bool dchub_info_valid;
172 int64_t zfb_phys_addr_base;
173 int64_t zfb_mc_base_addr;
174 uint64_t zfb_size_in_byte;
175 enum frame_buffer_mode fb_mode;
176};
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400177
Harry Wentland45622362017-09-12 15:58:20 -0400178struct dc_init_data {
179 struct hw_asic_id asic_id;
180 void *driver; /* ctx */
181 struct cgs_device *cgs_device;
182
183 int num_virtual_links;
184 /*
185 * If 'vbios_override' not NULL, it will be called instead
186 * of the real VBIOS. Intended use is Diagnostics on FPGA.
187 */
188 struct dc_bios *vbios_override;
189 enum dce_environment dce_environment;
190
191 struct dc_config flags;
192};
193
194struct dc *dc_create(const struct dc_init_data *init_params);
195
196void dc_destroy(struct dc **dc);
197
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400198bool dc_init_dchub(struct dc *dc, struct dchub_init_data *dh_data);
Alex Deucher2c8ad2d2017-06-15 16:20:24 -0400199
Harry Wentland45622362017-09-12 15:58:20 -0400200/*******************************************************************************
201 * Surface Interfaces
202 ******************************************************************************/
203
204enum {
Anthony Koofb735a92016-12-13 13:59:41 -0500205 TRANSFER_FUNC_POINTS = 1025
Harry Wentland45622362017-09-12 15:58:20 -0400206};
207
Andrew Wong1646a6fe2016-12-22 15:41:30 -0500208struct dc_hdr_static_metadata {
Amy Zhang70063a52017-02-16 11:04:48 -0500209 bool hdr_supported;
Andrew Wong1646a6fe2016-12-22 15:41:30 -0500210 bool is_hdr;
211
212 /* display chromaticities and white point in units of 0.00001 */
213 unsigned int chromaticity_green_x;
214 unsigned int chromaticity_green_y;
215 unsigned int chromaticity_blue_x;
216 unsigned int chromaticity_blue_y;
217 unsigned int chromaticity_red_x;
218 unsigned int chromaticity_red_y;
219 unsigned int chromaticity_white_point_x;
220 unsigned int chromaticity_white_point_y;
221
222 uint32_t min_luminance;
223 uint32_t max_luminance;
224 uint32_t maximum_content_light_level;
225 uint32_t maximum_frame_average_light_level;
226};
227
Anthony Koofb735a92016-12-13 13:59:41 -0500228enum dc_transfer_func_type {
229 TF_TYPE_PREDEFINED,
230 TF_TYPE_DISTRIBUTED_POINTS,
Amy Zhang70063a52017-02-16 11:04:48 -0500231 TF_TYPE_BYPASS
Anthony Koofb735a92016-12-13 13:59:41 -0500232};
233
234struct dc_transfer_func_distributed_points {
Amy Zhangfcd2f4b2017-01-05 17:12:20 -0500235 struct fixed31_32 red[TRANSFER_FUNC_POINTS];
236 struct fixed31_32 green[TRANSFER_FUNC_POINTS];
237 struct fixed31_32 blue[TRANSFER_FUNC_POINTS];
238
Anthony Koofb735a92016-12-13 13:59:41 -0500239 uint16_t end_exponent;
Amy Zhangfcd2f4b2017-01-05 17:12:20 -0500240 uint16_t x_point_at_y1_red;
241 uint16_t x_point_at_y1_green;
242 uint16_t x_point_at_y1_blue;
Anthony Koofb735a92016-12-13 13:59:41 -0500243};
244
245enum dc_transfer_func_predefined {
246 TRANSFER_FUNCTION_SRGB,
247 TRANSFER_FUNCTION_BT709,
Anthony Koo90e508b2016-12-15 12:09:46 -0500248 TRANSFER_FUNCTION_PQ,
Anthony Koofb735a92016-12-13 13:59:41 -0500249 TRANSFER_FUNCTION_LINEAR,
250};
251
252struct dc_transfer_func {
253 enum dc_transfer_func_type type;
254 enum dc_transfer_func_predefined tf;
255 struct dc_transfer_func_distributed_points tf_pts;
256};
257
Harry Wentland45622362017-09-12 15:58:20 -0400258struct dc_surface {
259 bool visible;
260 bool flip_immediate;
261 struct dc_plane_address address;
262
263 struct scaling_taps scaling_quality;
264 struct rect src_rect;
265 struct rect dst_rect;
266 struct rect clip_rect;
267
268 union plane_size plane_size;
269 union dc_tiling_info tiling_info;
270 struct dc_plane_dcc_param dcc;
271 enum dc_color_space color_space;
272
273 enum surface_pixel_format format;
274 enum dc_rotation_angle rotation;
275 bool horizontal_mirror;
276 enum plane_stereo_format stereo_format;
277
Andrew Wong1646a6fe2016-12-22 15:41:30 -0500278 struct dc_hdr_static_metadata hdr_static_ctx;
279
Harry Wentland45622362017-09-12 15:58:20 -0400280 const struct dc_gamma *gamma_correction;
Anthony Koofb735a92016-12-13 13:59:41 -0500281 const struct dc_transfer_func *in_transfer_func;
Harry Wentland45622362017-09-12 15:58:20 -0400282};
283
284struct dc_plane_info {
285 union plane_size plane_size;
286 union dc_tiling_info tiling_info;
Leon Elazar9cd09bf2016-12-19 12:00:05 -0500287 struct dc_plane_dcc_param dcc;
Harry Wentland45622362017-09-12 15:58:20 -0400288 enum surface_pixel_format format;
289 enum dc_rotation_angle rotation;
290 bool horizontal_mirror;
291 enum plane_stereo_format stereo_format;
292 enum dc_color_space color_space; /*todo: wrong place, fits in scaling info*/
293 bool visible;
294};
295
296struct dc_scaling_info {
297 struct rect src_rect;
298 struct rect dst_rect;
299 struct rect clip_rect;
300 struct scaling_taps scaling_quality;
301};
302
303struct dc_surface_update {
304 const struct dc_surface *surface;
305
306 /* isr safe update parameters. null means no updates */
307 struct dc_flip_addrs *flip_addr;
308 struct dc_plane_info *plane_info;
309 struct dc_scaling_info *scaling_info;
310 /* following updates require alloc/sleep/spin that is not isr safe,
311 * null means no updates
312 */
Anthony Koofb735a92016-12-13 13:59:41 -0500313 /* gamma TO BE REMOVED */
Harry Wentland45622362017-09-12 15:58:20 -0400314 struct dc_gamma *gamma;
Andrew Wong1646a6fe2016-12-22 15:41:30 -0500315 struct dc_hdr_static_metadata *hdr_static_metadata;
Anthony Koofb735a92016-12-13 13:59:41 -0500316 struct dc_transfer_func *in_transfer_func;
317 struct dc_transfer_func *out_transfer_func;
318
Harry Wentland45622362017-09-12 15:58:20 -0400319
320};
321/*
322 * This structure is filled in by dc_surface_get_status and contains
323 * the last requested address and the currently active address so the called
324 * can determine if there are any outstanding flips
325 */
326struct dc_surface_status {
327 struct dc_plane_address requested_address;
328 struct dc_plane_address current_address;
329 bool is_flip_pending;
330};
331
332/*
333 * Create a new surface with default parameters;
334 */
335struct dc_surface *dc_create_surface(const struct dc *dc);
336const struct dc_surface_status *dc_surface_get_status(
337 const struct dc_surface *dc_surface);
338
339void dc_surface_retain(const struct dc_surface *dc_surface);
340void dc_surface_release(const struct dc_surface *dc_surface);
341
Amy Zhang89e89632016-12-12 10:32:24 -0500342void dc_gamma_retain(const struct dc_gamma *dc_gamma);
Yongqiang Sunaff20232016-12-23 10:18:08 -0500343void dc_gamma_release(const struct dc_gamma **dc_gamma);
Harry Wentland45622362017-09-12 15:58:20 -0400344struct dc_gamma *dc_create_gamma(void);
345
Anthony Koofb735a92016-12-13 13:59:41 -0500346void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf);
347void dc_transfer_func_release(const struct dc_transfer_func *dc_tf);
Anthony Koo90e508b2016-12-15 12:09:46 -0500348struct dc_transfer_func *dc_create_transfer_func(void);
Anthony Koofb735a92016-12-13 13:59:41 -0500349
Harry Wentland45622362017-09-12 15:58:20 -0400350/*
351 * This structure holds a surface address. There could be multiple addresses
352 * in cases such as Stereo 3D, Planar YUV, etc. Other per-flip attributes such
353 * as frame durations and DCC format can also be set.
354 */
355struct dc_flip_addrs {
356 struct dc_plane_address address;
357 bool flip_immediate;
Harry Wentland45622362017-09-12 15:58:20 -0400358 /* TODO: add flip duration for FreeSync */
359};
360
361/*
362 * Optimized flip address update function.
363 *
364 * After this call:
365 * Surface addresses and flip attributes are programmed.
366 * Surface flip occur at next configured time (h_sync or v_sync flip)
367 */
368void dc_flip_surface_addrs(struct dc *dc,
369 const struct dc_surface *const surfaces[],
370 struct dc_flip_addrs flip_addrs[],
371 uint32_t count);
372
373/*
Aric Cyrab2541b2016-12-29 15:27:12 -0500374 * Set up surface attributes and associate to a stream
375 * The surfaces parameter is an absolute set of all surface active for the stream.
376 * If no surfaces are provided, the stream will be blanked; no memory read.
Harry Wentland45622362017-09-12 15:58:20 -0400377 * Any flip related attribute changes must be done through this interface.
378 *
379 * After this call:
Aric Cyrab2541b2016-12-29 15:27:12 -0500380 * Surfaces attributes are programmed and configured to be composed into stream.
Harry Wentland45622362017-09-12 15:58:20 -0400381 * This does not trigger a flip. No surface address is programmed.
382 */
383
Aric Cyrab2541b2016-12-29 15:27:12 -0500384bool dc_commit_surfaces_to_stream(
Harry Wentland45622362017-09-12 15:58:20 -0400385 struct dc *dc,
386 const struct dc_surface **dc_surfaces,
387 uint8_t surface_count,
Aric Cyrab2541b2016-12-29 15:27:12 -0500388 const struct dc_stream *stream);
Harry Wentland45622362017-09-12 15:58:20 -0400389
Aric Cyrab2541b2016-12-29 15:27:12 -0500390bool dc_pre_update_surfaces_to_stream(
Harry Wentland45622362017-09-12 15:58:20 -0400391 struct dc *dc,
392 const struct dc_surface *const *new_surfaces,
393 uint8_t new_surface_count,
Aric Cyrab2541b2016-12-29 15:27:12 -0500394 const struct dc_stream *stream);
Harry Wentland45622362017-09-12 15:58:20 -0400395
Aric Cyrab2541b2016-12-29 15:27:12 -0500396bool dc_post_update_surfaces_to_stream(
Harry Wentland45622362017-09-12 15:58:20 -0400397 struct dc *dc);
398
Aric Cyrab2541b2016-12-29 15:27:12 -0500399void dc_update_surfaces_for_stream(struct dc *dc, struct dc_surface_update *updates,
400 int surface_count, const struct dc_stream *stream);
Harry Wentland45622362017-09-12 15:58:20 -0400401
Leon Elazar5869b0f2017-03-01 12:30:11 -0500402enum surface_update_type {
403 UPDATE_TYPE_FAST, /* super fast, safe to execute in isr */
404 UPDATE_TYPE_MED, /* a lot of programming needed. may need to alloc */
405 UPDATE_TYPE_FULL, /* may need to shuffle resources */
406};
407
Harry Wentland45622362017-09-12 15:58:20 -0400408/*******************************************************************************
409 * Stream Interfaces
410 ******************************************************************************/
411struct dc_stream {
412 const struct dc_sink *sink;
413 struct dc_crtc_timing timing;
Sylvia Tsai8b320762017-04-04 17:28:17 -0400414 enum signal_type output_signal;
Harry Wentland45622362017-09-12 15:58:20 -0400415
416 enum dc_color_space output_color_space;
417
Aric Cyrab2541b2016-12-29 15:27:12 -0500418 struct rect src; /* composition area */
Harry Wentland45622362017-09-12 15:58:20 -0400419 struct rect dst; /* stream addressable area */
420
421 struct audio_info audio_info;
422
423 bool ignore_msa_timing_param;
424
425 struct freesync_context freesync_ctx;
426
Anthony Koo90e508b2016-12-15 12:09:46 -0500427 const struct dc_transfer_func *out_transfer_func;
Harry Wentland45622362017-09-12 15:58:20 -0400428 struct colorspace_transform gamut_remap_matrix;
429 struct csc_transform csc_color_matrix;
Anthony Koo90e508b2016-12-15 12:09:46 -0500430
431 /* TODO: dithering */
Harry Wentland45622362017-09-12 15:58:20 -0400432 /* TODO: custom INFO packets */
433 /* TODO: ABM info (DMCU) */
434 /* TODO: PSR info */
435 /* TODO: CEA VIC */
436};
437
Leon Elazara783e7b2017-03-09 14:38:15 -0500438struct dc_stream_update {
439
440 struct rect src;
441
442 struct rect dst;
443
444};
445
446
447/*
448 * Setup stream attributes if no stream updates are provided
449 * there will be no impact on the stream parameters
450 *
451 * Set up surface attributes and associate to a stream
452 * The surfaces parameter is an absolute set of all surface active for the stream.
453 * If no surfaces are provided, the stream will be blanked; no memory read.
454 * Any flip related attribute changes must be done through this interface.
455 *
456 * After this call:
457 * Surfaces attributes are programmed and configured to be composed into stream.
458 * This does not trigger a flip. No surface address is programmed.
459 *
460 */
461
462void dc_update_surfaces_and_stream(struct dc *dc,
463 struct dc_surface_update *surface_updates, int surface_count,
464 const struct dc_stream *dc_stream,
465 struct dc_stream_update *stream_update);
466
Aric Cyrab2541b2016-12-29 15:27:12 -0500467/*
468 * Log the current stream state.
469 */
470void dc_stream_log(
471 const struct dc_stream *stream,
472 struct dal_logger *dc_logger,
473 enum dc_log_type log_type);
474
475uint8_t dc_get_current_stream_count(const struct dc *dc);
476struct dc_stream *dc_get_stream_at_index(const struct dc *dc, uint8_t i);
477
478/*
479 * Return the current frame counter.
480 */
481uint32_t dc_stream_get_vblank_counter(const struct dc_stream *stream);
482
483/* TODO: Return parsed values rather than direct register read
484 * This has a dependency on the caller (amdgpu_get_crtc_scanoutpos)
485 * being refactored properly to be dce-specific
486 */
487uint32_t dc_stream_get_scanoutpos(
488 const struct dc_stream *stream, uint32_t *vbl, uint32_t *position);
489
490/*
491 * Structure to store surface/stream associations for validation
492 */
493struct dc_validation_set {
494 const struct dc_stream *stream;
495 const struct dc_surface *surfaces[MAX_SURFACES];
496 uint8_t surface_count;
497};
498
499/*
500 * This function takes a set of resources and checks that they are cofunctional.
501 *
502 * After this call:
503 * No hardware is programmed for call. Only validation is done.
504 */
505bool dc_validate_resources(
506 const struct dc *dc,
507 const struct dc_validation_set set[],
508 uint8_t set_count);
509
510/*
511 * This function takes a stream and checks if it is guaranteed to be supported.
512 * Guaranteed means that MAX_COFUNC similar streams are supported.
513 *
514 * After this call:
515 * No hardware is programmed for call. Only validation is done.
516 */
517
518bool dc_validate_guaranteed(
519 const struct dc *dc,
520 const struct dc_stream *stream);
521
522/*
523 * Set up streams and links associated to drive sinks
524 * The streams parameter is an absolute set of all active streams.
525 *
526 * After this call:
527 * Phy, Encoder, Timing Generator are programmed and enabled.
528 * New streams are enabled with blank stream; no memory read.
529 */
530bool dc_commit_streams(
531 struct dc *dc,
532 const struct dc_stream *streams[],
533 uint8_t stream_count);
534
Harry Wentland45622362017-09-12 15:58:20 -0400535/**
536 * Create a new default stream for the requested sink
537 */
538struct dc_stream *dc_create_stream_for_sink(const struct dc_sink *dc_sink);
539
540void dc_stream_retain(const struct dc_stream *dc_stream);
541void dc_stream_release(const struct dc_stream *dc_stream);
542
543struct dc_stream_status {
Aric Cyrab2541b2016-12-29 15:27:12 -0500544 int primary_otg_inst;
545 int surface_count;
546 const struct dc_surface *surfaces[MAX_SURFACE_NUM];
547
Harry Wentland45622362017-09-12 15:58:20 -0400548 /*
549 * link this stream passes through
550 */
551 const struct dc_link *link;
552};
553
554const struct dc_stream_status *dc_stream_get_status(
555 const struct dc_stream *dc_stream);
556
Leon Elazar5869b0f2017-03-01 12:30:11 -0500557enum surface_update_type dc_check_update_surfaces_for_stream(
558 struct dc *dc,
559 struct dc_surface_update *updates,
560 int surface_count,
Leon Elazaree8f63e2017-03-14 11:54:31 -0400561 struct dc_stream_update *stream_update,
Leon Elazar5869b0f2017-03-01 12:30:11 -0500562 const struct dc_stream_status *stream_status);
563
Harry Wentland45622362017-09-12 15:58:20 -0400564/*******************************************************************************
565 * Link Interfaces
566 ******************************************************************************/
567
568/*
569 * A link contains one or more sinks and their connected status.
570 * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
571 */
572struct dc_link {
573 const struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
574 unsigned int sink_count;
575 const struct dc_sink *local_sink;
576 unsigned int link_index;
577 enum dc_connection_type type;
578 enum signal_type connector_signal;
579 enum dc_irq_source irq_source_hpd;
580 enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */
581 /* caps is the same as reported_link_cap. link_traing use
582 * reported_link_cap. Will clean up. TODO
583 */
584 struct dc_link_settings reported_link_cap;
585 struct dc_link_settings verified_link_cap;
586 struct dc_link_settings max_link_setting;
587 struct dc_link_settings cur_link_settings;
588 struct dc_lane_settings cur_lane_setting;
589
590 uint8_t ddc_hw_inst;
591 uint8_t link_enc_hw_inst;
592
593 struct psr_caps psr_caps;
594 bool test_pattern_enabled;
595 union compliance_test_state compliance_test_state;
Andrey Grodzovsky9fb8de72017-02-14 13:50:17 -0500596
597 void *priv;
Andrey Grodzovsky7c7f5b12017-03-28 16:57:52 -0400598 bool aux_mode;
Harry Wentland45622362017-09-12 15:58:20 -0400599};
600
601struct dpcd_caps {
602 union dpcd_rev dpcd_rev;
603 union max_lane_count max_ln_count;
604 union max_down_spread max_down_spread;
605
606 /* dongle type (DP converter, CV smart dongle) */
607 enum display_dongle_type dongle_type;
608 /* Dongle's downstream count. */
609 union sink_count sink_count;
610 /* If dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER,
611 indicates 'Frame Sequential-to-lllFrame Pack' conversion capability.*/
612 bool is_dp_hdmi_s3d_converter;
613
614 bool allow_invalid_MSA_timing_param;
615 bool panel_mode_edp;
616 uint32_t sink_dev_id;
617 uint32_t branch_dev_id;
618 int8_t branch_dev_name[6];
619 int8_t branch_hw_revision;
620};
621
622struct dc_link_status {
623 struct dpcd_caps *dpcd_caps;
624};
625
626const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link);
627
628/*
629 * Return an enumerated dc_link. dc_link order is constant and determined at
630 * boot time. They cannot be created or destroyed.
631 * Use dc_get_caps() to get number of links.
632 */
633const struct dc_link *dc_get_link_at_index(const struct dc *dc, uint32_t link_index);
634
635/* Return id of physical connector represented by a dc_link at link_index.*/
636const struct graphics_object_id dc_get_link_id_at_index(
637 struct dc *dc, uint32_t link_index);
638
639/* Set backlight level of an embedded panel (eDP, LVDS). */
640bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level,
641 uint32_t frame_ramp, const struct dc_stream *stream);
642
Harry Wentland45622362017-09-12 15:58:20 -0400643bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable);
644
645bool dc_link_setup_psr(const struct dc_link *dc_link,
646 const struct dc_stream *stream);
647
648/* Request DC to detect if there is a Panel connected.
649 * boot - If this call is during initial boot.
650 * Return false for any type of detection failure or MST detection
651 * true otherwise. True meaning further action is required (status update
652 * and OS notification).
653 */
654bool dc_link_detect(const struct dc_link *dc_link, bool boot);
655
656/* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt).
657 * Return:
658 * true - Downstream port status changed. DM should call DC to do the
659 * detection.
660 * false - no change in Downstream port status. No further action required
661 * from DM. */
662bool dc_link_handle_hpd_rx_irq(const struct dc_link *dc_link);
663
664struct dc_sink_init_data;
665
666struct dc_sink *dc_link_add_remote_sink(
667 const struct dc_link *dc_link,
668 const uint8_t *edid,
669 int len,
670 struct dc_sink_init_data *init_data);
671
672void dc_link_remove_remote_sink(
673 const struct dc_link *link,
674 const struct dc_sink *sink);
675
676/* Used by diagnostics for virtual link at the moment */
677void dc_link_set_sink(const struct dc_link *link, struct dc_sink *sink);
678
679void dc_link_dp_set_drive_settings(
680 struct dc_link *link,
681 struct link_training_settings *lt_settings);
682
683bool dc_link_dp_perform_link_training(
684 struct dc_link *link,
685 const struct dc_link_settings *link_setting,
686 bool skip_video_pattern);
687
688void dc_link_dp_enable_hpd(const struct dc_link *link);
689
690void dc_link_dp_disable_hpd(const struct dc_link *link);
691
692bool dc_link_dp_set_test_pattern(
693 const struct dc_link *link,
694 enum dp_test_pattern test_pattern,
695 const struct link_training_settings *p_link_settings,
696 const unsigned char *p_custom_pattern,
697 unsigned int cust_pattern_size);
698
699/*******************************************************************************
700 * Sink Interfaces - A sink corresponds to a display output device
701 ******************************************************************************/
702
xhdu8c895312017-03-21 11:05:32 -0400703struct dc_container_id {
704 // 128bit GUID in binary form
705 unsigned char guid[16];
706 // 8 byte port ID -> ELD.PortID
707 unsigned int portId[2];
708 // 128bit GUID in binary formufacturer name -> ELD.ManufacturerName
709 unsigned short manufacturerName;
710 // 2 byte product code -> ELD.ProductCode
711 unsigned short productCode;
712};
713
Harry Wentland45622362017-09-12 15:58:20 -0400714/*
715 * The sink structure contains EDID and other display device properties
716 */
717struct dc_sink {
718 enum signal_type sink_signal;
719 struct dc_edid dc_edid; /* raw edid */
720 struct dc_edid_caps edid_caps; /* parse display caps */
xhdu8c895312017-03-21 11:05:32 -0400721 struct dc_container_id *dc_container_id;
Zeyu Fan4a9a5d62017-03-07 11:48:50 -0500722 uint32_t dongle_max_pix_clk;
723 bool converter_disable_audio;
Andrey Grodzovsky5c4e980642017-02-14 15:47:24 -0500724 void *priv;
Harry Wentland45622362017-09-12 15:58:20 -0400725};
726
727void dc_sink_retain(const struct dc_sink *sink);
728void dc_sink_release(const struct dc_sink *sink);
729
730const struct audio **dc_get_audios(struct dc *dc);
731
732struct dc_sink_init_data {
733 enum signal_type sink_signal;
734 const struct dc_link *link;
735 uint32_t dongle_max_pix_clk;
736 bool converter_disable_audio;
737};
738
739struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params);
xhdu8c895312017-03-21 11:05:32 -0400740bool dc_sink_get_container_id(struct dc_sink *dc_sink, struct dc_container_id *container_id);
741bool dc_sink_set_container_id(struct dc_sink *dc_sink, const struct dc_container_id *container_id);
Harry Wentland45622362017-09-12 15:58:20 -0400742
743/*******************************************************************************
Aric Cyrab2541b2016-12-29 15:27:12 -0500744 * Cursor interfaces - To manages the cursor within a stream
Harry Wentland45622362017-09-12 15:58:20 -0400745 ******************************************************************************/
746/* TODO: Deprecated once we switch to dc_set_cursor_position */
Aric Cyrab2541b2016-12-29 15:27:12 -0500747bool dc_stream_set_cursor_attributes(
748 const struct dc_stream *stream,
Harry Wentland45622362017-09-12 15:58:20 -0400749 const struct dc_cursor_attributes *attributes);
750
Aric Cyrab2541b2016-12-29 15:27:12 -0500751bool dc_stream_set_cursor_position(
752 const struct dc_stream *stream,
Yongqiang Sundabb3972017-03-27 09:59:38 -0400753 struct dc_cursor_position *position);
Harry Wentland45622362017-09-12 15:58:20 -0400754
755/* Newer interfaces */
756struct dc_cursor {
757 struct dc_plane_address address;
758 struct dc_cursor_attributes attributes;
759};
760
Harry Wentland45622362017-09-12 15:58:20 -0400761/*******************************************************************************
762 * Interrupt interfaces
763 ******************************************************************************/
764enum dc_irq_source dc_interrupt_to_irq_source(
765 struct dc *dc,
766 uint32_t src_id,
767 uint32_t ext_id);
768void dc_interrupt_set(const struct dc *dc, enum dc_irq_source src, bool enable);
769void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src);
770enum dc_irq_source dc_get_hpd_irq_source_at_index(
771 struct dc *dc, uint32_t link_index);
772
773/*******************************************************************************
774 * Power Interfaces
775 ******************************************************************************/
776
777void dc_set_power_state(
778 struct dc *dc,
Andrey Grodzovskya3621482017-04-20 15:59:25 -0400779 enum dc_acpi_cm_power_state power_state);
Harry Wentland45622362017-09-12 15:58:20 -0400780void dc_resume(const struct dc *dc);
781
782/*******************************************************************************
783 * DDC Interfaces
784 ******************************************************************************/
785
786const struct ddc_service *dc_get_ddc_at_index(
787 struct dc *dc, uint32_t link_index);
788
789/*
790 * DPCD access interfaces
791 */
792
Andrey Grodzovsky7c7f5b12017-03-28 16:57:52 -0400793bool dc_read_aux_dpcd(
Harry Wentland45622362017-09-12 15:58:20 -0400794 struct dc *dc,
795 uint32_t link_index,
796 uint32_t address,
797 uint8_t *data,
798 uint32_t size);
799
Andrey Grodzovsky7c7f5b12017-03-28 16:57:52 -0400800bool dc_write_aux_dpcd(
Harry Wentland45622362017-09-12 15:58:20 -0400801 struct dc *dc,
802 uint32_t link_index,
803 uint32_t address,
804 const uint8_t *data,
Zeyu Fan2b230ea2017-02-16 16:15:30 -0500805 uint32_t size);
806
Andrey Grodzovsky7c7f5b12017-03-28 16:57:52 -0400807bool dc_read_aux_i2c(
808 struct dc *dc,
809 uint32_t link_index,
810 enum i2c_mot_mode mot,
811 uint32_t address,
812 uint8_t *data,
813 uint32_t size);
814
815bool dc_write_aux_i2c(
816 struct dc *dc,
817 uint32_t link_index,
818 enum i2c_mot_mode mot,
819 uint32_t address,
820 const uint8_t *data,
821 uint32_t size);
822
Zeyu Fan2b230ea2017-02-16 16:15:30 -0500823bool dc_query_ddc_data(
824 struct dc *dc,
825 uint32_t link_index,
826 uint32_t address,
827 uint8_t *write_buf,
828 uint32_t write_size,
829 uint8_t *read_buf,
830 uint32_t read_size);
Harry Wentland45622362017-09-12 15:58:20 -0400831
832bool dc_submit_i2c(
833 struct dc *dc,
834 uint32_t link_index,
835 struct i2c_command *cmd);
836
Anthony Koo5e7773a2017-01-23 16:55:20 -0500837
Harry Wentland45622362017-09-12 15:58:20 -0400838#endif /* DC_INTERFACE_H_ */