1 /* 2 * Copyright 2015 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * Authors: AMD 23 * 24 */ 25 26 #include <linux/string.h> 27 #include <linux/acpi.h> 28 #include <linux/i2c.h> 29 30 #include <drm/drm_atomic.h> 31 #include <drm/drm_probe_helper.h> 32 #include <drm/amdgpu_drm.h> 33 #include <drm/drm_edid.h> 34 #include <drm/drm_fixed.h> 35 36 #include "dm_services.h" 37 #include "amdgpu.h" 38 #include "dc.h" 39 #include "amdgpu_dm.h" 40 #include "amdgpu_dm_irq.h" 41 #include "amdgpu_dm_mst_types.h" 42 #include "dpcd_defs.h" 43 #include "dc/inc/core_types.h" 44 45 #include "dm_helpers.h" 46 #include "ddc_service_types.h" 47 48 static u32 edid_extract_panel_id(struct edid *edid) 49 { 50 return (u32)edid->mfg_id[0] << 24 | 51 (u32)edid->mfg_id[1] << 16 | 52 (u32)EDID_PRODUCT_ID(edid); 53 } 54 55 static void apply_edid_quirks(struct edid *edid, struct dc_edid_caps *edid_caps) 56 { 57 uint32_t panel_id = edid_extract_panel_id(edid); 58 59 switch (panel_id) { 60 /* Workaround for some monitors which does not work well with FAMS */ 61 case drm_edid_encode_panel_id('S', 'A', 'M', 0x0E5E): 62 case drm_edid_encode_panel_id('S', 'A', 'M', 0x7053): 63 case drm_edid_encode_panel_id('S', 'A', 'M', 0x71AC): 64 DRM_DEBUG_DRIVER("Disabling FAMS on monitor with panel id %X\n", panel_id); 65 edid_caps->panel_patch.disable_fams = true; 66 break; 67 /* Workaround for some monitors that do not clear DPCD 0x317 if FreeSync is unsupported */ 68 case drm_edid_encode_panel_id('A', 'U', 'O', 0xA7AB): 69 case drm_edid_encode_panel_id('A', 'U', 'O', 0xE69B): 70 DRM_DEBUG_DRIVER("Clearing DPCD 0x317 on monitor with panel id %X\n", panel_id); 71 edid_caps->panel_patch.remove_sink_ext_caps = true; 72 break; 73 default: 74 return; 75 } 76 } 77 78 /** 79 * dm_helpers_parse_edid_caps() - Parse edid caps 80 * 81 * @link: current detected link 82 * @edid: [in] pointer to edid 83 * @edid_caps: [in] pointer to edid caps 84 * 85 * Return: void 86 */ 87 enum dc_edid_status dm_helpers_parse_edid_caps( 88 struct dc_link *link, 89 const struct dc_edid *edid, 90 struct dc_edid_caps *edid_caps) 91 { 92 struct amdgpu_dm_connector *aconnector = link->priv; 93 struct drm_connector *connector = &aconnector->base; 94 struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL; 95 struct cea_sad *sads; 96 int sad_count = -1; 97 int sadb_count = -1; 98 int i = 0; 99 uint8_t *sadb = NULL; 100 101 enum dc_edid_status result = EDID_OK; 102 103 if (!edid_caps || !edid) 104 return EDID_BAD_INPUT; 105 106 if (!drm_edid_is_valid(edid_buf)) 107 result = EDID_BAD_CHECKSUM; 108 109 edid_caps->manufacturer_id = (uint16_t) edid_buf->mfg_id[0] | 110 ((uint16_t) edid_buf->mfg_id[1])<<8; 111 edid_caps->product_id = (uint16_t) edid_buf->prod_code[0] | 112 ((uint16_t) edid_buf->prod_code[1])<<8; 113 edid_caps->serial_number = edid_buf->serial; 114 edid_caps->manufacture_week = edid_buf->mfg_week; 115 edid_caps->manufacture_year = edid_buf->mfg_year; 116 117 drm_edid_get_monitor_name(edid_buf, 118 edid_caps->display_name, 119 AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS); 120 121 edid_caps->edid_hdmi = connector->display_info.is_hdmi; 122 123 sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads); 124 if (sad_count <= 0) 125 return result; 126 127 edid_caps->audio_mode_count = min(sad_count, DC_MAX_AUDIO_DESC_COUNT); 128 for (i = 0; i < edid_caps->audio_mode_count; ++i) { 129 struct cea_sad *sad = &sads[i]; 130 131 edid_caps->audio_modes[i].format_code = sad->format; 132 edid_caps->audio_modes[i].channel_count = sad->channels + 1; 133 edid_caps->audio_modes[i].sample_rate = sad->freq; 134 edid_caps->audio_modes[i].sample_size = sad->byte2; 135 } 136 137 sadb_count = drm_edid_to_speaker_allocation((struct edid *) edid->raw_edid, &sadb); 138 139 if (sadb_count < 0) { 140 DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sadb_count); 141 sadb_count = 0; 142 } 143 144 if (sadb_count) 145 edid_caps->speaker_flags = sadb[0]; 146 else 147 edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION; 148 149 apply_edid_quirks(edid_buf, edid_caps); 150 151 kfree(sads); 152 kfree(sadb); 153 154 return result; 155 } 156 157 static void 158 fill_dc_mst_payload_table_from_drm(struct dc_link *link, 159 bool enable, 160 struct drm_dp_mst_atomic_payload *target_payload, 161 struct dc_dp_mst_stream_allocation_table *table) 162 { 163 struct dc_dp_mst_stream_allocation_table new_table = { 0 }; 164 struct dc_dp_mst_stream_allocation *sa; 165 struct link_mst_stream_allocation_table copy_of_link_table = 166 link->mst_stream_alloc_table; 167 168 int i; 169 int current_hw_table_stream_cnt = copy_of_link_table.stream_count; 170 struct link_mst_stream_allocation *dc_alloc; 171 172 /* TODO: refactor to set link->mst_stream_alloc_table directly if possible.*/ 173 if (enable) { 174 dc_alloc = 175 ©_of_link_table.stream_allocations[current_hw_table_stream_cnt]; 176 dc_alloc->vcp_id = target_payload->vcpi; 177 dc_alloc->slot_count = target_payload->time_slots; 178 } else { 179 for (i = 0; i < copy_of_link_table.stream_count; i++) { 180 dc_alloc = 181 ©_of_link_table.stream_allocations[i]; 182 183 if (dc_alloc->vcp_id == target_payload->vcpi) { 184 dc_alloc->vcp_id = 0; 185 dc_alloc->slot_count = 0; 186 break; 187 } 188 } 189 ASSERT(i != copy_of_link_table.stream_count); 190 } 191 192 /* Fill payload info*/ 193 for (i = 0; i < MAX_CONTROLLER_NUM; i++) { 194 dc_alloc = 195 ©_of_link_table.stream_allocations[i]; 196 if (dc_alloc->vcp_id > 0 && dc_alloc->slot_count > 0) { 197 sa = &new_table.stream_allocations[new_table.stream_count]; 198 sa->slot_count = dc_alloc->slot_count; 199 sa->vcp_id = dc_alloc->vcp_id; 200 new_table.stream_count++; 201 } 202 } 203 204 /* Overwrite the old table */ 205 *table = new_table; 206 } 207 208 void dm_helpers_dp_update_branch_info( 209 struct dc_context *ctx, 210 const struct dc_link *link) 211 {} 212 213 static void dm_helpers_construct_old_payload( 214 struct drm_dp_mst_topology_mgr *mgr, 215 struct drm_dp_mst_topology_state *mst_state, 216 struct drm_dp_mst_atomic_payload *new_payload, 217 struct drm_dp_mst_atomic_payload *old_payload) 218 { 219 struct drm_dp_mst_atomic_payload *pos; 220 int pbn_per_slot = dfixed_trunc(mst_state->pbn_div); 221 u8 next_payload_vc_start = mgr->next_start_slot; 222 u8 payload_vc_start = new_payload->vc_start_slot; 223 u8 allocated_time_slots; 224 225 *old_payload = *new_payload; 226 227 /* Set correct time_slots/PBN of old payload. 228 * other fields (delete & dsc_enabled) in 229 * struct drm_dp_mst_atomic_payload are don't care fields 230 * while calling drm_dp_remove_payload_part2() 231 */ 232 list_for_each_entry(pos, &mst_state->payloads, next) { 233 if (pos != new_payload && 234 pos->vc_start_slot > payload_vc_start && 235 pos->vc_start_slot < next_payload_vc_start) 236 next_payload_vc_start = pos->vc_start_slot; 237 } 238 239 allocated_time_slots = next_payload_vc_start - payload_vc_start; 240 241 old_payload->time_slots = allocated_time_slots; 242 old_payload->pbn = allocated_time_slots * pbn_per_slot; 243 } 244 245 /* 246 * Writes payload allocation table in immediate downstream device. 247 */ 248 bool dm_helpers_dp_mst_write_payload_allocation_table( 249 struct dc_context *ctx, 250 const struct dc_stream_state *stream, 251 struct dc_dp_mst_stream_allocation_table *proposed_table, 252 bool enable) 253 { 254 struct amdgpu_dm_connector *aconnector; 255 struct drm_dp_mst_topology_state *mst_state; 256 struct drm_dp_mst_atomic_payload *target_payload, *new_payload, old_payload; 257 struct drm_dp_mst_topology_mgr *mst_mgr; 258 259 aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context; 260 /* Accessing the connector state is required for vcpi_slots allocation 261 * and directly relies on behaviour in commit check 262 * that blocks before commit guaranteeing that the state 263 * is not gonna be swapped while still in use in commit tail 264 */ 265 266 if (!aconnector || !aconnector->mst_root) 267 return false; 268 269 mst_mgr = &aconnector->mst_root->mst_mgr; 270 mst_state = to_drm_dp_mst_topology_state(mst_mgr->base.state); 271 new_payload = drm_atomic_get_mst_payload_state(mst_state, aconnector->mst_output_port); 272 273 if (enable) { 274 target_payload = new_payload; 275 276 /* It's OK for this to fail */ 277 drm_dp_add_payload_part1(mst_mgr, mst_state, new_payload); 278 } else { 279 /* construct old payload by VCPI*/ 280 dm_helpers_construct_old_payload(mst_mgr, mst_state, 281 new_payload, &old_payload); 282 target_payload = &old_payload; 283 284 drm_dp_remove_payload_part1(mst_mgr, mst_state, new_payload); 285 } 286 287 /* mst_mgr->->payloads are VC payload notify MST branch using DPCD or 288 * AUX message. The sequence is slot 1-63 allocated sequence for each 289 * stream. AMD ASIC stream slot allocation should follow the same 290 * sequence. copy DRM MST allocation to dc 291 */ 292 fill_dc_mst_payload_table_from_drm(stream->link, enable, target_payload, proposed_table); 293 294 return true; 295 } 296 297 /* 298 * poll pending down reply 299 */ 300 void dm_helpers_dp_mst_poll_pending_down_reply( 301 struct dc_context *ctx, 302 const struct dc_link *link) 303 {} 304 305 /* 306 * Clear payload allocation table before enable MST DP link. 307 */ 308 void dm_helpers_dp_mst_clear_payload_allocation_table( 309 struct dc_context *ctx, 310 const struct dc_link *link) 311 {} 312 313 /* 314 * Polls for ACT (allocation change trigger) handled and sends 315 * ALLOCATE_PAYLOAD message. 316 */ 317 enum act_return_status dm_helpers_dp_mst_poll_for_allocation_change_trigger( 318 struct dc_context *ctx, 319 const struct dc_stream_state *stream) 320 { 321 struct amdgpu_dm_connector *aconnector; 322 struct drm_dp_mst_topology_mgr *mst_mgr; 323 int ret; 324 325 aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context; 326 327 if (!aconnector || !aconnector->mst_root) 328 return ACT_FAILED; 329 330 mst_mgr = &aconnector->mst_root->mst_mgr; 331 332 if (!mst_mgr->mst_state) 333 return ACT_FAILED; 334 335 ret = drm_dp_check_act_status(mst_mgr); 336 337 if (ret) 338 return ACT_FAILED; 339 340 return ACT_SUCCESS; 341 } 342 343 void dm_helpers_dp_mst_send_payload_allocation( 344 struct dc_context *ctx, 345 const struct dc_stream_state *stream) 346 { 347 struct amdgpu_dm_connector *aconnector; 348 struct drm_dp_mst_topology_state *mst_state; 349 struct drm_dp_mst_topology_mgr *mst_mgr; 350 struct drm_dp_mst_atomic_payload *new_payload; 351 enum mst_progress_status set_flag = MST_ALLOCATE_NEW_PAYLOAD; 352 enum mst_progress_status clr_flag = MST_CLEAR_ALLOCATED_PAYLOAD; 353 int ret = 0; 354 355 aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context; 356 357 if (!aconnector || !aconnector->mst_root) 358 return; 359 360 mst_mgr = &aconnector->mst_root->mst_mgr; 361 mst_state = to_drm_dp_mst_topology_state(mst_mgr->base.state); 362 new_payload = drm_atomic_get_mst_payload_state(mst_state, aconnector->mst_output_port); 363 364 ret = drm_dp_add_payload_part2(mst_mgr, mst_state->base.state, new_payload); 365 366 if (ret) { 367 amdgpu_dm_set_mst_status(&aconnector->mst_status, 368 set_flag, false); 369 } else { 370 amdgpu_dm_set_mst_status(&aconnector->mst_status, 371 set_flag, true); 372 amdgpu_dm_set_mst_status(&aconnector->mst_status, 373 clr_flag, false); 374 } 375 } 376 377 void dm_helpers_dp_mst_update_mst_mgr_for_deallocation( 378 struct dc_context *ctx, 379 const struct dc_stream_state *stream) 380 { 381 struct amdgpu_dm_connector *aconnector; 382 struct drm_dp_mst_topology_state *mst_state; 383 struct drm_dp_mst_topology_mgr *mst_mgr; 384 struct drm_dp_mst_atomic_payload *new_payload, old_payload; 385 enum mst_progress_status set_flag = MST_CLEAR_ALLOCATED_PAYLOAD; 386 enum mst_progress_status clr_flag = MST_ALLOCATE_NEW_PAYLOAD; 387 388 aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context; 389 390 if (!aconnector || !aconnector->mst_root) 391 return; 392 393 mst_mgr = &aconnector->mst_root->mst_mgr; 394 mst_state = to_drm_dp_mst_topology_state(mst_mgr->base.state); 395 new_payload = drm_atomic_get_mst_payload_state(mst_state, aconnector->mst_output_port); 396 dm_helpers_construct_old_payload(mst_mgr, mst_state, 397 new_payload, &old_payload); 398 399 drm_dp_remove_payload_part2(mst_mgr, mst_state, &old_payload, new_payload); 400 401 amdgpu_dm_set_mst_status(&aconnector->mst_status, set_flag, true); 402 amdgpu_dm_set_mst_status(&aconnector->mst_status, clr_flag, false); 403 } 404 405 void dm_dtn_log_begin(struct dc_context *ctx, 406 struct dc_log_buffer_ctx *log_ctx) 407 { 408 static const char msg[] = "[dtn begin]\n"; 409 410 if (!log_ctx) { 411 pr_info("%s", msg); 412 return; 413 } 414 415 dm_dtn_log_append_v(ctx, log_ctx, "%s", msg); 416 } 417 418 __printf(3, 4) 419 void dm_dtn_log_append_v(struct dc_context *ctx, 420 struct dc_log_buffer_ctx *log_ctx, 421 const char *msg, ...) 422 { 423 va_list args; 424 size_t total; 425 int n; 426 427 if (!log_ctx) { 428 /* No context, redirect to dmesg. */ 429 struct va_format vaf; 430 431 vaf.fmt = msg; 432 vaf.va = &args; 433 434 va_start(args, msg); 435 pr_info("%pV", &vaf); 436 va_end(args); 437 438 return; 439 } 440 441 /* Measure the output. */ 442 va_start(args, msg); 443 n = vsnprintf(NULL, 0, msg, args); 444 va_end(args); 445 446 if (n <= 0) 447 return; 448 449 /* Reallocate the string buffer as needed. */ 450 total = log_ctx->pos + n + 1; 451 452 if (total > log_ctx->size) { 453 char *buf = kvcalloc(total, sizeof(char), GFP_KERNEL); 454 455 if (buf) { 456 memcpy(buf, log_ctx->buf, log_ctx->pos); 457 kfree(log_ctx->buf); 458 459 log_ctx->buf = buf; 460 log_ctx->size = total; 461 } 462 } 463 464 if (!log_ctx->buf) 465 return; 466 467 /* Write the formatted string to the log buffer. */ 468 va_start(args, msg); 469 n = vscnprintf( 470 log_ctx->buf + log_ctx->pos, 471 log_ctx->size - log_ctx->pos, 472 msg, 473 args); 474 va_end(args); 475 476 if (n > 0) 477 log_ctx->pos += n; 478 } 479 480 void dm_dtn_log_end(struct dc_context *ctx, 481 struct dc_log_buffer_ctx *log_ctx) 482 { 483 static const char msg[] = "[dtn end]\n"; 484 485 if (!log_ctx) { 486 pr_info("%s", msg); 487 return; 488 } 489 490 dm_dtn_log_append_v(ctx, log_ctx, "%s", msg); 491 } 492 493 bool dm_helpers_dp_mst_start_top_mgr( 494 struct dc_context *ctx, 495 const struct dc_link *link, 496 bool boot) 497 { 498 struct amdgpu_dm_connector *aconnector = link->priv; 499 int ret; 500 501 if (!aconnector) { 502 DRM_ERROR("Failed to find connector for link!"); 503 return false; 504 } 505 506 if (boot) { 507 DRM_INFO("DM_MST: Differing MST start on aconnector: %p [id: %d]\n", 508 aconnector, aconnector->base.base.id); 509 return true; 510 } 511 512 DRM_INFO("DM_MST: starting TM on aconnector: %p [id: %d]\n", 513 aconnector, aconnector->base.base.id); 514 515 ret = drm_dp_mst_topology_mgr_set_mst(&aconnector->mst_mgr, true); 516 if (ret < 0) { 517 DRM_ERROR("DM_MST: Failed to set the device into MST mode!"); 518 return false; 519 } 520 521 DRM_INFO("DM_MST: DP%x, %d-lane link detected\n", aconnector->mst_mgr.dpcd[0], 522 aconnector->mst_mgr.dpcd[2] & DP_MAX_LANE_COUNT_MASK); 523 524 return true; 525 } 526 527 bool dm_helpers_dp_mst_stop_top_mgr( 528 struct dc_context *ctx, 529 struct dc_link *link) 530 { 531 struct amdgpu_dm_connector *aconnector = link->priv; 532 533 if (!aconnector) { 534 DRM_ERROR("Failed to find connector for link!"); 535 return false; 536 } 537 538 DRM_INFO("DM_MST: stopping TM on aconnector: %p [id: %d]\n", 539 aconnector, aconnector->base.base.id); 540 541 if (aconnector->mst_mgr.mst_state == true) { 542 drm_dp_mst_topology_mgr_set_mst(&aconnector->mst_mgr, false); 543 link->cur_link_settings.lane_count = 0; 544 } 545 546 return false; 547 } 548 549 bool dm_helpers_dp_read_dpcd( 550 struct dc_context *ctx, 551 const struct dc_link *link, 552 uint32_t address, 553 uint8_t *data, 554 uint32_t size) 555 { 556 557 struct amdgpu_dm_connector *aconnector = link->priv; 558 559 if (!aconnector) 560 return false; 561 562 return drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address, data, 563 size) == size; 564 } 565 566 bool dm_helpers_dp_write_dpcd( 567 struct dc_context *ctx, 568 const struct dc_link *link, 569 uint32_t address, 570 const uint8_t *data, 571 uint32_t size) 572 { 573 struct amdgpu_dm_connector *aconnector = link->priv; 574 575 if (!aconnector) { 576 DRM_ERROR("Failed to find connector for link!"); 577 return false; 578 } 579 580 return drm_dp_dpcd_write(&aconnector->dm_dp_aux.aux, 581 address, (uint8_t *)data, size) > 0; 582 } 583 584 bool dm_helpers_submit_i2c( 585 struct dc_context *ctx, 586 const struct dc_link *link, 587 struct i2c_command *cmd) 588 { 589 struct amdgpu_dm_connector *aconnector = link->priv; 590 struct i2c_msg *msgs; 591 int i = 0; 592 int num = cmd->number_of_payloads; 593 bool result; 594 595 if (!aconnector) { 596 DRM_ERROR("Failed to find connector for link!"); 597 return false; 598 } 599 600 msgs = kcalloc(num, sizeof(struct i2c_msg), GFP_KERNEL); 601 602 if (!msgs) 603 return false; 604 605 for (i = 0; i < num; i++) { 606 msgs[i].flags = cmd->payloads[i].write ? 0 : I2C_M_RD; 607 msgs[i].addr = cmd->payloads[i].address; 608 msgs[i].len = cmd->payloads[i].length; 609 msgs[i].buf = cmd->payloads[i].data; 610 } 611 612 result = i2c_transfer(&aconnector->i2c->base, msgs, num) == num; 613 614 kfree(msgs); 615 616 return result; 617 } 618 619 static bool execute_synaptics_rc_command(struct drm_dp_aux *aux, 620 bool is_write_cmd, 621 unsigned char cmd, 622 unsigned int length, 623 unsigned int offset, 624 unsigned char *data) 625 { 626 bool success = false; 627 unsigned char rc_data[16] = {0}; 628 unsigned char rc_offset[4] = {0}; 629 unsigned char rc_length[2] = {0}; 630 unsigned char rc_cmd = 0; 631 unsigned char rc_result = 0xFF; 632 unsigned char i = 0; 633 int ret; 634 635 if (is_write_cmd) { 636 // write rc data 637 memmove(rc_data, data, length); 638 ret = drm_dp_dpcd_write(aux, SYNAPTICS_RC_DATA, rc_data, sizeof(rc_data)); 639 } 640 641 // write rc offset 642 rc_offset[0] = (unsigned char) offset & 0xFF; 643 rc_offset[1] = (unsigned char) (offset >> 8) & 0xFF; 644 rc_offset[2] = (unsigned char) (offset >> 16) & 0xFF; 645 rc_offset[3] = (unsigned char) (offset >> 24) & 0xFF; 646 ret = drm_dp_dpcd_write(aux, SYNAPTICS_RC_OFFSET, rc_offset, sizeof(rc_offset)); 647 648 // write rc length 649 rc_length[0] = (unsigned char) length & 0xFF; 650 rc_length[1] = (unsigned char) (length >> 8) & 0xFF; 651 ret = drm_dp_dpcd_write(aux, SYNAPTICS_RC_LENGTH, rc_length, sizeof(rc_length)); 652 653 // write rc cmd 654 rc_cmd = cmd | 0x80; 655 ret = drm_dp_dpcd_write(aux, SYNAPTICS_RC_COMMAND, &rc_cmd, sizeof(rc_cmd)); 656 657 if (ret < 0) { 658 DRM_ERROR("%s: write cmd ..., err = %d\n", __func__, ret); 659 return false; 660 } 661 662 // poll until active is 0 663 for (i = 0; i < 10; i++) { 664 drm_dp_dpcd_read(aux, SYNAPTICS_RC_COMMAND, &rc_cmd, sizeof(rc_cmd)); 665 if (rc_cmd == cmd) 666 // active is 0 667 break; 668 msleep(10); 669 } 670 671 // read rc result 672 drm_dp_dpcd_read(aux, SYNAPTICS_RC_RESULT, &rc_result, sizeof(rc_result)); 673 success = (rc_result == 0); 674 675 if (success && !is_write_cmd) { 676 // read rc data 677 drm_dp_dpcd_read(aux, SYNAPTICS_RC_DATA, data, length); 678 } 679 680 drm_dbg_dp(aux->drm_dev, "success = %d\n", success); 681 682 return success; 683 } 684 685 static void apply_synaptics_fifo_reset_wa(struct drm_dp_aux *aux) 686 { 687 unsigned char data[16] = {0}; 688 689 drm_dbg_dp(aux->drm_dev, "Start\n"); 690 691 // Step 2 692 data[0] = 'P'; 693 data[1] = 'R'; 694 data[2] = 'I'; 695 data[3] = 'U'; 696 data[4] = 'S'; 697 698 if (!execute_synaptics_rc_command(aux, true, 0x01, 5, 0, data)) 699 return; 700 701 // Step 3 and 4 702 if (!execute_synaptics_rc_command(aux, false, 0x31, 4, 0x220998, data)) 703 return; 704 705 data[0] &= (~(1 << 1)); // set bit 1 to 0 706 if (!execute_synaptics_rc_command(aux, true, 0x21, 4, 0x220998, data)) 707 return; 708 709 if (!execute_synaptics_rc_command(aux, false, 0x31, 4, 0x220D98, data)) 710 return; 711 712 data[0] &= (~(1 << 1)); // set bit 1 to 0 713 if (!execute_synaptics_rc_command(aux, true, 0x21, 4, 0x220D98, data)) 714 return; 715 716 if (!execute_synaptics_rc_command(aux, false, 0x31, 4, 0x221198, data)) 717 return; 718 719 data[0] &= (~(1 << 1)); // set bit 1 to 0 720 if (!execute_synaptics_rc_command(aux, true, 0x21, 4, 0x221198, data)) 721 return; 722 723 // Step 3 and 5 724 if (!execute_synaptics_rc_command(aux, false, 0x31, 4, 0x220998, data)) 725 return; 726 727 data[0] |= (1 << 1); // set bit 1 to 1 728 if (!execute_synaptics_rc_command(aux, true, 0x21, 4, 0x220998, data)) 729 return; 730 731 if (!execute_synaptics_rc_command(aux, false, 0x31, 4, 0x220D98, data)) 732 return; 733 734 data[0] |= (1 << 1); // set bit 1 to 1 735 736 if (!execute_synaptics_rc_command(aux, false, 0x31, 4, 0x221198, data)) 737 return; 738 739 data[0] |= (1 << 1); // set bit 1 to 1 740 if (!execute_synaptics_rc_command(aux, true, 0x21, 4, 0x221198, data)) 741 return; 742 743 // Step 6 744 if (!execute_synaptics_rc_command(aux, true, 0x02, 0, 0, NULL)) 745 return; 746 747 drm_dbg_dp(aux->drm_dev, "Done\n"); 748 } 749 750 /* MST Dock */ 751 static const uint8_t SYNAPTICS_DEVICE_ID[] = "SYNA"; 752 753 static uint8_t write_dsc_enable_synaptics_non_virtual_dpcd_mst( 754 struct drm_dp_aux *aux, 755 const struct dc_stream_state *stream, 756 bool enable) 757 { 758 uint8_t ret = 0; 759 760 drm_dbg_dp(aux->drm_dev, 761 "Configure DSC to non-virtual dpcd synaptics\n"); 762 763 if (enable) { 764 /* When DSC is enabled on previous boot and reboot with the hub, 765 * there is a chance that Synaptics hub gets stuck during reboot sequence. 766 * Applying a workaround to reset Synaptics SDP fifo before enabling the first stream 767 */ 768 if (!stream->link->link_status.link_active && 769 memcmp(stream->link->dpcd_caps.branch_dev_name, 770 (int8_t *)SYNAPTICS_DEVICE_ID, 4) == 0) 771 apply_synaptics_fifo_reset_wa(aux); 772 773 ret = drm_dp_dpcd_write(aux, DP_DSC_ENABLE, &enable, 1); 774 DRM_INFO("Send DSC enable to synaptics\n"); 775 776 } else { 777 /* Synaptics hub not support virtual dpcd, 778 * external monitor occur garbage while disable DSC, 779 * Disable DSC only when entire link status turn to false, 780 */ 781 if (!stream->link->link_status.link_active) { 782 ret = drm_dp_dpcd_write(aux, DP_DSC_ENABLE, &enable, 1); 783 DRM_INFO("Send DSC disable to synaptics\n"); 784 } 785 } 786 787 return ret; 788 } 789 790 bool dm_helpers_dp_write_dsc_enable( 791 struct dc_context *ctx, 792 const struct dc_stream_state *stream, 793 bool enable) 794 { 795 static const uint8_t DSC_DISABLE; 796 static const uint8_t DSC_DECODING = 0x01; 797 static const uint8_t DSC_PASSTHROUGH = 0x02; 798 799 struct amdgpu_dm_connector *aconnector = 800 (struct amdgpu_dm_connector *)stream->dm_stream_context; 801 struct drm_device *dev = aconnector->base.dev; 802 struct drm_dp_mst_port *port; 803 uint8_t enable_dsc = enable ? DSC_DECODING : DSC_DISABLE; 804 uint8_t enable_passthrough = enable ? DSC_PASSTHROUGH : DSC_DISABLE; 805 uint8_t ret = 0; 806 807 if (!stream) 808 return false; 809 810 if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) { 811 if (!aconnector->dsc_aux) 812 return false; 813 814 // apply w/a to synaptics 815 if (needs_dsc_aux_workaround(aconnector->dc_link) && 816 (aconnector->mst_downstream_port_present.byte & 0x7) != 0x3) 817 return write_dsc_enable_synaptics_non_virtual_dpcd_mst( 818 aconnector->dsc_aux, stream, enable_dsc); 819 820 port = aconnector->mst_output_port; 821 822 if (enable) { 823 if (port->passthrough_aux) { 824 ret = drm_dp_dpcd_write(port->passthrough_aux, 825 DP_DSC_ENABLE, 826 &enable_passthrough, 1); 827 drm_dbg_dp(dev, 828 "Sent DSC pass-through enable to virtual dpcd port, ret = %u\n", 829 ret); 830 } 831 832 ret = drm_dp_dpcd_write(aconnector->dsc_aux, 833 DP_DSC_ENABLE, &enable_dsc, 1); 834 drm_dbg_dp(dev, 835 "Sent DSC decoding enable to %s port, ret = %u\n", 836 (port->passthrough_aux) ? "remote RX" : 837 "virtual dpcd", 838 ret); 839 } else { 840 ret = drm_dp_dpcd_write(aconnector->dsc_aux, 841 DP_DSC_ENABLE, &enable_dsc, 1); 842 drm_dbg_dp(dev, 843 "Sent DSC decoding disable to %s port, ret = %u\n", 844 (port->passthrough_aux) ? "remote RX" : 845 "virtual dpcd", 846 ret); 847 848 if (port->passthrough_aux) { 849 ret = drm_dp_dpcd_write(port->passthrough_aux, 850 DP_DSC_ENABLE, 851 &enable_passthrough, 1); 852 drm_dbg_dp(dev, 853 "Sent DSC pass-through disable to virtual dpcd port, ret = %u\n", 854 ret); 855 } 856 } 857 } 858 859 if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT || stream->signal == SIGNAL_TYPE_EDP) { 860 if (stream->sink->link->dpcd_caps.dongle_type == DISPLAY_DONGLE_NONE) { 861 ret = dm_helpers_dp_write_dpcd(ctx, stream->link, DP_DSC_ENABLE, &enable_dsc, 1); 862 drm_dbg_dp(dev, 863 "Send DSC %s to SST RX\n", 864 enable_dsc ? "enable" : "disable"); 865 } else if (stream->sink->link->dpcd_caps.dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER) { 866 ret = dm_helpers_dp_write_dpcd(ctx, stream->link, DP_DSC_ENABLE, &enable_dsc, 1); 867 drm_dbg_dp(dev, 868 "Send DSC %s to DP-HDMI PCON\n", 869 enable_dsc ? "enable" : "disable"); 870 } 871 } 872 873 return ret; 874 } 875 876 bool dm_helpers_is_dp_sink_present(struct dc_link *link) 877 { 878 bool dp_sink_present; 879 struct amdgpu_dm_connector *aconnector = link->priv; 880 881 if (!aconnector) { 882 BUG_ON("Failed to find connector for link!"); 883 return true; 884 } 885 886 mutex_lock(&aconnector->dm_dp_aux.aux.hw_mutex); 887 dp_sink_present = dc_link_is_dp_sink_present(link); 888 mutex_unlock(&aconnector->dm_dp_aux.aux.hw_mutex); 889 return dp_sink_present; 890 } 891 892 enum dc_edid_status dm_helpers_read_local_edid( 893 struct dc_context *ctx, 894 struct dc_link *link, 895 struct dc_sink *sink) 896 { 897 struct amdgpu_dm_connector *aconnector = link->priv; 898 struct drm_connector *connector = &aconnector->base; 899 struct i2c_adapter *ddc; 900 int retry = 3; 901 enum dc_edid_status edid_status; 902 struct edid *edid; 903 904 if (link->aux_mode) 905 ddc = &aconnector->dm_dp_aux.aux.ddc; 906 else 907 ddc = &aconnector->i2c->base; 908 909 /* some dongles read edid incorrectly the first time, 910 * do check sum and retry to make sure read correct edid. 911 */ 912 do { 913 914 edid = drm_get_edid(&aconnector->base, ddc); 915 916 /* DP Compliance Test 4.2.2.6 */ 917 if (link->aux_mode && connector->edid_corrupt) 918 drm_dp_send_real_edid_checksum(&aconnector->dm_dp_aux.aux, connector->real_edid_checksum); 919 920 if (!edid && connector->edid_corrupt) { 921 connector->edid_corrupt = false; 922 return EDID_BAD_CHECKSUM; 923 } 924 925 if (!edid) 926 return EDID_NO_RESPONSE; 927 928 sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1); 929 memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length); 930 931 /* We don't need the original edid anymore */ 932 kfree(edid); 933 934 edid_status = dm_helpers_parse_edid_caps( 935 link, 936 &sink->dc_edid, 937 &sink->edid_caps); 938 939 } while (edid_status == EDID_BAD_CHECKSUM && --retry > 0); 940 941 if (edid_status != EDID_OK) 942 DRM_ERROR("EDID err: %d, on connector: %s", 943 edid_status, 944 aconnector->base.name); 945 if (link->aux_mode) { 946 union test_request test_request = {0}; 947 union test_response test_response = {0}; 948 949 dm_helpers_dp_read_dpcd(ctx, 950 link, 951 DP_TEST_REQUEST, 952 &test_request.raw, 953 sizeof(union test_request)); 954 955 if (!test_request.bits.EDID_READ) 956 return edid_status; 957 958 test_response.bits.EDID_CHECKSUM_WRITE = 1; 959 960 dm_helpers_dp_write_dpcd(ctx, 961 link, 962 DP_TEST_EDID_CHECKSUM, 963 &sink->dc_edid.raw_edid[sink->dc_edid.length-1], 964 1); 965 966 dm_helpers_dp_write_dpcd(ctx, 967 link, 968 DP_TEST_RESPONSE, 969 &test_response.raw, 970 sizeof(test_response)); 971 972 } 973 974 return edid_status; 975 } 976 int dm_helper_dmub_aux_transfer_sync( 977 struct dc_context *ctx, 978 const struct dc_link *link, 979 struct aux_payload *payload, 980 enum aux_return_code_type *operation_result) 981 { 982 return amdgpu_dm_process_dmub_aux_transfer_sync(ctx, link->link_index, payload, 983 operation_result); 984 } 985 986 int dm_helpers_dmub_set_config_sync(struct dc_context *ctx, 987 const struct dc_link *link, 988 struct set_config_cmd_payload *payload, 989 enum set_config_status *operation_result) 990 { 991 return amdgpu_dm_process_dmub_set_config_sync(ctx, link->link_index, payload, 992 operation_result); 993 } 994 995 void dm_set_dcn_clocks(struct dc_context *ctx, struct dc_clocks *clks) 996 { 997 /* TODO: something */ 998 } 999 1000 void dm_helpers_smu_timeout(struct dc_context *ctx, unsigned int msg_id, unsigned int param, unsigned int timeout_us) 1001 { 1002 // TODO: 1003 //amdgpu_device_gpu_recover(dc_context->driver-context, NULL); 1004 } 1005 1006 void dm_helpers_init_panel_settings( 1007 struct dc_context *ctx, 1008 struct dc_panel_config *panel_config, 1009 struct dc_sink *sink) 1010 { 1011 // Extra Panel Power Sequence 1012 panel_config->pps.extra_t3_ms = sink->edid_caps.panel_patch.extra_t3_ms; 1013 panel_config->pps.extra_t7_ms = sink->edid_caps.panel_patch.extra_t7_ms; 1014 panel_config->pps.extra_delay_backlight_off = sink->edid_caps.panel_patch.extra_delay_backlight_off; 1015 panel_config->pps.extra_post_t7_ms = 0; 1016 panel_config->pps.extra_pre_t11_ms = 0; 1017 panel_config->pps.extra_t12_ms = sink->edid_caps.panel_patch.extra_t12_ms; 1018 panel_config->pps.extra_post_OUI_ms = 0; 1019 // Feature DSC 1020 panel_config->dsc.disable_dsc_edp = false; 1021 panel_config->dsc.force_dsc_edp_policy = 0; 1022 } 1023 1024 void dm_helpers_override_panel_settings( 1025 struct dc_context *ctx, 1026 struct dc_panel_config *panel_config) 1027 { 1028 // Feature DSC 1029 if (amdgpu_dc_debug_mask & DC_DISABLE_DSC) 1030 panel_config->dsc.disable_dsc_edp = true; 1031 } 1032 1033 void *dm_helpers_allocate_gpu_mem( 1034 struct dc_context *ctx, 1035 enum dc_gpu_mem_alloc_type type, 1036 size_t size, 1037 long long *addr) 1038 { 1039 struct amdgpu_device *adev = ctx->driver_context; 1040 struct dal_allocation *da; 1041 u32 domain = (type == DC_MEM_ALLOC_TYPE_GART) ? 1042 AMDGPU_GEM_DOMAIN_GTT : AMDGPU_GEM_DOMAIN_VRAM; 1043 int ret; 1044 1045 da = kzalloc(sizeof(struct dal_allocation), GFP_KERNEL); 1046 if (!da) 1047 return NULL; 1048 1049 ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE, 1050 domain, &da->bo, 1051 &da->gpu_addr, &da->cpu_ptr); 1052 1053 *addr = da->gpu_addr; 1054 1055 if (ret) { 1056 kfree(da); 1057 return NULL; 1058 } 1059 1060 /* add da to list in dm */ 1061 list_add(&da->list, &adev->dm.da_list); 1062 1063 return da->cpu_ptr; 1064 } 1065 1066 void dm_helpers_free_gpu_mem( 1067 struct dc_context *ctx, 1068 enum dc_gpu_mem_alloc_type type, 1069 void *pvMem) 1070 { 1071 struct amdgpu_device *adev = ctx->driver_context; 1072 struct dal_allocation *da; 1073 1074 /* walk the da list in DM */ 1075 list_for_each_entry(da, &adev->dm.da_list, list) { 1076 if (pvMem == da->cpu_ptr) { 1077 amdgpu_bo_free_kernel(&da->bo, &da->gpu_addr, &da->cpu_ptr); 1078 list_del(&da->list); 1079 kfree(da); 1080 break; 1081 } 1082 } 1083 } 1084 1085 bool dm_helpers_dmub_outbox_interrupt_control(struct dc_context *ctx, bool enable) 1086 { 1087 enum dc_irq_source irq_source; 1088 bool ret; 1089 1090 irq_source = DC_IRQ_SOURCE_DMCUB_OUTBOX; 1091 1092 ret = dc_interrupt_set(ctx->dc, irq_source, enable); 1093 1094 DRM_DEBUG_DRIVER("Dmub trace irq %sabling: r=%d\n", 1095 enable ? "en" : "dis", ret); 1096 return ret; 1097 } 1098 1099 void dm_helpers_mst_enable_stream_features(const struct dc_stream_state *stream) 1100 { 1101 /* TODO: virtual DPCD */ 1102 struct dc_link *link = stream->link; 1103 union down_spread_ctrl old_downspread; 1104 union down_spread_ctrl new_downspread; 1105 1106 if (link->aux_access_disabled) 1107 return; 1108 1109 if (!dm_helpers_dp_read_dpcd(link->ctx, link, DP_DOWNSPREAD_CTRL, 1110 &old_downspread.raw, 1111 sizeof(old_downspread))) 1112 return; 1113 1114 new_downspread.raw = old_downspread.raw; 1115 new_downspread.bits.IGNORE_MSA_TIMING_PARAM = 1116 (stream->ignore_msa_timing_param) ? 1 : 0; 1117 1118 if (new_downspread.raw != old_downspread.raw) 1119 dm_helpers_dp_write_dpcd(link->ctx, link, DP_DOWNSPREAD_CTRL, 1120 &new_downspread.raw, 1121 sizeof(new_downspread)); 1122 } 1123 1124 bool dm_helpers_dp_handle_test_pattern_request( 1125 struct dc_context *ctx, 1126 const struct dc_link *link, 1127 union link_test_pattern dpcd_test_pattern, 1128 union test_misc dpcd_test_params) 1129 { 1130 enum dp_test_pattern test_pattern; 1131 enum dp_test_pattern_color_space test_pattern_color_space = 1132 DP_TEST_PATTERN_COLOR_SPACE_UNDEFINED; 1133 enum dc_color_depth requestColorDepth = COLOR_DEPTH_UNDEFINED; 1134 enum dc_pixel_encoding requestPixelEncoding = PIXEL_ENCODING_UNDEFINED; 1135 struct pipe_ctx *pipes = link->dc->current_state->res_ctx.pipe_ctx; 1136 struct pipe_ctx *pipe_ctx = NULL; 1137 struct amdgpu_dm_connector *aconnector = link->priv; 1138 struct drm_device *dev = aconnector->base.dev; 1139 int i; 1140 1141 for (i = 0; i < MAX_PIPES; i++) { 1142 if (pipes[i].stream == NULL) 1143 continue; 1144 1145 if (pipes[i].stream->link == link && !pipes[i].top_pipe && 1146 !pipes[i].prev_odm_pipe) { 1147 pipe_ctx = &pipes[i]; 1148 break; 1149 } 1150 } 1151 1152 if (pipe_ctx == NULL) 1153 return false; 1154 1155 switch (dpcd_test_pattern.bits.PATTERN) { 1156 case LINK_TEST_PATTERN_COLOR_RAMP: 1157 test_pattern = DP_TEST_PATTERN_COLOR_RAMP; 1158 break; 1159 case LINK_TEST_PATTERN_VERTICAL_BARS: 1160 test_pattern = DP_TEST_PATTERN_VERTICAL_BARS; 1161 break; /* black and white */ 1162 case LINK_TEST_PATTERN_COLOR_SQUARES: 1163 test_pattern = (dpcd_test_params.bits.DYN_RANGE == 1164 TEST_DYN_RANGE_VESA ? 1165 DP_TEST_PATTERN_COLOR_SQUARES : 1166 DP_TEST_PATTERN_COLOR_SQUARES_CEA); 1167 break; 1168 default: 1169 test_pattern = DP_TEST_PATTERN_VIDEO_MODE; 1170 break; 1171 } 1172 1173 if (dpcd_test_params.bits.CLR_FORMAT == 0) 1174 test_pattern_color_space = DP_TEST_PATTERN_COLOR_SPACE_RGB; 1175 else 1176 test_pattern_color_space = dpcd_test_params.bits.YCBCR_COEFS ? 1177 DP_TEST_PATTERN_COLOR_SPACE_YCBCR709 : 1178 DP_TEST_PATTERN_COLOR_SPACE_YCBCR601; 1179 1180 switch (dpcd_test_params.bits.BPC) { 1181 case 0: // 6 bits 1182 requestColorDepth = COLOR_DEPTH_666; 1183 break; 1184 case 1: // 8 bits 1185 requestColorDepth = COLOR_DEPTH_888; 1186 break; 1187 case 2: // 10 bits 1188 requestColorDepth = COLOR_DEPTH_101010; 1189 break; 1190 case 3: // 12 bits 1191 requestColorDepth = COLOR_DEPTH_121212; 1192 break; 1193 default: 1194 break; 1195 } 1196 1197 switch (dpcd_test_params.bits.CLR_FORMAT) { 1198 case 0: 1199 requestPixelEncoding = PIXEL_ENCODING_RGB; 1200 break; 1201 case 1: 1202 requestPixelEncoding = PIXEL_ENCODING_YCBCR422; 1203 break; 1204 case 2: 1205 requestPixelEncoding = PIXEL_ENCODING_YCBCR444; 1206 break; 1207 default: 1208 requestPixelEncoding = PIXEL_ENCODING_RGB; 1209 break; 1210 } 1211 1212 if ((requestColorDepth != COLOR_DEPTH_UNDEFINED 1213 && pipe_ctx->stream->timing.display_color_depth != requestColorDepth) 1214 || (requestPixelEncoding != PIXEL_ENCODING_UNDEFINED 1215 && pipe_ctx->stream->timing.pixel_encoding != requestPixelEncoding)) { 1216 drm_dbg(dev, 1217 "original bpc %d pix encoding %d, changing to %d %d\n", 1218 pipe_ctx->stream->timing.display_color_depth, 1219 pipe_ctx->stream->timing.pixel_encoding, 1220 requestColorDepth, 1221 requestPixelEncoding); 1222 pipe_ctx->stream->timing.display_color_depth = requestColorDepth; 1223 pipe_ctx->stream->timing.pixel_encoding = requestPixelEncoding; 1224 1225 dc_link_update_dsc_config(pipe_ctx); 1226 1227 aconnector->timing_changed = true; 1228 /* store current timing */ 1229 if (aconnector->timing_requested) 1230 *aconnector->timing_requested = pipe_ctx->stream->timing; 1231 else 1232 drm_err(dev, "timing storage failed\n"); 1233 1234 } 1235 1236 pipe_ctx->stream->test_pattern.type = test_pattern; 1237 pipe_ctx->stream->test_pattern.color_space = test_pattern_color_space; 1238 1239 dc_link_dp_set_test_pattern( 1240 (struct dc_link *) link, 1241 test_pattern, 1242 test_pattern_color_space, 1243 NULL, 1244 NULL, 1245 0); 1246 1247 return false; 1248 } 1249 1250 void dm_set_phyd32clk(struct dc_context *ctx, int freq_khz) 1251 { 1252 // TODO 1253 } 1254 1255 void dm_helpers_enable_periodic_detection(struct dc_context *ctx, bool enable) 1256 { 1257 /* TODO: add periodic detection implementation */ 1258 } 1259 1260 void dm_helpers_dp_mst_update_branch_bandwidth( 1261 struct dc_context *ctx, 1262 struct dc_link *link) 1263 { 1264 // TODO 1265 } 1266 1267 static bool dm_is_freesync_pcon_whitelist(const uint32_t branch_dev_id) 1268 { 1269 bool ret_val = false; 1270 1271 switch (branch_dev_id) { 1272 case DP_BRANCH_DEVICE_ID_0060AD: 1273 case DP_BRANCH_DEVICE_ID_00E04C: 1274 case DP_BRANCH_DEVICE_ID_90CC24: 1275 ret_val = true; 1276 break; 1277 default: 1278 break; 1279 } 1280 1281 return ret_val; 1282 } 1283 1284 enum adaptive_sync_type dm_get_adaptive_sync_support_type(struct dc_link *link) 1285 { 1286 struct dpcd_caps *dpcd_caps = &link->dpcd_caps; 1287 enum adaptive_sync_type as_type = ADAPTIVE_SYNC_TYPE_NONE; 1288 1289 switch (dpcd_caps->dongle_type) { 1290 case DISPLAY_DONGLE_DP_HDMI_CONVERTER: 1291 if (dpcd_caps->adaptive_sync_caps.dp_adap_sync_caps.bits.ADAPTIVE_SYNC_SDP_SUPPORT == true && 1292 dpcd_caps->allow_invalid_MSA_timing_param == true && 1293 dm_is_freesync_pcon_whitelist(dpcd_caps->branch_dev_id)) 1294 as_type = FREESYNC_TYPE_PCON_IN_WHITELIST; 1295 break; 1296 default: 1297 break; 1298 } 1299 1300 return as_type; 1301 } 1302