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