Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 1 | /* |
| 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 Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 30 | #include "grph_object_defs.h" |
| 31 | #include "logger_types.h" |
| 32 | #include "gpio_types.h" |
| 33 | #include "link_service_types.h" |
| 34 | |
| 35 | #define MAX_TARGETS 6 |
Harry Wentland | 091a97e | 2016-12-06 12:25:52 -0500 | [diff] [blame] | 36 | #define MAX_SURFACES 3 |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 37 | #define MAX_SINKS_PER_LINK 4 |
| 38 | |
| 39 | /******************************************************************************* |
| 40 | * Display Core Interfaces |
| 41 | ******************************************************************************/ |
| 42 | |
| 43 | struct dc_caps { |
| 44 | uint32_t max_targets; |
| 45 | uint32_t max_links; |
| 46 | uint32_t max_audios; |
| 47 | uint32_t max_slave_planes; |
| 48 | uint32_t max_downscale_ratio; |
| 49 | uint32_t i2c_speed_in_khz; |
| 50 | }; |
| 51 | |
| 52 | |
| 53 | struct dc_dcc_surface_param { |
| 54 | enum surface_pixel_format format; |
| 55 | struct dc_size surface_size; |
| 56 | enum dc_scan_direction scan; |
| 57 | }; |
| 58 | |
| 59 | struct dc_dcc_setting { |
| 60 | unsigned int max_compressed_blk_size; |
| 61 | unsigned int max_uncompressed_blk_size; |
| 62 | bool independent_64b_blks; |
| 63 | }; |
| 64 | |
| 65 | struct dc_surface_dcc_cap { |
| 66 | bool capable; |
| 67 | bool const_color_support; |
| 68 | |
| 69 | union { |
| 70 | struct { |
| 71 | struct dc_dcc_setting rgb; |
| 72 | } grph; |
| 73 | |
| 74 | struct { |
| 75 | struct dc_dcc_setting luma; |
| 76 | struct dc_dcc_setting chroma; |
| 77 | } video; |
| 78 | }; |
| 79 | }; |
| 80 | |
| 81 | /* Forward declaration*/ |
| 82 | struct dc; |
| 83 | struct dc_surface; |
| 84 | struct validate_context; |
| 85 | |
| 86 | struct dc_cap_funcs { |
| 87 | int i; |
| 88 | }; |
| 89 | |
| 90 | struct dc_stream_funcs { |
| 91 | bool (*adjust_vmin_vmax)(struct dc *dc, |
| 92 | const struct dc_stream **stream, |
| 93 | int num_streams, |
| 94 | int vmin, |
| 95 | int vmax); |
| 96 | |
| 97 | void (*stream_update_scaling)(const struct dc *dc, |
| 98 | const struct dc_stream *dc_stream, |
| 99 | const struct rect *src, |
| 100 | const struct rect *dst); |
| 101 | bool (*set_gamut_remap)(struct dc *dc, |
| 102 | const struct dc_stream **stream, int num_streams); |
| 103 | bool (*set_backlight)(struct dc *dc, unsigned int backlight_level, |
| 104 | unsigned int frame_ramp, const struct dc_stream *stream); |
| 105 | bool (*init_dmcu_backlight_settings)(struct dc *dc); |
| 106 | bool (*set_abm_level)(struct dc *dc, unsigned int abm_level); |
| 107 | bool (*set_psr_enable)(struct dc *dc, bool enable); |
| 108 | bool (*setup_psr)(struct dc *dc, const struct dc_stream *stream); |
| 109 | }; |
| 110 | |
| 111 | struct link_training_settings; |
| 112 | |
| 113 | struct dc_link_funcs { |
| 114 | void (*set_drive_settings)(struct dc *dc, |
Hersen Wu | bf5cda3 | 2017-01-04 10:22:35 -0500 | [diff] [blame^] | 115 | struct link_training_settings *lt_settings, |
| 116 | const struct dc_link *link); |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 117 | 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 Fan | 8863916 | 2016-12-23 16:53:12 -0500 | [diff] [blame] | 121 | struct dc_link_settings *link_setting, |
| 122 | const struct dc_link *link); |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 123 | 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. */ |
| 134 | struct dc_config { |
| 135 | bool gpu_vm_support; |
| 136 | bool disable_disp_pll_sharing; |
| 137 | }; |
| 138 | |
| 139 | struct dc_debug { |
| 140 | bool surface_visual_confirm; |
| 141 | bool max_disp_clk; |
| 142 | bool target_trace; |
| 143 | bool surface_trace; |
Yongqiang Sun | 9474980 | 2016-12-08 09:47:11 -0500 | [diff] [blame] | 144 | bool timing_trace; |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 145 | bool validation_trace; |
| 146 | bool disable_stutter; |
| 147 | bool disable_dcc; |
| 148 | bool disable_dfs_bypass; |
| 149 | bool disable_power_gate; |
| 150 | bool disable_clock_gate; |
Yongqiang Sun | aa66df5 | 2016-12-15 10:50:48 -0500 | [diff] [blame] | 151 | bool disable_dmcu; |
Tony Cheng | dc0bcaf | 2016-12-23 07:12:19 -0500 | [diff] [blame] | 152 | bool disable_hdmi_deep_color; |
Tony Cheng | e12078c | 2016-12-23 07:20:53 -0500 | [diff] [blame] | 153 | bool disable_color_module; |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | struct dc { |
| 157 | struct dc_caps caps; |
| 158 | struct dc_cap_funcs cap_funcs; |
| 159 | struct dc_stream_funcs stream_funcs; |
| 160 | struct dc_link_funcs link_funcs; |
| 161 | struct dc_config config; |
| 162 | struct dc_debug debug; |
| 163 | }; |
| 164 | |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 165 | struct dc_init_data { |
| 166 | struct hw_asic_id asic_id; |
| 167 | void *driver; /* ctx */ |
| 168 | struct cgs_device *cgs_device; |
| 169 | |
| 170 | int num_virtual_links; |
| 171 | /* |
| 172 | * If 'vbios_override' not NULL, it will be called instead |
| 173 | * of the real VBIOS. Intended use is Diagnostics on FPGA. |
| 174 | */ |
| 175 | struct dc_bios *vbios_override; |
| 176 | enum dce_environment dce_environment; |
| 177 | |
| 178 | struct dc_config flags; |
| 179 | }; |
| 180 | |
| 181 | struct dc *dc_create(const struct dc_init_data *init_params); |
| 182 | |
| 183 | void dc_destroy(struct dc **dc); |
| 184 | |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 185 | /******************************************************************************* |
| 186 | * Surface Interfaces |
| 187 | ******************************************************************************/ |
| 188 | |
| 189 | enum { |
Anthony Koo | fb735a9 | 2016-12-13 13:59:41 -0500 | [diff] [blame] | 190 | TRANSFER_FUNC_POINTS = 1025 |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 191 | }; |
| 192 | |
Andrew Wong | 1646a6fe | 2016-12-22 15:41:30 -0500 | [diff] [blame] | 193 | struct dc_hdr_static_metadata { |
| 194 | bool is_hdr; |
| 195 | |
| 196 | /* display chromaticities and white point in units of 0.00001 */ |
| 197 | unsigned int chromaticity_green_x; |
| 198 | unsigned int chromaticity_green_y; |
| 199 | unsigned int chromaticity_blue_x; |
| 200 | unsigned int chromaticity_blue_y; |
| 201 | unsigned int chromaticity_red_x; |
| 202 | unsigned int chromaticity_red_y; |
| 203 | unsigned int chromaticity_white_point_x; |
| 204 | unsigned int chromaticity_white_point_y; |
| 205 | |
| 206 | uint32_t min_luminance; |
| 207 | uint32_t max_luminance; |
| 208 | uint32_t maximum_content_light_level; |
| 209 | uint32_t maximum_frame_average_light_level; |
| 210 | }; |
| 211 | |
Anthony Koo | fb735a9 | 2016-12-13 13:59:41 -0500 | [diff] [blame] | 212 | enum dc_transfer_func_type { |
| 213 | TF_TYPE_PREDEFINED, |
| 214 | TF_TYPE_DISTRIBUTED_POINTS, |
| 215 | }; |
| 216 | |
| 217 | struct dc_transfer_func_distributed_points { |
| 218 | uint16_t red[TRANSFER_FUNC_POINTS]; |
| 219 | uint16_t green[TRANSFER_FUNC_POINTS]; |
| 220 | uint16_t blue[TRANSFER_FUNC_POINTS]; |
| 221 | uint16_t end_exponent; |
| 222 | uint16_t x_point_at_y1; |
| 223 | }; |
| 224 | |
| 225 | enum dc_transfer_func_predefined { |
| 226 | TRANSFER_FUNCTION_SRGB, |
| 227 | TRANSFER_FUNCTION_BT709, |
Anthony Koo | 90e508b | 2016-12-15 12:09:46 -0500 | [diff] [blame] | 228 | TRANSFER_FUNCTION_PQ, |
Anthony Koo | fb735a9 | 2016-12-13 13:59:41 -0500 | [diff] [blame] | 229 | TRANSFER_FUNCTION_LINEAR, |
| 230 | }; |
| 231 | |
| 232 | struct dc_transfer_func { |
| 233 | enum dc_transfer_func_type type; |
| 234 | enum dc_transfer_func_predefined tf; |
| 235 | struct dc_transfer_func_distributed_points tf_pts; |
| 236 | }; |
| 237 | |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 238 | struct dc_surface { |
| 239 | bool visible; |
| 240 | bool flip_immediate; |
| 241 | struct dc_plane_address address; |
| 242 | |
| 243 | struct scaling_taps scaling_quality; |
| 244 | struct rect src_rect; |
| 245 | struct rect dst_rect; |
| 246 | struct rect clip_rect; |
| 247 | |
| 248 | union plane_size plane_size; |
| 249 | union dc_tiling_info tiling_info; |
| 250 | struct dc_plane_dcc_param dcc; |
| 251 | enum dc_color_space color_space; |
| 252 | |
| 253 | enum surface_pixel_format format; |
| 254 | enum dc_rotation_angle rotation; |
| 255 | bool horizontal_mirror; |
| 256 | enum plane_stereo_format stereo_format; |
| 257 | |
Andrew Wong | 1646a6fe | 2016-12-22 15:41:30 -0500 | [diff] [blame] | 258 | struct dc_hdr_static_metadata hdr_static_ctx; |
| 259 | |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 260 | const struct dc_gamma *gamma_correction; |
Anthony Koo | fb735a9 | 2016-12-13 13:59:41 -0500 | [diff] [blame] | 261 | const struct dc_transfer_func *in_transfer_func; |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 262 | }; |
| 263 | |
| 264 | struct dc_plane_info { |
| 265 | union plane_size plane_size; |
| 266 | union dc_tiling_info tiling_info; |
Leon Elazar | 9cd09bf | 2016-12-19 12:00:05 -0500 | [diff] [blame] | 267 | struct dc_plane_dcc_param dcc; |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 268 | enum surface_pixel_format format; |
| 269 | enum dc_rotation_angle rotation; |
| 270 | bool horizontal_mirror; |
| 271 | enum plane_stereo_format stereo_format; |
| 272 | enum dc_color_space color_space; /*todo: wrong place, fits in scaling info*/ |
| 273 | bool visible; |
| 274 | }; |
| 275 | |
| 276 | struct dc_scaling_info { |
| 277 | struct rect src_rect; |
| 278 | struct rect dst_rect; |
| 279 | struct rect clip_rect; |
| 280 | struct scaling_taps scaling_quality; |
| 281 | }; |
| 282 | |
| 283 | struct dc_surface_update { |
| 284 | const struct dc_surface *surface; |
| 285 | |
| 286 | /* isr safe update parameters. null means no updates */ |
| 287 | struct dc_flip_addrs *flip_addr; |
| 288 | struct dc_plane_info *plane_info; |
| 289 | struct dc_scaling_info *scaling_info; |
| 290 | /* following updates require alloc/sleep/spin that is not isr safe, |
| 291 | * null means no updates |
| 292 | */ |
Anthony Koo | fb735a9 | 2016-12-13 13:59:41 -0500 | [diff] [blame] | 293 | /* gamma TO BE REMOVED */ |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 294 | struct dc_gamma *gamma; |
Andrew Wong | 1646a6fe | 2016-12-22 15:41:30 -0500 | [diff] [blame] | 295 | struct dc_hdr_static_metadata *hdr_static_metadata; |
Anthony Koo | fb735a9 | 2016-12-13 13:59:41 -0500 | [diff] [blame] | 296 | struct dc_transfer_func *in_transfer_func; |
| 297 | struct dc_transfer_func *out_transfer_func; |
| 298 | |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 299 | |
| 300 | }; |
| 301 | /* |
| 302 | * This structure is filled in by dc_surface_get_status and contains |
| 303 | * the last requested address and the currently active address so the called |
| 304 | * can determine if there are any outstanding flips |
| 305 | */ |
| 306 | struct dc_surface_status { |
| 307 | struct dc_plane_address requested_address; |
| 308 | struct dc_plane_address current_address; |
| 309 | bool is_flip_pending; |
| 310 | }; |
| 311 | |
| 312 | /* |
| 313 | * Create a new surface with default parameters; |
| 314 | */ |
| 315 | struct dc_surface *dc_create_surface(const struct dc *dc); |
| 316 | const struct dc_surface_status *dc_surface_get_status( |
| 317 | const struct dc_surface *dc_surface); |
| 318 | |
| 319 | void dc_surface_retain(const struct dc_surface *dc_surface); |
| 320 | void dc_surface_release(const struct dc_surface *dc_surface); |
| 321 | |
Amy Zhang | 89e8963 | 2016-12-12 10:32:24 -0500 | [diff] [blame] | 322 | void dc_gamma_retain(const struct dc_gamma *dc_gamma); |
Yongqiang Sun | aff2023 | 2016-12-23 10:18:08 -0500 | [diff] [blame] | 323 | void dc_gamma_release(const struct dc_gamma **dc_gamma); |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 324 | struct dc_gamma *dc_create_gamma(void); |
| 325 | |
Anthony Koo | fb735a9 | 2016-12-13 13:59:41 -0500 | [diff] [blame] | 326 | void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf); |
| 327 | void dc_transfer_func_release(const struct dc_transfer_func *dc_tf); |
Anthony Koo | 90e508b | 2016-12-15 12:09:46 -0500 | [diff] [blame] | 328 | struct dc_transfer_func *dc_create_transfer_func(void); |
Anthony Koo | fb735a9 | 2016-12-13 13:59:41 -0500 | [diff] [blame] | 329 | |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 330 | /* |
| 331 | * This structure holds a surface address. There could be multiple addresses |
| 332 | * in cases such as Stereo 3D, Planar YUV, etc. Other per-flip attributes such |
| 333 | * as frame durations and DCC format can also be set. |
| 334 | */ |
| 335 | struct dc_flip_addrs { |
| 336 | struct dc_plane_address address; |
| 337 | bool flip_immediate; |
| 338 | /* TODO: DCC format info */ |
| 339 | /* TODO: add flip duration for FreeSync */ |
| 340 | }; |
| 341 | |
| 342 | /* |
| 343 | * Optimized flip address update function. |
| 344 | * |
| 345 | * After this call: |
| 346 | * Surface addresses and flip attributes are programmed. |
| 347 | * Surface flip occur at next configured time (h_sync or v_sync flip) |
| 348 | */ |
| 349 | void dc_flip_surface_addrs(struct dc *dc, |
| 350 | const struct dc_surface *const surfaces[], |
| 351 | struct dc_flip_addrs flip_addrs[], |
| 352 | uint32_t count); |
| 353 | |
| 354 | /* |
| 355 | * Set up surface attributes and associate to a target |
| 356 | * The surfaces parameter is an absolute set of all surface active for the target. |
| 357 | * If no surfaces are provided, the target will be blanked; no memory read. |
| 358 | * Any flip related attribute changes must be done through this interface. |
| 359 | * |
| 360 | * After this call: |
| 361 | * Surfaces attributes are programmed and configured to be composed into target. |
| 362 | * This does not trigger a flip. No surface address is programmed. |
| 363 | */ |
| 364 | |
| 365 | bool dc_commit_surfaces_to_target( |
| 366 | struct dc *dc, |
| 367 | const struct dc_surface **dc_surfaces, |
| 368 | uint8_t surface_count, |
| 369 | struct dc_target *dc_target); |
| 370 | |
| 371 | bool dc_pre_update_surfaces_to_target( |
| 372 | struct dc *dc, |
| 373 | const struct dc_surface *const *new_surfaces, |
| 374 | uint8_t new_surface_count, |
| 375 | struct dc_target *dc_target); |
| 376 | |
| 377 | bool dc_post_update_surfaces_to_target( |
| 378 | struct dc *dc); |
| 379 | |
| 380 | void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *updates, |
| 381 | int surface_count, struct dc_target *dc_target); |
| 382 | |
| 383 | /******************************************************************************* |
| 384 | * Target Interfaces |
| 385 | ******************************************************************************/ |
| 386 | #define MAX_STREAM_NUM 1 |
| 387 | |
| 388 | struct dc_target { |
| 389 | uint8_t stream_count; |
| 390 | const struct dc_stream *streams[MAX_STREAM_NUM]; |
| 391 | }; |
| 392 | |
| 393 | /* |
| 394 | * Target status is returned from dc_target_get_status in order to get the |
| 395 | * the IRQ source, current frame counter and currently attached surfaces. |
| 396 | */ |
| 397 | struct dc_target_status { |
| 398 | int primary_otg_inst; |
| 399 | int cur_frame_count; |
| 400 | int surface_count; |
| 401 | const struct dc_surface *surfaces[MAX_SURFACE_NUM]; |
| 402 | }; |
| 403 | |
| 404 | struct dc_target *dc_create_target_for_streams( |
| 405 | struct dc_stream *dc_streams[], |
| 406 | uint8_t stream_count); |
| 407 | |
| 408 | /* |
| 409 | * Get the current target status. |
| 410 | */ |
| 411 | const struct dc_target_status *dc_target_get_status( |
| 412 | const struct dc_target* dc_target); |
| 413 | |
| 414 | void dc_target_retain(const struct dc_target *dc_target); |
| 415 | void dc_target_release(const struct dc_target *dc_target); |
| 416 | void dc_target_log( |
| 417 | const struct dc_target *dc_target, |
| 418 | struct dal_logger *dc_logger, |
| 419 | enum dc_log_type log_type); |
| 420 | |
| 421 | uint8_t dc_get_current_target_count(const struct dc *dc); |
| 422 | struct dc_target *dc_get_target_at_index(const struct dc *dc, uint8_t i); |
| 423 | |
| 424 | bool dc_target_is_connected_to_sink( |
| 425 | const struct dc_target *dc_target, |
| 426 | const struct dc_sink *dc_sink); |
| 427 | |
| 428 | uint32_t dc_target_get_vblank_counter(const struct dc_target *dc_target); |
| 429 | |
| 430 | /* TODO: Return parsed values rather than direct register read |
| 431 | * This has a dependency on the caller (amdgpu_get_crtc_scanoutpos) |
| 432 | * being refactored properly to be dce-specific |
| 433 | */ |
| 434 | uint32_t dc_target_get_scanoutpos( |
| 435 | const struct dc_target *dc_target, |
| 436 | uint32_t *vbl, |
| 437 | uint32_t *position); |
| 438 | |
| 439 | /* |
| 440 | * Structure to store surface/target associations for validation |
| 441 | */ |
| 442 | struct dc_validation_set { |
| 443 | const struct dc_target *target; |
| 444 | const struct dc_surface *surfaces[MAX_SURFACES]; |
| 445 | uint8_t surface_count; |
| 446 | }; |
| 447 | |
| 448 | /* |
| 449 | * This function takes a set of resources and checks that they are cofunctional. |
| 450 | * |
| 451 | * After this call: |
| 452 | * No hardware is programmed for call. Only validation is done. |
| 453 | */ |
| 454 | bool dc_validate_resources( |
| 455 | const struct dc *dc, |
| 456 | const struct dc_validation_set set[], |
| 457 | uint8_t set_count); |
| 458 | |
| 459 | /* |
| 460 | * This function takes a target and checks if it is guaranteed to be supported. |
| 461 | * Guaranteed means that MAX_COFUNC*target is supported. |
| 462 | * |
| 463 | * After this call: |
| 464 | * No hardware is programmed for call. Only validation is done. |
| 465 | */ |
| 466 | |
| 467 | bool dc_validate_guaranteed( |
| 468 | const struct dc *dc, |
| 469 | const struct dc_target *dc_target); |
| 470 | |
| 471 | /* |
| 472 | * Set up streams and links associated to targets to drive sinks |
| 473 | * The targets parameter is an absolute set of all active targets. |
| 474 | * |
| 475 | * After this call: |
| 476 | * Phy, Encoder, Timing Generator are programmed and enabled. |
| 477 | * New targets are enabled with blank stream; no memory read. |
| 478 | */ |
| 479 | bool dc_commit_targets( |
| 480 | struct dc *dc, |
| 481 | struct dc_target *targets[], |
| 482 | uint8_t target_count); |
| 483 | |
| 484 | /******************************************************************************* |
| 485 | * Stream Interfaces |
| 486 | ******************************************************************************/ |
| 487 | struct dc_stream { |
| 488 | const struct dc_sink *sink; |
| 489 | struct dc_crtc_timing timing; |
| 490 | |
| 491 | enum dc_color_space output_color_space; |
| 492 | |
| 493 | struct rect src; /* viewport in target space*/ |
| 494 | struct rect dst; /* stream addressable area */ |
| 495 | |
| 496 | struct audio_info audio_info; |
| 497 | |
| 498 | bool ignore_msa_timing_param; |
| 499 | |
| 500 | struct freesync_context freesync_ctx; |
| 501 | |
Anthony Koo | 90e508b | 2016-12-15 12:09:46 -0500 | [diff] [blame] | 502 | const struct dc_transfer_func *out_transfer_func; |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 503 | struct colorspace_transform gamut_remap_matrix; |
| 504 | struct csc_transform csc_color_matrix; |
Anthony Koo | 90e508b | 2016-12-15 12:09:46 -0500 | [diff] [blame] | 505 | |
| 506 | /* TODO: dithering */ |
Harry Wentland | 4562236 | 2017-09-12 15:58:20 -0400 | [diff] [blame] | 507 | /* TODO: custom INFO packets */ |
| 508 | /* TODO: ABM info (DMCU) */ |
| 509 | /* TODO: PSR info */ |
| 510 | /* TODO: CEA VIC */ |
| 511 | }; |
| 512 | |
| 513 | /** |
| 514 | * Create a new default stream for the requested sink |
| 515 | */ |
| 516 | struct dc_stream *dc_create_stream_for_sink(const struct dc_sink *dc_sink); |
| 517 | |
| 518 | void dc_stream_retain(const struct dc_stream *dc_stream); |
| 519 | void dc_stream_release(const struct dc_stream *dc_stream); |
| 520 | |
| 521 | struct dc_stream_status { |
| 522 | /* |
| 523 | * link this stream passes through |
| 524 | */ |
| 525 | const struct dc_link *link; |
| 526 | }; |
| 527 | |
| 528 | const struct dc_stream_status *dc_stream_get_status( |
| 529 | const struct dc_stream *dc_stream); |
| 530 | |
| 531 | /******************************************************************************* |
| 532 | * Link Interfaces |
| 533 | ******************************************************************************/ |
| 534 | |
| 535 | /* |
| 536 | * A link contains one or more sinks and their connected status. |
| 537 | * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported. |
| 538 | */ |
| 539 | struct dc_link { |
| 540 | const struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK]; |
| 541 | unsigned int sink_count; |
| 542 | const struct dc_sink *local_sink; |
| 543 | unsigned int link_index; |
| 544 | enum dc_connection_type type; |
| 545 | enum signal_type connector_signal; |
| 546 | enum dc_irq_source irq_source_hpd; |
| 547 | enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */ |
| 548 | /* caps is the same as reported_link_cap. link_traing use |
| 549 | * reported_link_cap. Will clean up. TODO |
| 550 | */ |
| 551 | struct dc_link_settings reported_link_cap; |
| 552 | struct dc_link_settings verified_link_cap; |
| 553 | struct dc_link_settings max_link_setting; |
| 554 | struct dc_link_settings cur_link_settings; |
| 555 | struct dc_lane_settings cur_lane_setting; |
| 556 | |
| 557 | uint8_t ddc_hw_inst; |
| 558 | uint8_t link_enc_hw_inst; |
| 559 | |
| 560 | struct psr_caps psr_caps; |
| 561 | bool test_pattern_enabled; |
| 562 | union compliance_test_state compliance_test_state; |
| 563 | }; |
| 564 | |
| 565 | struct dpcd_caps { |
| 566 | union dpcd_rev dpcd_rev; |
| 567 | union max_lane_count max_ln_count; |
| 568 | union max_down_spread max_down_spread; |
| 569 | |
| 570 | /* dongle type (DP converter, CV smart dongle) */ |
| 571 | enum display_dongle_type dongle_type; |
| 572 | /* Dongle's downstream count. */ |
| 573 | union sink_count sink_count; |
| 574 | /* If dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER, |
| 575 | indicates 'Frame Sequential-to-lllFrame Pack' conversion capability.*/ |
| 576 | bool is_dp_hdmi_s3d_converter; |
| 577 | |
| 578 | bool allow_invalid_MSA_timing_param; |
| 579 | bool panel_mode_edp; |
| 580 | uint32_t sink_dev_id; |
| 581 | uint32_t branch_dev_id; |
| 582 | int8_t branch_dev_name[6]; |
| 583 | int8_t branch_hw_revision; |
| 584 | }; |
| 585 | |
| 586 | struct dc_link_status { |
| 587 | struct dpcd_caps *dpcd_caps; |
| 588 | }; |
| 589 | |
| 590 | const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link); |
| 591 | |
| 592 | /* |
| 593 | * Return an enumerated dc_link. dc_link order is constant and determined at |
| 594 | * boot time. They cannot be created or destroyed. |
| 595 | * Use dc_get_caps() to get number of links. |
| 596 | */ |
| 597 | const struct dc_link *dc_get_link_at_index(const struct dc *dc, uint32_t link_index); |
| 598 | |
| 599 | /* Return id of physical connector represented by a dc_link at link_index.*/ |
| 600 | const struct graphics_object_id dc_get_link_id_at_index( |
| 601 | struct dc *dc, uint32_t link_index); |
| 602 | |
| 603 | /* Set backlight level of an embedded panel (eDP, LVDS). */ |
| 604 | bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level, |
| 605 | uint32_t frame_ramp, const struct dc_stream *stream); |
| 606 | |
| 607 | bool dc_link_init_dmcu_backlight_settings(const struct dc_link *dc_link); |
| 608 | |
| 609 | bool dc_link_set_abm_level(const struct dc_link *dc_link, uint32_t level); |
| 610 | |
| 611 | bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable); |
| 612 | |
| 613 | bool dc_link_setup_psr(const struct dc_link *dc_link, |
| 614 | const struct dc_stream *stream); |
| 615 | |
| 616 | /* Request DC to detect if there is a Panel connected. |
| 617 | * boot - If this call is during initial boot. |
| 618 | * Return false for any type of detection failure or MST detection |
| 619 | * true otherwise. True meaning further action is required (status update |
| 620 | * and OS notification). |
| 621 | */ |
| 622 | bool dc_link_detect(const struct dc_link *dc_link, bool boot); |
| 623 | |
| 624 | /* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt). |
| 625 | * Return: |
| 626 | * true - Downstream port status changed. DM should call DC to do the |
| 627 | * detection. |
| 628 | * false - no change in Downstream port status. No further action required |
| 629 | * from DM. */ |
| 630 | bool dc_link_handle_hpd_rx_irq(const struct dc_link *dc_link); |
| 631 | |
| 632 | struct dc_sink_init_data; |
| 633 | |
| 634 | struct dc_sink *dc_link_add_remote_sink( |
| 635 | const struct dc_link *dc_link, |
| 636 | const uint8_t *edid, |
| 637 | int len, |
| 638 | struct dc_sink_init_data *init_data); |
| 639 | |
| 640 | void dc_link_remove_remote_sink( |
| 641 | const struct dc_link *link, |
| 642 | const struct dc_sink *sink); |
| 643 | |
| 644 | /* Used by diagnostics for virtual link at the moment */ |
| 645 | void dc_link_set_sink(const struct dc_link *link, struct dc_sink *sink); |
| 646 | |
| 647 | void dc_link_dp_set_drive_settings( |
| 648 | struct dc_link *link, |
| 649 | struct link_training_settings *lt_settings); |
| 650 | |
| 651 | bool dc_link_dp_perform_link_training( |
| 652 | struct dc_link *link, |
| 653 | const struct dc_link_settings *link_setting, |
| 654 | bool skip_video_pattern); |
| 655 | |
| 656 | void dc_link_dp_enable_hpd(const struct dc_link *link); |
| 657 | |
| 658 | void dc_link_dp_disable_hpd(const struct dc_link *link); |
| 659 | |
| 660 | bool dc_link_dp_set_test_pattern( |
| 661 | const struct dc_link *link, |
| 662 | enum dp_test_pattern test_pattern, |
| 663 | const struct link_training_settings *p_link_settings, |
| 664 | const unsigned char *p_custom_pattern, |
| 665 | unsigned int cust_pattern_size); |
| 666 | |
| 667 | /******************************************************************************* |
| 668 | * Sink Interfaces - A sink corresponds to a display output device |
| 669 | ******************************************************************************/ |
| 670 | |
| 671 | /* |
| 672 | * The sink structure contains EDID and other display device properties |
| 673 | */ |
| 674 | struct dc_sink { |
| 675 | enum signal_type sink_signal; |
| 676 | struct dc_edid dc_edid; /* raw edid */ |
| 677 | struct dc_edid_caps edid_caps; /* parse display caps */ |
| 678 | }; |
| 679 | |
| 680 | void dc_sink_retain(const struct dc_sink *sink); |
| 681 | void dc_sink_release(const struct dc_sink *sink); |
| 682 | |
| 683 | const struct audio **dc_get_audios(struct dc *dc); |
| 684 | |
| 685 | struct dc_sink_init_data { |
| 686 | enum signal_type sink_signal; |
| 687 | const struct dc_link *link; |
| 688 | uint32_t dongle_max_pix_clk; |
| 689 | bool converter_disable_audio; |
| 690 | }; |
| 691 | |
| 692 | struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params); |
| 693 | |
| 694 | /******************************************************************************* |
| 695 | * Cursor interfaces - To manages the cursor within a target |
| 696 | ******************************************************************************/ |
| 697 | /* TODO: Deprecated once we switch to dc_set_cursor_position */ |
| 698 | bool dc_target_set_cursor_attributes( |
| 699 | struct dc_target *dc_target, |
| 700 | const struct dc_cursor_attributes *attributes); |
| 701 | |
| 702 | bool dc_target_set_cursor_position( |
| 703 | struct dc_target *dc_target, |
| 704 | const struct dc_cursor_position *position); |
| 705 | |
| 706 | /* Newer interfaces */ |
| 707 | struct dc_cursor { |
| 708 | struct dc_plane_address address; |
| 709 | struct dc_cursor_attributes attributes; |
| 710 | }; |
| 711 | |
| 712 | /* |
| 713 | * Create a new cursor with default values for a given target. |
| 714 | */ |
| 715 | struct dc_cursor *dc_create_cursor_for_target( |
| 716 | const struct dc *dc, |
| 717 | struct dc_target *dc_target); |
| 718 | |
| 719 | /** |
| 720 | * Commit cursor attribute changes such as pixel format and dimensions and |
| 721 | * surface address. |
| 722 | * |
| 723 | * After this call: |
| 724 | * Cursor address and format is programmed to the new values. |
| 725 | * Cursor position is unmodified. |
| 726 | */ |
| 727 | bool dc_commit_cursor( |
| 728 | const struct dc *dc, |
| 729 | struct dc_cursor *cursor); |
| 730 | |
| 731 | /* |
| 732 | * Optimized cursor position update |
| 733 | * |
| 734 | * After this call: |
| 735 | * Cursor position will be programmed as well as enable/disable bit. |
| 736 | */ |
| 737 | bool dc_set_cursor_position( |
| 738 | const struct dc *dc, |
| 739 | struct dc_cursor *cursor, |
| 740 | struct dc_cursor_position *pos); |
| 741 | |
| 742 | /******************************************************************************* |
| 743 | * Interrupt interfaces |
| 744 | ******************************************************************************/ |
| 745 | enum dc_irq_source dc_interrupt_to_irq_source( |
| 746 | struct dc *dc, |
| 747 | uint32_t src_id, |
| 748 | uint32_t ext_id); |
| 749 | void dc_interrupt_set(const struct dc *dc, enum dc_irq_source src, bool enable); |
| 750 | void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src); |
| 751 | enum dc_irq_source dc_get_hpd_irq_source_at_index( |
| 752 | struct dc *dc, uint32_t link_index); |
| 753 | |
| 754 | /******************************************************************************* |
| 755 | * Power Interfaces |
| 756 | ******************************************************************************/ |
| 757 | |
| 758 | void dc_set_power_state( |
| 759 | struct dc *dc, |
| 760 | enum dc_acpi_cm_power_state power_state, |
| 761 | enum dc_video_power_state video_power_state); |
| 762 | void dc_resume(const struct dc *dc); |
| 763 | |
| 764 | /******************************************************************************* |
| 765 | * DDC Interfaces |
| 766 | ******************************************************************************/ |
| 767 | |
| 768 | const struct ddc_service *dc_get_ddc_at_index( |
| 769 | struct dc *dc, uint32_t link_index); |
| 770 | |
| 771 | /* |
| 772 | * DPCD access interfaces |
| 773 | */ |
| 774 | |
| 775 | bool dc_read_dpcd( |
| 776 | struct dc *dc, |
| 777 | uint32_t link_index, |
| 778 | uint32_t address, |
| 779 | uint8_t *data, |
| 780 | uint32_t size); |
| 781 | |
| 782 | bool dc_write_dpcd( |
| 783 | struct dc *dc, |
| 784 | uint32_t link_index, |
| 785 | uint32_t address, |
| 786 | const uint8_t *data, |
| 787 | uint32_t size); |
| 788 | |
| 789 | bool dc_submit_i2c( |
| 790 | struct dc *dc, |
| 791 | uint32_t link_index, |
| 792 | struct i2c_command *cmd); |
| 793 | |
| 794 | #endif /* DC_INTERFACE_H_ */ |