1 /* 2 * Copyright 2007-8 Advanced Micro Devices, Inc. 3 * Copyright 2008 Red Hat Inc. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: Dave Airlie 24 * Alex Deucher 25 */ 26 #include <drm/drmP.h> 27 #include <drm/drm_edid.h> 28 #include <drm/drm_crtc_helper.h> 29 #include <drm/drm_fb_helper.h> 30 #include <drm/radeon_drm.h> 31 #include "radeon.h" 32 #include "atom.h" 33 34 #include <linux/pm_runtime.h> 35 36 void radeon_connector_hotplug(struct drm_connector *connector) 37 { 38 struct drm_device *dev = connector->dev; 39 struct radeon_device *rdev = dev->dev_private; 40 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 41 42 /* bail if the connector does not have hpd pin, e.g., 43 * VGA, TV, etc. 44 */ 45 if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) 46 return; 47 48 radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); 49 50 /* if the connector is already off, don't turn it back on */ 51 /* FIXME: This access isn't protected by any locks. */ 52 if (connector->dpms != DRM_MODE_DPMS_ON) 53 return; 54 55 /* just deal with DP (not eDP) here. */ 56 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { 57 struct radeon_connector_atom_dig *dig_connector = 58 radeon_connector->con_priv; 59 60 /* if existing sink type was not DP no need to retrain */ 61 if (dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_DISPLAYPORT) 62 return; 63 64 /* first get sink type as it may be reset after (un)plug */ 65 dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); 66 /* don't do anything if sink is not display port, i.e., 67 * passive dp->(dvi|hdmi) adaptor 68 */ 69 if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { 70 int saved_dpms = connector->dpms; 71 /* Only turn off the display if it's physically disconnected */ 72 if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { 73 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 74 } else if (radeon_dp_needs_link_train(radeon_connector)) { 75 /* set it to OFF so that drm_helper_connector_dpms() 76 * won't return immediately since the current state 77 * is ON at this point. 78 */ 79 connector->dpms = DRM_MODE_DPMS_OFF; 80 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); 81 } 82 connector->dpms = saved_dpms; 83 } 84 } 85 } 86 87 static void radeon_property_change_mode(struct drm_encoder *encoder) 88 { 89 struct drm_crtc *crtc = encoder->crtc; 90 91 if (crtc && crtc->enabled) { 92 drm_crtc_helper_set_mode(crtc, &crtc->mode, 93 crtc->x, crtc->y, crtc->primary->fb); 94 } 95 } 96 97 int radeon_get_monitor_bpc(struct drm_connector *connector) 98 { 99 struct drm_device *dev = connector->dev; 100 struct radeon_device *rdev = dev->dev_private; 101 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 102 struct radeon_connector_atom_dig *dig_connector; 103 int bpc = 8; 104 int mode_clock, max_tmds_clock; 105 106 switch (connector->connector_type) { 107 case DRM_MODE_CONNECTOR_DVII: 108 case DRM_MODE_CONNECTOR_HDMIB: 109 if (radeon_connector->use_digital) { 110 if (drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { 111 if (connector->display_info.bpc) 112 bpc = connector->display_info.bpc; 113 } 114 } 115 break; 116 case DRM_MODE_CONNECTOR_DVID: 117 case DRM_MODE_CONNECTOR_HDMIA: 118 if (drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { 119 if (connector->display_info.bpc) 120 bpc = connector->display_info.bpc; 121 } 122 break; 123 case DRM_MODE_CONNECTOR_DisplayPort: 124 dig_connector = radeon_connector->con_priv; 125 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || 126 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP) || 127 drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { 128 if (connector->display_info.bpc) 129 bpc = connector->display_info.bpc; 130 } 131 break; 132 case DRM_MODE_CONNECTOR_eDP: 133 case DRM_MODE_CONNECTOR_LVDS: 134 if (connector->display_info.bpc) 135 bpc = connector->display_info.bpc; 136 else if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev)) { 137 struct drm_connector_helper_funcs *connector_funcs = 138 connector->helper_private; 139 struct drm_encoder *encoder = connector_funcs->best_encoder(connector); 140 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 141 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 142 143 if (dig->lcd_misc & ATOM_PANEL_MISC_V13_6BIT_PER_COLOR) 144 bpc = 6; 145 else if (dig->lcd_misc & ATOM_PANEL_MISC_V13_8BIT_PER_COLOR) 146 bpc = 8; 147 } 148 break; 149 } 150 151 if (drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { 152 /* hdmi deep color only implemented on DCE4+ */ 153 if ((bpc > 8) && !ASIC_IS_DCE4(rdev)) { 154 DRM_DEBUG("%s: HDMI deep color %d bpc unsupported. Using 8 bpc.\n", 155 connector->name, bpc); 156 bpc = 8; 157 } 158 159 /* 160 * Pre DCE-8 hw can't handle > 12 bpc, and more than 12 bpc doesn't make 161 * much sense without support for > 12 bpc framebuffers. RGB 4:4:4 at 162 * 12 bpc is always supported on hdmi deep color sinks, as this is 163 * required by the HDMI-1.3 spec. Clamp to a safe 12 bpc maximum. 164 */ 165 if (bpc > 12) { 166 DRM_DEBUG("%s: HDMI deep color %d bpc unsupported. Using 12 bpc.\n", 167 connector->name, bpc); 168 bpc = 12; 169 } 170 171 /* Any defined maximum tmds clock limit we must not exceed? */ 172 if (connector->max_tmds_clock > 0) { 173 /* mode_clock is clock in kHz for mode to be modeset on this connector */ 174 mode_clock = radeon_connector->pixelclock_for_modeset; 175 176 /* Maximum allowable input clock in kHz */ 177 max_tmds_clock = connector->max_tmds_clock * 1000; 178 179 DRM_DEBUG("%s: hdmi mode dotclock %d kHz, max tmds input clock %d kHz.\n", 180 connector->name, mode_clock, max_tmds_clock); 181 182 /* Check if bpc is within clock limit. Try to degrade gracefully otherwise */ 183 if ((bpc == 12) && (mode_clock * 3/2 > max_tmds_clock)) { 184 if ((connector->display_info.edid_hdmi_dc_modes & DRM_EDID_HDMI_DC_30) && 185 (mode_clock * 5/4 <= max_tmds_clock)) 186 bpc = 10; 187 else 188 bpc = 8; 189 190 DRM_DEBUG("%s: HDMI deep color 12 bpc exceeds max tmds clock. Using %d bpc.\n", 191 connector->name, bpc); 192 } 193 194 if ((bpc == 10) && (mode_clock * 5/4 > max_tmds_clock)) { 195 bpc = 8; 196 DRM_DEBUG("%s: HDMI deep color 10 bpc exceeds max tmds clock. Using %d bpc.\n", 197 connector->name, bpc); 198 } 199 } 200 else if (bpc > 8) { 201 /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */ 202 DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n", 203 connector->name); 204 bpc = 8; 205 } 206 } 207 208 if ((radeon_deep_color == 0) && (bpc > 8)) { 209 DRM_DEBUG("%s: Deep color disabled. Set radeon module param deep_color=1 to enable.\n", 210 connector->name); 211 bpc = 8; 212 } 213 214 DRM_DEBUG("%s: Display bpc=%d, returned bpc=%d\n", 215 connector->name, connector->display_info.bpc, bpc); 216 217 return bpc; 218 } 219 220 static void 221 radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status) 222 { 223 struct drm_device *dev = connector->dev; 224 struct radeon_device *rdev = dev->dev_private; 225 struct drm_encoder *best_encoder = NULL; 226 struct drm_encoder *encoder = NULL; 227 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 228 bool connected; 229 int i; 230 231 best_encoder = connector_funcs->best_encoder(connector); 232 233 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 234 if (connector->encoder_ids[i] == 0) 235 break; 236 237 encoder = drm_encoder_find(connector->dev, 238 connector->encoder_ids[i]); 239 if (!encoder) 240 continue; 241 242 if ((encoder == best_encoder) && (status == connector_status_connected)) 243 connected = true; 244 else 245 connected = false; 246 247 if (rdev->is_atom_bios) 248 radeon_atombios_connected_scratch_regs(connector, encoder, connected); 249 else 250 radeon_combios_connected_scratch_regs(connector, encoder, connected); 251 252 } 253 } 254 255 static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type) 256 { 257 struct drm_encoder *encoder; 258 int i; 259 260 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 261 if (connector->encoder_ids[i] == 0) 262 break; 263 264 encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]); 265 if (!encoder) 266 continue; 267 268 if (encoder->encoder_type == encoder_type) 269 return encoder; 270 } 271 return NULL; 272 } 273 274 struct edid *radeon_connector_edid(struct drm_connector *connector) 275 { 276 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 277 struct drm_property_blob *edid_blob = connector->edid_blob_ptr; 278 279 if (radeon_connector->edid) { 280 return radeon_connector->edid; 281 } else if (edid_blob) { 282 struct edid *edid = kmemdup(edid_blob->data, edid_blob->length, GFP_KERNEL); 283 if (edid) 284 radeon_connector->edid = edid; 285 } 286 return radeon_connector->edid; 287 } 288 289 static void radeon_connector_get_edid(struct drm_connector *connector) 290 { 291 struct drm_device *dev = connector->dev; 292 struct radeon_device *rdev = dev->dev_private; 293 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 294 295 if (radeon_connector->edid) 296 return; 297 298 /* on hw with routers, select right port */ 299 if (radeon_connector->router.ddc_valid) 300 radeon_router_select_ddc_port(radeon_connector); 301 302 if ((radeon_connector_encoder_get_dp_bridge_encoder_id(connector) != 303 ENCODER_OBJECT_ID_NONE) && 304 radeon_connector->ddc_bus->has_aux) { 305 radeon_connector->edid = drm_get_edid(connector, 306 &radeon_connector->ddc_bus->aux.ddc); 307 } else if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) || 308 (connector->connector_type == DRM_MODE_CONNECTOR_eDP)) { 309 struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; 310 311 if ((dig->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT || 312 dig->dp_sink_type == CONNECTOR_OBJECT_ID_eDP) && 313 radeon_connector->ddc_bus->has_aux) 314 radeon_connector->edid = drm_get_edid(&radeon_connector->base, 315 &radeon_connector->ddc_bus->aux.ddc); 316 else if (radeon_connector->ddc_bus) 317 radeon_connector->edid = drm_get_edid(&radeon_connector->base, 318 &radeon_connector->ddc_bus->adapter); 319 } else if (radeon_connector->ddc_bus) { 320 radeon_connector->edid = drm_get_edid(&radeon_connector->base, 321 &radeon_connector->ddc_bus->adapter); 322 } 323 324 if (!radeon_connector->edid) { 325 if (rdev->is_atom_bios) { 326 /* some laptops provide a hardcoded edid in rom for LCDs */ 327 if (((connector->connector_type == DRM_MODE_CONNECTOR_LVDS) || 328 (connector->connector_type == DRM_MODE_CONNECTOR_eDP))) 329 radeon_connector->edid = radeon_bios_get_hardcoded_edid(rdev); 330 } else { 331 /* some servers provide a hardcoded edid in rom for KVMs */ 332 radeon_connector->edid = radeon_bios_get_hardcoded_edid(rdev); 333 } 334 } 335 } 336 337 static void radeon_connector_free_edid(struct drm_connector *connector) 338 { 339 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 340 341 if (radeon_connector->edid) { 342 kfree(radeon_connector->edid); 343 radeon_connector->edid = NULL; 344 } 345 } 346 347 static int radeon_ddc_get_modes(struct drm_connector *connector) 348 { 349 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 350 int ret; 351 352 if (radeon_connector->edid) { 353 drm_mode_connector_update_edid_property(connector, radeon_connector->edid); 354 ret = drm_add_edid_modes(connector, radeon_connector->edid); 355 drm_edid_to_eld(connector, radeon_connector->edid); 356 return ret; 357 } 358 drm_mode_connector_update_edid_property(connector, NULL); 359 return 0; 360 } 361 362 static struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector) 363 { 364 int enc_id = connector->encoder_ids[0]; 365 /* pick the encoder ids */ 366 if (enc_id) 367 return drm_encoder_find(connector->dev, enc_id); 368 return NULL; 369 } 370 371 static void radeon_get_native_mode(struct drm_connector *connector) 372 { 373 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 374 struct radeon_encoder *radeon_encoder; 375 376 if (encoder == NULL) 377 return; 378 379 radeon_encoder = to_radeon_encoder(encoder); 380 381 if (!list_empty(&connector->probed_modes)) { 382 struct drm_display_mode *preferred_mode = 383 list_first_entry(&connector->probed_modes, 384 struct drm_display_mode, head); 385 386 radeon_encoder->native_mode = *preferred_mode; 387 } else { 388 radeon_encoder->native_mode.clock = 0; 389 } 390 } 391 392 /* 393 * radeon_connector_analog_encoder_conflict_solve 394 * - search for other connectors sharing this encoder 395 * if priority is true, then set them disconnected if this is connected 396 * if priority is false, set us disconnected if they are connected 397 */ 398 static enum drm_connector_status 399 radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector, 400 struct drm_encoder *encoder, 401 enum drm_connector_status current_status, 402 bool priority) 403 { 404 struct drm_device *dev = connector->dev; 405 struct drm_connector *conflict; 406 struct radeon_connector *radeon_conflict; 407 int i; 408 409 list_for_each_entry(conflict, &dev->mode_config.connector_list, head) { 410 if (conflict == connector) 411 continue; 412 413 radeon_conflict = to_radeon_connector(conflict); 414 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 415 if (conflict->encoder_ids[i] == 0) 416 break; 417 418 /* if the IDs match */ 419 if (conflict->encoder_ids[i] == encoder->base.id) { 420 if (conflict->status != connector_status_connected) 421 continue; 422 423 if (radeon_conflict->use_digital) 424 continue; 425 426 if (priority == true) { 427 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", 428 conflict->name); 429 DRM_DEBUG_KMS("in favor of %s\n", 430 connector->name); 431 conflict->status = connector_status_disconnected; 432 radeon_connector_update_scratch_regs(conflict, connector_status_disconnected); 433 } else { 434 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", 435 connector->name); 436 DRM_DEBUG_KMS("in favor of %s\n", 437 conflict->name); 438 current_status = connector_status_disconnected; 439 } 440 break; 441 } 442 } 443 } 444 return current_status; 445 446 } 447 448 static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encoder) 449 { 450 struct drm_device *dev = encoder->dev; 451 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 452 struct drm_display_mode *mode = NULL; 453 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 454 455 if (native_mode->hdisplay != 0 && 456 native_mode->vdisplay != 0 && 457 native_mode->clock != 0) { 458 mode = drm_mode_duplicate(dev, native_mode); 459 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; 460 drm_mode_set_name(mode); 461 462 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode->name); 463 } else if (native_mode->hdisplay != 0 && 464 native_mode->vdisplay != 0) { 465 /* mac laptops without an edid */ 466 /* Note that this is not necessarily the exact panel mode, 467 * but an approximation based on the cvt formula. For these 468 * systems we should ideally read the mode info out of the 469 * registers or add a mode table, but this works and is much 470 * simpler. 471 */ 472 mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false); 473 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; 474 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name); 475 } 476 return mode; 477 } 478 479 static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector) 480 { 481 struct drm_device *dev = encoder->dev; 482 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 483 struct drm_display_mode *mode = NULL; 484 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 485 int i; 486 struct mode_size { 487 int w; 488 int h; 489 } common_modes[17] = { 490 { 640, 480}, 491 { 720, 480}, 492 { 800, 600}, 493 { 848, 480}, 494 {1024, 768}, 495 {1152, 768}, 496 {1280, 720}, 497 {1280, 800}, 498 {1280, 854}, 499 {1280, 960}, 500 {1280, 1024}, 501 {1440, 900}, 502 {1400, 1050}, 503 {1680, 1050}, 504 {1600, 1200}, 505 {1920, 1080}, 506 {1920, 1200} 507 }; 508 509 for (i = 0; i < 17; i++) { 510 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 511 if (common_modes[i].w > 1024 || 512 common_modes[i].h > 768) 513 continue; 514 } 515 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 516 if (common_modes[i].w > native_mode->hdisplay || 517 common_modes[i].h > native_mode->vdisplay || 518 (common_modes[i].w == native_mode->hdisplay && 519 common_modes[i].h == native_mode->vdisplay)) 520 continue; 521 } 522 if (common_modes[i].w < 320 || common_modes[i].h < 200) 523 continue; 524 525 mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); 526 drm_mode_probed_add(connector, mode); 527 } 528 } 529 530 static int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property, 531 uint64_t val) 532 { 533 struct drm_device *dev = connector->dev; 534 struct radeon_device *rdev = dev->dev_private; 535 struct drm_encoder *encoder; 536 struct radeon_encoder *radeon_encoder; 537 538 if (property == rdev->mode_info.coherent_mode_property) { 539 struct radeon_encoder_atom_dig *dig; 540 bool new_coherent_mode; 541 542 /* need to find digital encoder on connector */ 543 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 544 if (!encoder) 545 return 0; 546 547 radeon_encoder = to_radeon_encoder(encoder); 548 549 if (!radeon_encoder->enc_priv) 550 return 0; 551 552 dig = radeon_encoder->enc_priv; 553 new_coherent_mode = val ? true : false; 554 if (dig->coherent_mode != new_coherent_mode) { 555 dig->coherent_mode = new_coherent_mode; 556 radeon_property_change_mode(&radeon_encoder->base); 557 } 558 } 559 560 if (property == rdev->mode_info.audio_property) { 561 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 562 /* need to find digital encoder on connector */ 563 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 564 if (!encoder) 565 return 0; 566 567 radeon_encoder = to_radeon_encoder(encoder); 568 569 if (radeon_connector->audio != val) { 570 radeon_connector->audio = val; 571 radeon_property_change_mode(&radeon_encoder->base); 572 } 573 } 574 575 if (property == rdev->mode_info.dither_property) { 576 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 577 /* need to find digital encoder on connector */ 578 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 579 if (!encoder) 580 return 0; 581 582 radeon_encoder = to_radeon_encoder(encoder); 583 584 if (radeon_connector->dither != val) { 585 radeon_connector->dither = val; 586 radeon_property_change_mode(&radeon_encoder->base); 587 } 588 } 589 590 if (property == rdev->mode_info.underscan_property) { 591 /* need to find digital encoder on connector */ 592 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 593 if (!encoder) 594 return 0; 595 596 radeon_encoder = to_radeon_encoder(encoder); 597 598 if (radeon_encoder->underscan_type != val) { 599 radeon_encoder->underscan_type = val; 600 radeon_property_change_mode(&radeon_encoder->base); 601 } 602 } 603 604 if (property == rdev->mode_info.underscan_hborder_property) { 605 /* need to find digital encoder on connector */ 606 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 607 if (!encoder) 608 return 0; 609 610 radeon_encoder = to_radeon_encoder(encoder); 611 612 if (radeon_encoder->underscan_hborder != val) { 613 radeon_encoder->underscan_hborder = val; 614 radeon_property_change_mode(&radeon_encoder->base); 615 } 616 } 617 618 if (property == rdev->mode_info.underscan_vborder_property) { 619 /* need to find digital encoder on connector */ 620 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 621 if (!encoder) 622 return 0; 623 624 radeon_encoder = to_radeon_encoder(encoder); 625 626 if (radeon_encoder->underscan_vborder != val) { 627 radeon_encoder->underscan_vborder = val; 628 radeon_property_change_mode(&radeon_encoder->base); 629 } 630 } 631 632 if (property == rdev->mode_info.tv_std_property) { 633 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC); 634 if (!encoder) { 635 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC); 636 } 637 638 if (!encoder) 639 return 0; 640 641 radeon_encoder = to_radeon_encoder(encoder); 642 if (!radeon_encoder->enc_priv) 643 return 0; 644 if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) { 645 struct radeon_encoder_atom_dac *dac_int; 646 dac_int = radeon_encoder->enc_priv; 647 dac_int->tv_std = val; 648 } else { 649 struct radeon_encoder_tv_dac *dac_int; 650 dac_int = radeon_encoder->enc_priv; 651 dac_int->tv_std = val; 652 } 653 radeon_property_change_mode(&radeon_encoder->base); 654 } 655 656 if (property == rdev->mode_info.load_detect_property) { 657 struct radeon_connector *radeon_connector = 658 to_radeon_connector(connector); 659 660 if (val == 0) 661 radeon_connector->dac_load_detect = false; 662 else 663 radeon_connector->dac_load_detect = true; 664 } 665 666 if (property == rdev->mode_info.tmds_pll_property) { 667 struct radeon_encoder_int_tmds *tmds = NULL; 668 bool ret = false; 669 /* need to find digital encoder on connector */ 670 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 671 if (!encoder) 672 return 0; 673 674 radeon_encoder = to_radeon_encoder(encoder); 675 676 tmds = radeon_encoder->enc_priv; 677 if (!tmds) 678 return 0; 679 680 if (val == 0) { 681 if (rdev->is_atom_bios) 682 ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds); 683 else 684 ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds); 685 } 686 if (val == 1 || ret == false) { 687 radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds); 688 } 689 radeon_property_change_mode(&radeon_encoder->base); 690 } 691 692 if (property == dev->mode_config.scaling_mode_property) { 693 enum radeon_rmx_type rmx_type; 694 695 if (connector->encoder) 696 radeon_encoder = to_radeon_encoder(connector->encoder); 697 else { 698 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 699 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); 700 } 701 702 switch (val) { 703 default: 704 case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break; 705 case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break; 706 case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break; 707 case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break; 708 } 709 if (radeon_encoder->rmx_type == rmx_type) 710 return 0; 711 712 if ((rmx_type != DRM_MODE_SCALE_NONE) && 713 (radeon_encoder->native_mode.clock == 0)) 714 return 0; 715 716 radeon_encoder->rmx_type = rmx_type; 717 718 radeon_property_change_mode(&radeon_encoder->base); 719 } 720 721 return 0; 722 } 723 724 static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder, 725 struct drm_connector *connector) 726 { 727 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 728 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 729 struct drm_display_mode *t, *mode; 730 731 /* If the EDID preferred mode doesn't match the native mode, use it */ 732 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { 733 if (mode->type & DRM_MODE_TYPE_PREFERRED) { 734 if (mode->hdisplay != native_mode->hdisplay || 735 mode->vdisplay != native_mode->vdisplay) 736 memcpy(native_mode, mode, sizeof(*mode)); 737 } 738 } 739 740 /* Try to get native mode details from EDID if necessary */ 741 if (!native_mode->clock) { 742 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { 743 if (mode->hdisplay == native_mode->hdisplay && 744 mode->vdisplay == native_mode->vdisplay) { 745 *native_mode = *mode; 746 drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V); 747 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n"); 748 break; 749 } 750 } 751 } 752 753 if (!native_mode->clock) { 754 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n"); 755 radeon_encoder->rmx_type = RMX_OFF; 756 } 757 } 758 759 static int radeon_lvds_get_modes(struct drm_connector *connector) 760 { 761 struct drm_encoder *encoder; 762 int ret = 0; 763 struct drm_display_mode *mode; 764 765 radeon_connector_get_edid(connector); 766 ret = radeon_ddc_get_modes(connector); 767 if (ret > 0) { 768 encoder = radeon_best_single_encoder(connector); 769 if (encoder) { 770 radeon_fixup_lvds_native_mode(encoder, connector); 771 /* add scaled modes */ 772 radeon_add_common_modes(encoder, connector); 773 } 774 return ret; 775 } 776 777 encoder = radeon_best_single_encoder(connector); 778 if (!encoder) 779 return 0; 780 781 /* we have no EDID modes */ 782 mode = radeon_fp_native_mode(encoder); 783 if (mode) { 784 ret = 1; 785 drm_mode_probed_add(connector, mode); 786 /* add the width/height from vbios tables if available */ 787 connector->display_info.width_mm = mode->width_mm; 788 connector->display_info.height_mm = mode->height_mm; 789 /* add scaled modes */ 790 radeon_add_common_modes(encoder, connector); 791 } 792 793 return ret; 794 } 795 796 static int radeon_lvds_mode_valid(struct drm_connector *connector, 797 struct drm_display_mode *mode) 798 { 799 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 800 801 if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) 802 return MODE_PANEL; 803 804 if (encoder) { 805 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 806 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 807 808 /* AVIVO hardware supports downscaling modes larger than the panel 809 * to the panel size, but I'm not sure this is desirable. 810 */ 811 if ((mode->hdisplay > native_mode->hdisplay) || 812 (mode->vdisplay > native_mode->vdisplay)) 813 return MODE_PANEL; 814 815 /* if scaling is disabled, block non-native modes */ 816 if (radeon_encoder->rmx_type == RMX_OFF) { 817 if ((mode->hdisplay != native_mode->hdisplay) || 818 (mode->vdisplay != native_mode->vdisplay)) 819 return MODE_PANEL; 820 } 821 } 822 823 return MODE_OK; 824 } 825 826 static enum drm_connector_status 827 radeon_lvds_detect(struct drm_connector *connector, bool force) 828 { 829 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 830 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 831 enum drm_connector_status ret = connector_status_disconnected; 832 int r; 833 834 r = pm_runtime_get_sync(connector->dev->dev); 835 if (r < 0) 836 return connector_status_disconnected; 837 838 if (encoder) { 839 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 840 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 841 842 /* check if panel is valid */ 843 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) 844 ret = connector_status_connected; 845 846 } 847 848 /* check for edid as well */ 849 radeon_connector_get_edid(connector); 850 if (radeon_connector->edid) 851 ret = connector_status_connected; 852 /* check acpi lid status ??? */ 853 854 radeon_connector_update_scratch_regs(connector, ret); 855 pm_runtime_mark_last_busy(connector->dev->dev); 856 pm_runtime_put_autosuspend(connector->dev->dev); 857 return ret; 858 } 859 860 static void radeon_connector_destroy(struct drm_connector *connector) 861 { 862 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 863 864 radeon_connector_free_edid(connector); 865 kfree(radeon_connector->con_priv); 866 drm_connector_unregister(connector); 867 drm_connector_cleanup(connector); 868 kfree(connector); 869 } 870 871 static int radeon_lvds_set_property(struct drm_connector *connector, 872 struct drm_property *property, 873 uint64_t value) 874 { 875 struct drm_device *dev = connector->dev; 876 struct radeon_encoder *radeon_encoder; 877 enum radeon_rmx_type rmx_type; 878 879 DRM_DEBUG_KMS("\n"); 880 if (property != dev->mode_config.scaling_mode_property) 881 return 0; 882 883 if (connector->encoder) 884 radeon_encoder = to_radeon_encoder(connector->encoder); 885 else { 886 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 887 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); 888 } 889 890 switch (value) { 891 case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break; 892 case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break; 893 case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break; 894 default: 895 case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break; 896 } 897 if (radeon_encoder->rmx_type == rmx_type) 898 return 0; 899 900 radeon_encoder->rmx_type = rmx_type; 901 902 radeon_property_change_mode(&radeon_encoder->base); 903 return 0; 904 } 905 906 907 static const struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = { 908 .get_modes = radeon_lvds_get_modes, 909 .mode_valid = radeon_lvds_mode_valid, 910 .best_encoder = radeon_best_single_encoder, 911 }; 912 913 static const struct drm_connector_funcs radeon_lvds_connector_funcs = { 914 .dpms = drm_helper_connector_dpms, 915 .detect = radeon_lvds_detect, 916 .fill_modes = drm_helper_probe_single_connector_modes, 917 .destroy = radeon_connector_destroy, 918 .set_property = radeon_lvds_set_property, 919 }; 920 921 static int radeon_vga_get_modes(struct drm_connector *connector) 922 { 923 int ret; 924 925 radeon_connector_get_edid(connector); 926 ret = radeon_ddc_get_modes(connector); 927 928 radeon_get_native_mode(connector); 929 930 return ret; 931 } 932 933 static int radeon_vga_mode_valid(struct drm_connector *connector, 934 struct drm_display_mode *mode) 935 { 936 struct drm_device *dev = connector->dev; 937 struct radeon_device *rdev = dev->dev_private; 938 939 /* XXX check mode bandwidth */ 940 941 if ((mode->clock / 10) > rdev->clock.max_pixel_clock) 942 return MODE_CLOCK_HIGH; 943 944 return MODE_OK; 945 } 946 947 static enum drm_connector_status 948 radeon_vga_detect(struct drm_connector *connector, bool force) 949 { 950 struct drm_device *dev = connector->dev; 951 struct radeon_device *rdev = dev->dev_private; 952 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 953 struct drm_encoder *encoder; 954 struct drm_encoder_helper_funcs *encoder_funcs; 955 bool dret = false; 956 enum drm_connector_status ret = connector_status_disconnected; 957 int r; 958 959 r = pm_runtime_get_sync(connector->dev->dev); 960 if (r < 0) 961 return connector_status_disconnected; 962 963 encoder = radeon_best_single_encoder(connector); 964 if (!encoder) 965 ret = connector_status_disconnected; 966 967 if (radeon_connector->ddc_bus) 968 dret = radeon_ddc_probe(radeon_connector, false); 969 if (dret) { 970 radeon_connector->detected_by_load = false; 971 radeon_connector_free_edid(connector); 972 radeon_connector_get_edid(connector); 973 974 if (!radeon_connector->edid) { 975 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", 976 connector->name); 977 ret = connector_status_connected; 978 } else { 979 radeon_connector->use_digital = 980 !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); 981 982 /* some oems have boards with separate digital and analog connectors 983 * with a shared ddc line (often vga + hdmi) 984 */ 985 if (radeon_connector->use_digital && radeon_connector->shared_ddc) { 986 radeon_connector_free_edid(connector); 987 ret = connector_status_disconnected; 988 } else { 989 ret = connector_status_connected; 990 } 991 } 992 } else { 993 994 /* if we aren't forcing don't do destructive polling */ 995 if (!force) { 996 /* only return the previous status if we last 997 * detected a monitor via load. 998 */ 999 if (radeon_connector->detected_by_load) 1000 ret = connector->status; 1001 goto out; 1002 } 1003 1004 if (radeon_connector->dac_load_detect && encoder) { 1005 encoder_funcs = encoder->helper_private; 1006 ret = encoder_funcs->detect(encoder, connector); 1007 if (ret != connector_status_disconnected) 1008 radeon_connector->detected_by_load = true; 1009 } 1010 } 1011 1012 if (ret == connector_status_connected) 1013 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); 1014 1015 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the 1016 * vbios to deal with KVMs. If we have one and are not able to detect a monitor 1017 * by other means, assume the CRT is connected and use that EDID. 1018 */ 1019 if ((!rdev->is_atom_bios) && 1020 (ret == connector_status_disconnected) && 1021 rdev->mode_info.bios_hardcoded_edid_size) { 1022 ret = connector_status_connected; 1023 } 1024 1025 radeon_connector_update_scratch_regs(connector, ret); 1026 1027 out: 1028 pm_runtime_mark_last_busy(connector->dev->dev); 1029 pm_runtime_put_autosuspend(connector->dev->dev); 1030 1031 return ret; 1032 } 1033 1034 static const struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = { 1035 .get_modes = radeon_vga_get_modes, 1036 .mode_valid = radeon_vga_mode_valid, 1037 .best_encoder = radeon_best_single_encoder, 1038 }; 1039 1040 static const struct drm_connector_funcs radeon_vga_connector_funcs = { 1041 .dpms = drm_helper_connector_dpms, 1042 .detect = radeon_vga_detect, 1043 .fill_modes = drm_helper_probe_single_connector_modes, 1044 .destroy = radeon_connector_destroy, 1045 .set_property = radeon_connector_set_property, 1046 }; 1047 1048 static int radeon_tv_get_modes(struct drm_connector *connector) 1049 { 1050 struct drm_device *dev = connector->dev; 1051 struct radeon_device *rdev = dev->dev_private; 1052 struct drm_display_mode *tv_mode; 1053 struct drm_encoder *encoder; 1054 1055 encoder = radeon_best_single_encoder(connector); 1056 if (!encoder) 1057 return 0; 1058 1059 /* avivo chips can scale any mode */ 1060 if (rdev->family >= CHIP_RS600) 1061 /* add scaled modes */ 1062 radeon_add_common_modes(encoder, connector); 1063 else { 1064 /* only 800x600 is supported right now on pre-avivo chips */ 1065 tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false); 1066 tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; 1067 drm_mode_probed_add(connector, tv_mode); 1068 } 1069 return 1; 1070 } 1071 1072 static int radeon_tv_mode_valid(struct drm_connector *connector, 1073 struct drm_display_mode *mode) 1074 { 1075 if ((mode->hdisplay > 1024) || (mode->vdisplay > 768)) 1076 return MODE_CLOCK_RANGE; 1077 return MODE_OK; 1078 } 1079 1080 static enum drm_connector_status 1081 radeon_tv_detect(struct drm_connector *connector, bool force) 1082 { 1083 struct drm_encoder *encoder; 1084 struct drm_encoder_helper_funcs *encoder_funcs; 1085 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1086 enum drm_connector_status ret = connector_status_disconnected; 1087 int r; 1088 1089 if (!radeon_connector->dac_load_detect) 1090 return ret; 1091 1092 r = pm_runtime_get_sync(connector->dev->dev); 1093 if (r < 0) 1094 return connector_status_disconnected; 1095 1096 encoder = radeon_best_single_encoder(connector); 1097 if (!encoder) 1098 ret = connector_status_disconnected; 1099 else { 1100 encoder_funcs = encoder->helper_private; 1101 ret = encoder_funcs->detect(encoder, connector); 1102 } 1103 if (ret == connector_status_connected) 1104 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); 1105 radeon_connector_update_scratch_regs(connector, ret); 1106 pm_runtime_mark_last_busy(connector->dev->dev); 1107 pm_runtime_put_autosuspend(connector->dev->dev); 1108 return ret; 1109 } 1110 1111 static const struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = { 1112 .get_modes = radeon_tv_get_modes, 1113 .mode_valid = radeon_tv_mode_valid, 1114 .best_encoder = radeon_best_single_encoder, 1115 }; 1116 1117 static const struct drm_connector_funcs radeon_tv_connector_funcs = { 1118 .dpms = drm_helper_connector_dpms, 1119 .detect = radeon_tv_detect, 1120 .fill_modes = drm_helper_probe_single_connector_modes, 1121 .destroy = radeon_connector_destroy, 1122 .set_property = radeon_connector_set_property, 1123 }; 1124 1125 static bool radeon_check_hpd_status_unchanged(struct drm_connector *connector) 1126 { 1127 struct drm_device *dev = connector->dev; 1128 struct radeon_device *rdev = dev->dev_private; 1129 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1130 enum drm_connector_status status; 1131 1132 /* We only trust HPD on R600 and newer ASICS. */ 1133 if (rdev->family >= CHIP_R600 1134 && radeon_connector->hpd.hpd != RADEON_HPD_NONE) { 1135 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) 1136 status = connector_status_connected; 1137 else 1138 status = connector_status_disconnected; 1139 if (connector->status == status) 1140 return true; 1141 } 1142 1143 return false; 1144 } 1145 1146 /* 1147 * DVI is complicated 1148 * Do a DDC probe, if DDC probe passes, get the full EDID so 1149 * we can do analog/digital monitor detection at this point. 1150 * If the monitor is an analog monitor or we got no DDC, 1151 * we need to find the DAC encoder object for this connector. 1152 * If we got no DDC, we do load detection on the DAC encoder object. 1153 * If we got analog DDC or load detection passes on the DAC encoder 1154 * we have to check if this analog encoder is shared with anyone else (TV) 1155 * if its shared we have to set the other connector to disconnected. 1156 */ 1157 static enum drm_connector_status 1158 radeon_dvi_detect(struct drm_connector *connector, bool force) 1159 { 1160 struct drm_device *dev = connector->dev; 1161 struct radeon_device *rdev = dev->dev_private; 1162 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1163 struct drm_encoder *encoder = NULL; 1164 struct drm_encoder_helper_funcs *encoder_funcs; 1165 int i, r; 1166 enum drm_connector_status ret = connector_status_disconnected; 1167 bool dret = false, broken_edid = false; 1168 1169 r = pm_runtime_get_sync(connector->dev->dev); 1170 if (r < 0) 1171 return connector_status_disconnected; 1172 1173 if (!force && radeon_check_hpd_status_unchanged(connector)) { 1174 ret = connector->status; 1175 goto exit; 1176 } 1177 1178 if (radeon_connector->ddc_bus) 1179 dret = radeon_ddc_probe(radeon_connector, false); 1180 if (dret) { 1181 radeon_connector->detected_by_load = false; 1182 radeon_connector_free_edid(connector); 1183 radeon_connector_get_edid(connector); 1184 1185 if (!radeon_connector->edid) { 1186 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", 1187 connector->name); 1188 /* rs690 seems to have a problem with connectors not existing and always 1189 * return a block of 0's. If we see this just stop polling on this output */ 1190 if ((rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) && 1191 radeon_connector->base.null_edid_counter) { 1192 ret = connector_status_disconnected; 1193 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", 1194 connector->name); 1195 radeon_connector->ddc_bus = NULL; 1196 } else { 1197 ret = connector_status_connected; 1198 broken_edid = true; /* defer use_digital to later */ 1199 } 1200 } else { 1201 radeon_connector->use_digital = 1202 !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); 1203 1204 /* some oems have boards with separate digital and analog connectors 1205 * with a shared ddc line (often vga + hdmi) 1206 */ 1207 if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) { 1208 radeon_connector_free_edid(connector); 1209 ret = connector_status_disconnected; 1210 } else { 1211 ret = connector_status_connected; 1212 } 1213 /* This gets complicated. We have boards with VGA + HDMI with a 1214 * shared DDC line and we have boards with DVI-D + HDMI with a shared 1215 * DDC line. The latter is more complex because with DVI<->HDMI adapters 1216 * you don't really know what's connected to which port as both are digital. 1217 */ 1218 if (radeon_connector->shared_ddc && (ret == connector_status_connected)) { 1219 struct drm_connector *list_connector; 1220 struct radeon_connector *list_radeon_connector; 1221 list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) { 1222 if (connector == list_connector) 1223 continue; 1224 list_radeon_connector = to_radeon_connector(list_connector); 1225 if (list_radeon_connector->shared_ddc && 1226 (list_radeon_connector->ddc_bus->rec.i2c_id == 1227 radeon_connector->ddc_bus->rec.i2c_id)) { 1228 /* cases where both connectors are digital */ 1229 if (list_connector->connector_type != DRM_MODE_CONNECTOR_VGA) { 1230 /* hpd is our only option in this case */ 1231 if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { 1232 radeon_connector_free_edid(connector); 1233 ret = connector_status_disconnected; 1234 } 1235 } 1236 } 1237 } 1238 } 1239 } 1240 } 1241 1242 if ((ret == connector_status_connected) && (radeon_connector->use_digital == true)) 1243 goto out; 1244 1245 /* DVI-D and HDMI-A are digital only */ 1246 if ((connector->connector_type == DRM_MODE_CONNECTOR_DVID) || 1247 (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA)) 1248 goto out; 1249 1250 /* if we aren't forcing don't do destructive polling */ 1251 if (!force) { 1252 /* only return the previous status if we last 1253 * detected a monitor via load. 1254 */ 1255 if (radeon_connector->detected_by_load) 1256 ret = connector->status; 1257 goto out; 1258 } 1259 1260 /* find analog encoder */ 1261 if (radeon_connector->dac_load_detect) { 1262 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1263 if (connector->encoder_ids[i] == 0) 1264 break; 1265 1266 encoder = drm_encoder_find(connector->dev, 1267 connector->encoder_ids[i]); 1268 if (!encoder) 1269 continue; 1270 1271 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC && 1272 encoder->encoder_type != DRM_MODE_ENCODER_TVDAC) 1273 continue; 1274 1275 encoder_funcs = encoder->helper_private; 1276 if (encoder_funcs->detect) { 1277 if (!broken_edid) { 1278 if (ret != connector_status_connected) { 1279 /* deal with analog monitors without DDC */ 1280 ret = encoder_funcs->detect(encoder, connector); 1281 if (ret == connector_status_connected) { 1282 radeon_connector->use_digital = false; 1283 } 1284 if (ret != connector_status_disconnected) 1285 radeon_connector->detected_by_load = true; 1286 } 1287 } else { 1288 enum drm_connector_status lret; 1289 /* assume digital unless load detected otherwise */ 1290 radeon_connector->use_digital = true; 1291 lret = encoder_funcs->detect(encoder, connector); 1292 DRM_DEBUG_KMS("load_detect %x returned: %x\n",encoder->encoder_type,lret); 1293 if (lret == connector_status_connected) 1294 radeon_connector->use_digital = false; 1295 } 1296 break; 1297 } 1298 } 1299 } 1300 1301 if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) && 1302 encoder) { 1303 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); 1304 } 1305 1306 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the 1307 * vbios to deal with KVMs. If we have one and are not able to detect a monitor 1308 * by other means, assume the DFP is connected and use that EDID. In most 1309 * cases the DVI port is actually a virtual KVM port connected to the service 1310 * processor. 1311 */ 1312 out: 1313 if ((!rdev->is_atom_bios) && 1314 (ret == connector_status_disconnected) && 1315 rdev->mode_info.bios_hardcoded_edid_size) { 1316 radeon_connector->use_digital = true; 1317 ret = connector_status_connected; 1318 } 1319 1320 /* updated in get modes as well since we need to know if it's analog or digital */ 1321 radeon_connector_update_scratch_regs(connector, ret); 1322 1323 exit: 1324 pm_runtime_mark_last_busy(connector->dev->dev); 1325 pm_runtime_put_autosuspend(connector->dev->dev); 1326 1327 return ret; 1328 } 1329 1330 /* okay need to be smart in here about which encoder to pick */ 1331 static struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector) 1332 { 1333 int enc_id = connector->encoder_ids[0]; 1334 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1335 struct drm_encoder *encoder; 1336 int i; 1337 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1338 if (connector->encoder_ids[i] == 0) 1339 break; 1340 1341 encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]); 1342 if (!encoder) 1343 continue; 1344 1345 if (radeon_connector->use_digital == true) { 1346 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) 1347 return encoder; 1348 } else { 1349 if (encoder->encoder_type == DRM_MODE_ENCODER_DAC || 1350 encoder->encoder_type == DRM_MODE_ENCODER_TVDAC) 1351 return encoder; 1352 } 1353 } 1354 1355 /* see if we have a default encoder TODO */ 1356 1357 /* then check use digitial */ 1358 /* pick the first one */ 1359 if (enc_id) 1360 return drm_encoder_find(connector->dev, enc_id); 1361 return NULL; 1362 } 1363 1364 static void radeon_dvi_force(struct drm_connector *connector) 1365 { 1366 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1367 if (connector->force == DRM_FORCE_ON) 1368 radeon_connector->use_digital = false; 1369 if (connector->force == DRM_FORCE_ON_DIGITAL) 1370 radeon_connector->use_digital = true; 1371 } 1372 1373 static int radeon_dvi_mode_valid(struct drm_connector *connector, 1374 struct drm_display_mode *mode) 1375 { 1376 struct drm_device *dev = connector->dev; 1377 struct radeon_device *rdev = dev->dev_private; 1378 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1379 1380 /* XXX check mode bandwidth */ 1381 1382 /* clocks over 135 MHz have heat issues with DVI on RV100 */ 1383 if (radeon_connector->use_digital && 1384 (rdev->family == CHIP_RV100) && 1385 (mode->clock > 135000)) 1386 return MODE_CLOCK_HIGH; 1387 1388 if (radeon_connector->use_digital && (mode->clock > 165000)) { 1389 if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) || 1390 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) || 1391 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) 1392 return MODE_OK; 1393 else if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { 1394 /* HDMI 1.3+ supports max clock of 340 Mhz */ 1395 if (mode->clock > 340000) 1396 return MODE_CLOCK_HIGH; 1397 else 1398 return MODE_OK; 1399 } else { 1400 return MODE_CLOCK_HIGH; 1401 } 1402 } 1403 1404 /* check against the max pixel clock */ 1405 if ((mode->clock / 10) > rdev->clock.max_pixel_clock) 1406 return MODE_CLOCK_HIGH; 1407 1408 return MODE_OK; 1409 } 1410 1411 static const struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = { 1412 .get_modes = radeon_vga_get_modes, 1413 .mode_valid = radeon_dvi_mode_valid, 1414 .best_encoder = radeon_dvi_encoder, 1415 }; 1416 1417 static const struct drm_connector_funcs radeon_dvi_connector_funcs = { 1418 .dpms = drm_helper_connector_dpms, 1419 .detect = radeon_dvi_detect, 1420 .fill_modes = drm_helper_probe_single_connector_modes, 1421 .set_property = radeon_connector_set_property, 1422 .destroy = radeon_connector_destroy, 1423 .force = radeon_dvi_force, 1424 }; 1425 1426 static int radeon_dp_get_modes(struct drm_connector *connector) 1427 { 1428 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1429 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1430 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 1431 int ret; 1432 1433 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || 1434 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { 1435 struct drm_display_mode *mode; 1436 1437 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 1438 if (!radeon_dig_connector->edp_on) 1439 atombios_set_edp_panel_power(connector, 1440 ATOM_TRANSMITTER_ACTION_POWER_ON); 1441 radeon_connector_get_edid(connector); 1442 ret = radeon_ddc_get_modes(connector); 1443 if (!radeon_dig_connector->edp_on) 1444 atombios_set_edp_panel_power(connector, 1445 ATOM_TRANSMITTER_ACTION_POWER_OFF); 1446 } else { 1447 /* need to setup ddc on the bridge */ 1448 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) != 1449 ENCODER_OBJECT_ID_NONE) { 1450 if (encoder) 1451 radeon_atom_ext_encoder_setup_ddc(encoder); 1452 } 1453 radeon_connector_get_edid(connector); 1454 ret = radeon_ddc_get_modes(connector); 1455 } 1456 1457 if (ret > 0) { 1458 if (encoder) { 1459 radeon_fixup_lvds_native_mode(encoder, connector); 1460 /* add scaled modes */ 1461 radeon_add_common_modes(encoder, connector); 1462 } 1463 return ret; 1464 } 1465 1466 if (!encoder) 1467 return 0; 1468 1469 /* we have no EDID modes */ 1470 mode = radeon_fp_native_mode(encoder); 1471 if (mode) { 1472 ret = 1; 1473 drm_mode_probed_add(connector, mode); 1474 /* add the width/height from vbios tables if available */ 1475 connector->display_info.width_mm = mode->width_mm; 1476 connector->display_info.height_mm = mode->height_mm; 1477 /* add scaled modes */ 1478 radeon_add_common_modes(encoder, connector); 1479 } 1480 } else { 1481 /* need to setup ddc on the bridge */ 1482 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) != 1483 ENCODER_OBJECT_ID_NONE) { 1484 if (encoder) 1485 radeon_atom_ext_encoder_setup_ddc(encoder); 1486 } 1487 radeon_connector_get_edid(connector); 1488 ret = radeon_ddc_get_modes(connector); 1489 1490 radeon_get_native_mode(connector); 1491 } 1492 1493 return ret; 1494 } 1495 1496 u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connector) 1497 { 1498 struct drm_encoder *encoder; 1499 struct radeon_encoder *radeon_encoder; 1500 int i; 1501 1502 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1503 if (connector->encoder_ids[i] == 0) 1504 break; 1505 1506 encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]); 1507 if (!encoder) 1508 continue; 1509 1510 radeon_encoder = to_radeon_encoder(encoder); 1511 1512 switch (radeon_encoder->encoder_id) { 1513 case ENCODER_OBJECT_ID_TRAVIS: 1514 case ENCODER_OBJECT_ID_NUTMEG: 1515 return radeon_encoder->encoder_id; 1516 default: 1517 break; 1518 } 1519 } 1520 1521 return ENCODER_OBJECT_ID_NONE; 1522 } 1523 1524 static bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector) 1525 { 1526 struct drm_encoder *encoder; 1527 struct radeon_encoder *radeon_encoder; 1528 int i; 1529 bool found = false; 1530 1531 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1532 if (connector->encoder_ids[i] == 0) 1533 break; 1534 1535 encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]); 1536 if (!encoder) 1537 continue; 1538 1539 radeon_encoder = to_radeon_encoder(encoder); 1540 if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2) 1541 found = true; 1542 } 1543 1544 return found; 1545 } 1546 1547 bool radeon_connector_is_dp12_capable(struct drm_connector *connector) 1548 { 1549 struct drm_device *dev = connector->dev; 1550 struct radeon_device *rdev = dev->dev_private; 1551 1552 if (ASIC_IS_DCE5(rdev) && 1553 (rdev->clock.default_dispclk >= 53900) && 1554 radeon_connector_encoder_is_hbr2(connector)) { 1555 return true; 1556 } 1557 1558 return false; 1559 } 1560 1561 static enum drm_connector_status 1562 radeon_dp_detect(struct drm_connector *connector, bool force) 1563 { 1564 struct drm_device *dev = connector->dev; 1565 struct radeon_device *rdev = dev->dev_private; 1566 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1567 enum drm_connector_status ret = connector_status_disconnected; 1568 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1569 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 1570 int r; 1571 1572 r = pm_runtime_get_sync(connector->dev->dev); 1573 if (r < 0) 1574 return connector_status_disconnected; 1575 1576 if (!force && radeon_check_hpd_status_unchanged(connector)) { 1577 ret = connector->status; 1578 goto out; 1579 } 1580 1581 radeon_connector_free_edid(connector); 1582 1583 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || 1584 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { 1585 if (encoder) { 1586 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1587 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 1588 1589 /* check if panel is valid */ 1590 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) 1591 ret = connector_status_connected; 1592 } 1593 /* eDP is always DP */ 1594 radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; 1595 if (!radeon_dig_connector->edp_on) 1596 atombios_set_edp_panel_power(connector, 1597 ATOM_TRANSMITTER_ACTION_POWER_ON); 1598 if (radeon_dp_getdpcd(radeon_connector)) 1599 ret = connector_status_connected; 1600 if (!radeon_dig_connector->edp_on) 1601 atombios_set_edp_panel_power(connector, 1602 ATOM_TRANSMITTER_ACTION_POWER_OFF); 1603 } else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) != 1604 ENCODER_OBJECT_ID_NONE) { 1605 /* DP bridges are always DP */ 1606 radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; 1607 /* get the DPCD from the bridge */ 1608 radeon_dp_getdpcd(radeon_connector); 1609 1610 if (encoder) { 1611 /* setup ddc on the bridge */ 1612 radeon_atom_ext_encoder_setup_ddc(encoder); 1613 /* bridge chips are always aux */ 1614 if (radeon_ddc_probe(radeon_connector, true)) /* try DDC */ 1615 ret = connector_status_connected; 1616 else if (radeon_connector->dac_load_detect) { /* try load detection */ 1617 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; 1618 ret = encoder_funcs->detect(encoder, connector); 1619 } 1620 } 1621 } else { 1622 radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); 1623 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { 1624 ret = connector_status_connected; 1625 if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) 1626 radeon_dp_getdpcd(radeon_connector); 1627 } else { 1628 if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { 1629 if (radeon_dp_getdpcd(radeon_connector)) 1630 ret = connector_status_connected; 1631 } else { 1632 /* try non-aux ddc (DP to DVI/HDMI/etc. adapter) */ 1633 if (radeon_ddc_probe(radeon_connector, false)) 1634 ret = connector_status_connected; 1635 } 1636 } 1637 } 1638 1639 radeon_connector_update_scratch_regs(connector, ret); 1640 out: 1641 pm_runtime_mark_last_busy(connector->dev->dev); 1642 pm_runtime_put_autosuspend(connector->dev->dev); 1643 1644 return ret; 1645 } 1646 1647 static int radeon_dp_mode_valid(struct drm_connector *connector, 1648 struct drm_display_mode *mode) 1649 { 1650 struct drm_device *dev = connector->dev; 1651 struct radeon_device *rdev = dev->dev_private; 1652 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1653 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1654 1655 /* XXX check mode bandwidth */ 1656 1657 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || 1658 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { 1659 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 1660 1661 if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) 1662 return MODE_PANEL; 1663 1664 if (encoder) { 1665 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1666 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 1667 1668 /* AVIVO hardware supports downscaling modes larger than the panel 1669 * to the panel size, but I'm not sure this is desirable. 1670 */ 1671 if ((mode->hdisplay > native_mode->hdisplay) || 1672 (mode->vdisplay > native_mode->vdisplay)) 1673 return MODE_PANEL; 1674 1675 /* if scaling is disabled, block non-native modes */ 1676 if (radeon_encoder->rmx_type == RMX_OFF) { 1677 if ((mode->hdisplay != native_mode->hdisplay) || 1678 (mode->vdisplay != native_mode->vdisplay)) 1679 return MODE_PANEL; 1680 } 1681 } 1682 } else { 1683 if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || 1684 (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) { 1685 return radeon_dp_mode_valid_helper(connector, mode); 1686 } else { 1687 if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { 1688 /* HDMI 1.3+ supports max clock of 340 Mhz */ 1689 if (mode->clock > 340000) 1690 return MODE_CLOCK_HIGH; 1691 } else { 1692 if (mode->clock > 165000) 1693 return MODE_CLOCK_HIGH; 1694 } 1695 } 1696 } 1697 1698 return MODE_OK; 1699 } 1700 1701 static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { 1702 .get_modes = radeon_dp_get_modes, 1703 .mode_valid = radeon_dp_mode_valid, 1704 .best_encoder = radeon_dvi_encoder, 1705 }; 1706 1707 static const struct drm_connector_funcs radeon_dp_connector_funcs = { 1708 .dpms = drm_helper_connector_dpms, 1709 .detect = radeon_dp_detect, 1710 .fill_modes = drm_helper_probe_single_connector_modes, 1711 .set_property = radeon_connector_set_property, 1712 .destroy = radeon_connector_destroy, 1713 .force = radeon_dvi_force, 1714 }; 1715 1716 static const struct drm_connector_funcs radeon_edp_connector_funcs = { 1717 .dpms = drm_helper_connector_dpms, 1718 .detect = radeon_dp_detect, 1719 .fill_modes = drm_helper_probe_single_connector_modes, 1720 .set_property = radeon_lvds_set_property, 1721 .destroy = radeon_connector_destroy, 1722 .force = radeon_dvi_force, 1723 }; 1724 1725 static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = { 1726 .dpms = drm_helper_connector_dpms, 1727 .detect = radeon_dp_detect, 1728 .fill_modes = drm_helper_probe_single_connector_modes, 1729 .set_property = radeon_lvds_set_property, 1730 .destroy = radeon_connector_destroy, 1731 .force = radeon_dvi_force, 1732 }; 1733 1734 void 1735 radeon_add_atom_connector(struct drm_device *dev, 1736 uint32_t connector_id, 1737 uint32_t supported_device, 1738 int connector_type, 1739 struct radeon_i2c_bus_rec *i2c_bus, 1740 uint32_t igp_lane_info, 1741 uint16_t connector_object_id, 1742 struct radeon_hpd *hpd, 1743 struct radeon_router *router) 1744 { 1745 struct radeon_device *rdev = dev->dev_private; 1746 struct drm_connector *connector; 1747 struct radeon_connector *radeon_connector; 1748 struct radeon_connector_atom_dig *radeon_dig_connector; 1749 struct drm_encoder *encoder; 1750 struct radeon_encoder *radeon_encoder; 1751 uint32_t subpixel_order = SubPixelNone; 1752 bool shared_ddc = false; 1753 bool is_dp_bridge = false; 1754 bool has_aux = false; 1755 1756 if (connector_type == DRM_MODE_CONNECTOR_Unknown) 1757 return; 1758 1759 /* if the user selected tv=0 don't try and add the connector */ 1760 if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) || 1761 (connector_type == DRM_MODE_CONNECTOR_Composite) || 1762 (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) && 1763 (radeon_tv == 0)) 1764 return; 1765 1766 /* see if we already added it */ 1767 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 1768 radeon_connector = to_radeon_connector(connector); 1769 if (radeon_connector->connector_id == connector_id) { 1770 radeon_connector->devices |= supported_device; 1771 return; 1772 } 1773 if (radeon_connector->ddc_bus && i2c_bus->valid) { 1774 if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) { 1775 radeon_connector->shared_ddc = true; 1776 shared_ddc = true; 1777 } 1778 if (radeon_connector->router_bus && router->ddc_valid && 1779 (radeon_connector->router.router_id == router->router_id)) { 1780 radeon_connector->shared_ddc = false; 1781 shared_ddc = false; 1782 } 1783 } 1784 } 1785 1786 /* check if it's a dp bridge */ 1787 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 1788 radeon_encoder = to_radeon_encoder(encoder); 1789 if (radeon_encoder->devices & supported_device) { 1790 switch (radeon_encoder->encoder_id) { 1791 case ENCODER_OBJECT_ID_TRAVIS: 1792 case ENCODER_OBJECT_ID_NUTMEG: 1793 is_dp_bridge = true; 1794 break; 1795 default: 1796 break; 1797 } 1798 } 1799 } 1800 1801 radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); 1802 if (!radeon_connector) 1803 return; 1804 1805 connector = &radeon_connector->base; 1806 1807 radeon_connector->connector_id = connector_id; 1808 radeon_connector->devices = supported_device; 1809 radeon_connector->shared_ddc = shared_ddc; 1810 radeon_connector->connector_object_id = connector_object_id; 1811 radeon_connector->hpd = *hpd; 1812 1813 radeon_connector->router = *router; 1814 if (router->ddc_valid || router->cd_valid) { 1815 radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info); 1816 if (!radeon_connector->router_bus) 1817 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n"); 1818 } 1819 1820 if (is_dp_bridge) { 1821 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1822 if (!radeon_dig_connector) 1823 goto failed; 1824 radeon_dig_connector->igp_lane_info = igp_lane_info; 1825 radeon_connector->con_priv = radeon_dig_connector; 1826 if (i2c_bus->valid) { 1827 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1828 if (radeon_connector->ddc_bus) 1829 has_aux = true; 1830 else 1831 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1832 } 1833 switch (connector_type) { 1834 case DRM_MODE_CONNECTOR_VGA: 1835 case DRM_MODE_CONNECTOR_DVIA: 1836 default: 1837 drm_connector_init(dev, &radeon_connector->base, 1838 &radeon_dp_connector_funcs, connector_type); 1839 drm_connector_helper_add(&radeon_connector->base, 1840 &radeon_dp_connector_helper_funcs); 1841 connector->interlace_allowed = true; 1842 connector->doublescan_allowed = true; 1843 radeon_connector->dac_load_detect = true; 1844 drm_object_attach_property(&radeon_connector->base.base, 1845 rdev->mode_info.load_detect_property, 1846 1); 1847 drm_object_attach_property(&radeon_connector->base.base, 1848 dev->mode_config.scaling_mode_property, 1849 DRM_MODE_SCALE_NONE); 1850 break; 1851 case DRM_MODE_CONNECTOR_DVII: 1852 case DRM_MODE_CONNECTOR_DVID: 1853 case DRM_MODE_CONNECTOR_HDMIA: 1854 case DRM_MODE_CONNECTOR_HDMIB: 1855 case DRM_MODE_CONNECTOR_DisplayPort: 1856 drm_connector_init(dev, &radeon_connector->base, 1857 &radeon_dp_connector_funcs, connector_type); 1858 drm_connector_helper_add(&radeon_connector->base, 1859 &radeon_dp_connector_helper_funcs); 1860 drm_object_attach_property(&radeon_connector->base.base, 1861 rdev->mode_info.underscan_property, 1862 UNDERSCAN_OFF); 1863 drm_object_attach_property(&radeon_connector->base.base, 1864 rdev->mode_info.underscan_hborder_property, 1865 0); 1866 drm_object_attach_property(&radeon_connector->base.base, 1867 rdev->mode_info.underscan_vborder_property, 1868 0); 1869 1870 drm_object_attach_property(&radeon_connector->base.base, 1871 dev->mode_config.scaling_mode_property, 1872 DRM_MODE_SCALE_NONE); 1873 1874 drm_object_attach_property(&radeon_connector->base.base, 1875 rdev->mode_info.dither_property, 1876 RADEON_FMT_DITHER_DISABLE); 1877 1878 if (radeon_audio != 0) 1879 drm_object_attach_property(&radeon_connector->base.base, 1880 rdev->mode_info.audio_property, 1881 RADEON_AUDIO_AUTO); 1882 1883 subpixel_order = SubPixelHorizontalRGB; 1884 connector->interlace_allowed = true; 1885 if (connector_type == DRM_MODE_CONNECTOR_HDMIB) 1886 connector->doublescan_allowed = true; 1887 else 1888 connector->doublescan_allowed = false; 1889 if (connector_type == DRM_MODE_CONNECTOR_DVII) { 1890 radeon_connector->dac_load_detect = true; 1891 drm_object_attach_property(&radeon_connector->base.base, 1892 rdev->mode_info.load_detect_property, 1893 1); 1894 } 1895 break; 1896 case DRM_MODE_CONNECTOR_LVDS: 1897 case DRM_MODE_CONNECTOR_eDP: 1898 drm_connector_init(dev, &radeon_connector->base, 1899 &radeon_lvds_bridge_connector_funcs, connector_type); 1900 drm_connector_helper_add(&radeon_connector->base, 1901 &radeon_dp_connector_helper_funcs); 1902 drm_object_attach_property(&radeon_connector->base.base, 1903 dev->mode_config.scaling_mode_property, 1904 DRM_MODE_SCALE_FULLSCREEN); 1905 subpixel_order = SubPixelHorizontalRGB; 1906 connector->interlace_allowed = false; 1907 connector->doublescan_allowed = false; 1908 break; 1909 } 1910 } else { 1911 switch (connector_type) { 1912 case DRM_MODE_CONNECTOR_VGA: 1913 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 1914 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); 1915 if (i2c_bus->valid) { 1916 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1917 if (!radeon_connector->ddc_bus) 1918 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1919 } 1920 radeon_connector->dac_load_detect = true; 1921 drm_object_attach_property(&radeon_connector->base.base, 1922 rdev->mode_info.load_detect_property, 1923 1); 1924 if (ASIC_IS_AVIVO(rdev)) 1925 drm_object_attach_property(&radeon_connector->base.base, 1926 dev->mode_config.scaling_mode_property, 1927 DRM_MODE_SCALE_NONE); 1928 /* no HPD on analog connectors */ 1929 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1930 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 1931 connector->interlace_allowed = true; 1932 connector->doublescan_allowed = true; 1933 break; 1934 case DRM_MODE_CONNECTOR_DVIA: 1935 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 1936 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); 1937 if (i2c_bus->valid) { 1938 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1939 if (!radeon_connector->ddc_bus) 1940 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1941 } 1942 radeon_connector->dac_load_detect = true; 1943 drm_object_attach_property(&radeon_connector->base.base, 1944 rdev->mode_info.load_detect_property, 1945 1); 1946 if (ASIC_IS_AVIVO(rdev)) 1947 drm_object_attach_property(&radeon_connector->base.base, 1948 dev->mode_config.scaling_mode_property, 1949 DRM_MODE_SCALE_NONE); 1950 /* no HPD on analog connectors */ 1951 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1952 connector->interlace_allowed = true; 1953 connector->doublescan_allowed = true; 1954 break; 1955 case DRM_MODE_CONNECTOR_DVII: 1956 case DRM_MODE_CONNECTOR_DVID: 1957 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1958 if (!radeon_dig_connector) 1959 goto failed; 1960 radeon_dig_connector->igp_lane_info = igp_lane_info; 1961 radeon_connector->con_priv = radeon_dig_connector; 1962 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); 1963 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); 1964 if (i2c_bus->valid) { 1965 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1966 if (!radeon_connector->ddc_bus) 1967 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1968 } 1969 subpixel_order = SubPixelHorizontalRGB; 1970 drm_object_attach_property(&radeon_connector->base.base, 1971 rdev->mode_info.coherent_mode_property, 1972 1); 1973 if (ASIC_IS_AVIVO(rdev)) { 1974 drm_object_attach_property(&radeon_connector->base.base, 1975 rdev->mode_info.underscan_property, 1976 UNDERSCAN_OFF); 1977 drm_object_attach_property(&radeon_connector->base.base, 1978 rdev->mode_info.underscan_hborder_property, 1979 0); 1980 drm_object_attach_property(&radeon_connector->base.base, 1981 rdev->mode_info.underscan_vborder_property, 1982 0); 1983 drm_object_attach_property(&radeon_connector->base.base, 1984 rdev->mode_info.dither_property, 1985 RADEON_FMT_DITHER_DISABLE); 1986 drm_object_attach_property(&radeon_connector->base.base, 1987 dev->mode_config.scaling_mode_property, 1988 DRM_MODE_SCALE_NONE); 1989 } 1990 if (ASIC_IS_DCE2(rdev) && (radeon_audio != 0)) { 1991 drm_object_attach_property(&radeon_connector->base.base, 1992 rdev->mode_info.audio_property, 1993 RADEON_AUDIO_AUTO); 1994 } 1995 if (connector_type == DRM_MODE_CONNECTOR_DVII) { 1996 radeon_connector->dac_load_detect = true; 1997 drm_object_attach_property(&radeon_connector->base.base, 1998 rdev->mode_info.load_detect_property, 1999 1); 2000 } 2001 connector->interlace_allowed = true; 2002 if (connector_type == DRM_MODE_CONNECTOR_DVII) 2003 connector->doublescan_allowed = true; 2004 else 2005 connector->doublescan_allowed = false; 2006 break; 2007 case DRM_MODE_CONNECTOR_HDMIA: 2008 case DRM_MODE_CONNECTOR_HDMIB: 2009 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 2010 if (!radeon_dig_connector) 2011 goto failed; 2012 radeon_dig_connector->igp_lane_info = igp_lane_info; 2013 radeon_connector->con_priv = radeon_dig_connector; 2014 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); 2015 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); 2016 if (i2c_bus->valid) { 2017 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 2018 if (!radeon_connector->ddc_bus) 2019 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 2020 } 2021 drm_object_attach_property(&radeon_connector->base.base, 2022 rdev->mode_info.coherent_mode_property, 2023 1); 2024 if (ASIC_IS_AVIVO(rdev)) { 2025 drm_object_attach_property(&radeon_connector->base.base, 2026 rdev->mode_info.underscan_property, 2027 UNDERSCAN_OFF); 2028 drm_object_attach_property(&radeon_connector->base.base, 2029 rdev->mode_info.underscan_hborder_property, 2030 0); 2031 drm_object_attach_property(&radeon_connector->base.base, 2032 rdev->mode_info.underscan_vborder_property, 2033 0); 2034 drm_object_attach_property(&radeon_connector->base.base, 2035 rdev->mode_info.dither_property, 2036 RADEON_FMT_DITHER_DISABLE); 2037 drm_object_attach_property(&radeon_connector->base.base, 2038 dev->mode_config.scaling_mode_property, 2039 DRM_MODE_SCALE_NONE); 2040 } 2041 if (ASIC_IS_DCE2(rdev) && (radeon_audio != 0)) { 2042 drm_object_attach_property(&radeon_connector->base.base, 2043 rdev->mode_info.audio_property, 2044 RADEON_AUDIO_AUTO); 2045 } 2046 subpixel_order = SubPixelHorizontalRGB; 2047 connector->interlace_allowed = true; 2048 if (connector_type == DRM_MODE_CONNECTOR_HDMIB) 2049 connector->doublescan_allowed = true; 2050 else 2051 connector->doublescan_allowed = false; 2052 break; 2053 case DRM_MODE_CONNECTOR_DisplayPort: 2054 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 2055 if (!radeon_dig_connector) 2056 goto failed; 2057 radeon_dig_connector->igp_lane_info = igp_lane_info; 2058 radeon_connector->con_priv = radeon_dig_connector; 2059 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); 2060 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); 2061 if (i2c_bus->valid) { 2062 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 2063 if (radeon_connector->ddc_bus) 2064 has_aux = true; 2065 else 2066 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 2067 } 2068 subpixel_order = SubPixelHorizontalRGB; 2069 drm_object_attach_property(&radeon_connector->base.base, 2070 rdev->mode_info.coherent_mode_property, 2071 1); 2072 if (ASIC_IS_AVIVO(rdev)) { 2073 drm_object_attach_property(&radeon_connector->base.base, 2074 rdev->mode_info.underscan_property, 2075 UNDERSCAN_OFF); 2076 drm_object_attach_property(&radeon_connector->base.base, 2077 rdev->mode_info.underscan_hborder_property, 2078 0); 2079 drm_object_attach_property(&radeon_connector->base.base, 2080 rdev->mode_info.underscan_vborder_property, 2081 0); 2082 drm_object_attach_property(&radeon_connector->base.base, 2083 rdev->mode_info.dither_property, 2084 RADEON_FMT_DITHER_DISABLE); 2085 drm_object_attach_property(&radeon_connector->base.base, 2086 dev->mode_config.scaling_mode_property, 2087 DRM_MODE_SCALE_NONE); 2088 } 2089 if (ASIC_IS_DCE2(rdev) && (radeon_audio != 0)) { 2090 drm_object_attach_property(&radeon_connector->base.base, 2091 rdev->mode_info.audio_property, 2092 RADEON_AUDIO_AUTO); 2093 } 2094 connector->interlace_allowed = true; 2095 /* in theory with a DP to VGA converter... */ 2096 connector->doublescan_allowed = false; 2097 break; 2098 case DRM_MODE_CONNECTOR_eDP: 2099 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 2100 if (!radeon_dig_connector) 2101 goto failed; 2102 radeon_dig_connector->igp_lane_info = igp_lane_info; 2103 radeon_connector->con_priv = radeon_dig_connector; 2104 drm_connector_init(dev, &radeon_connector->base, &radeon_edp_connector_funcs, connector_type); 2105 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); 2106 if (i2c_bus->valid) { 2107 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 2108 if (radeon_connector->ddc_bus) 2109 has_aux = true; 2110 else 2111 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 2112 } 2113 drm_object_attach_property(&radeon_connector->base.base, 2114 dev->mode_config.scaling_mode_property, 2115 DRM_MODE_SCALE_FULLSCREEN); 2116 subpixel_order = SubPixelHorizontalRGB; 2117 connector->interlace_allowed = false; 2118 connector->doublescan_allowed = false; 2119 break; 2120 case DRM_MODE_CONNECTOR_SVIDEO: 2121 case DRM_MODE_CONNECTOR_Composite: 2122 case DRM_MODE_CONNECTOR_9PinDIN: 2123 drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); 2124 drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); 2125 radeon_connector->dac_load_detect = true; 2126 drm_object_attach_property(&radeon_connector->base.base, 2127 rdev->mode_info.load_detect_property, 2128 1); 2129 drm_object_attach_property(&radeon_connector->base.base, 2130 rdev->mode_info.tv_std_property, 2131 radeon_atombios_get_tv_info(rdev)); 2132 /* no HPD on analog connectors */ 2133 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 2134 connector->interlace_allowed = false; 2135 connector->doublescan_allowed = false; 2136 break; 2137 case DRM_MODE_CONNECTOR_LVDS: 2138 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 2139 if (!radeon_dig_connector) 2140 goto failed; 2141 radeon_dig_connector->igp_lane_info = igp_lane_info; 2142 radeon_connector->con_priv = radeon_dig_connector; 2143 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); 2144 drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); 2145 if (i2c_bus->valid) { 2146 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 2147 if (!radeon_connector->ddc_bus) 2148 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 2149 } 2150 drm_object_attach_property(&radeon_connector->base.base, 2151 dev->mode_config.scaling_mode_property, 2152 DRM_MODE_SCALE_FULLSCREEN); 2153 subpixel_order = SubPixelHorizontalRGB; 2154 connector->interlace_allowed = false; 2155 connector->doublescan_allowed = false; 2156 break; 2157 } 2158 } 2159 2160 if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { 2161 if (i2c_bus->valid) 2162 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 2163 } else 2164 connector->polled = DRM_CONNECTOR_POLL_HPD; 2165 2166 connector->display_info.subpixel_order = subpixel_order; 2167 drm_connector_register(connector); 2168 2169 if (has_aux) 2170 radeon_dp_aux_init(radeon_connector); 2171 2172 return; 2173 2174 failed: 2175 drm_connector_cleanup(connector); 2176 kfree(connector); 2177 } 2178 2179 void 2180 radeon_add_legacy_connector(struct drm_device *dev, 2181 uint32_t connector_id, 2182 uint32_t supported_device, 2183 int connector_type, 2184 struct radeon_i2c_bus_rec *i2c_bus, 2185 uint16_t connector_object_id, 2186 struct radeon_hpd *hpd) 2187 { 2188 struct radeon_device *rdev = dev->dev_private; 2189 struct drm_connector *connector; 2190 struct radeon_connector *radeon_connector; 2191 uint32_t subpixel_order = SubPixelNone; 2192 2193 if (connector_type == DRM_MODE_CONNECTOR_Unknown) 2194 return; 2195 2196 /* if the user selected tv=0 don't try and add the connector */ 2197 if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) || 2198 (connector_type == DRM_MODE_CONNECTOR_Composite) || 2199 (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) && 2200 (radeon_tv == 0)) 2201 return; 2202 2203 /* see if we already added it */ 2204 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 2205 radeon_connector = to_radeon_connector(connector); 2206 if (radeon_connector->connector_id == connector_id) { 2207 radeon_connector->devices |= supported_device; 2208 return; 2209 } 2210 } 2211 2212 radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); 2213 if (!radeon_connector) 2214 return; 2215 2216 connector = &radeon_connector->base; 2217 2218 radeon_connector->connector_id = connector_id; 2219 radeon_connector->devices = supported_device; 2220 radeon_connector->connector_object_id = connector_object_id; 2221 radeon_connector->hpd = *hpd; 2222 2223 switch (connector_type) { 2224 case DRM_MODE_CONNECTOR_VGA: 2225 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 2226 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); 2227 if (i2c_bus->valid) { 2228 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 2229 if (!radeon_connector->ddc_bus) 2230 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 2231 } 2232 radeon_connector->dac_load_detect = true; 2233 drm_object_attach_property(&radeon_connector->base.base, 2234 rdev->mode_info.load_detect_property, 2235 1); 2236 /* no HPD on analog connectors */ 2237 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 2238 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 2239 connector->interlace_allowed = true; 2240 connector->doublescan_allowed = true; 2241 break; 2242 case DRM_MODE_CONNECTOR_DVIA: 2243 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 2244 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); 2245 if (i2c_bus->valid) { 2246 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 2247 if (!radeon_connector->ddc_bus) 2248 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 2249 } 2250 radeon_connector->dac_load_detect = true; 2251 drm_object_attach_property(&radeon_connector->base.base, 2252 rdev->mode_info.load_detect_property, 2253 1); 2254 /* no HPD on analog connectors */ 2255 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 2256 connector->interlace_allowed = true; 2257 connector->doublescan_allowed = true; 2258 break; 2259 case DRM_MODE_CONNECTOR_DVII: 2260 case DRM_MODE_CONNECTOR_DVID: 2261 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); 2262 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); 2263 if (i2c_bus->valid) { 2264 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 2265 if (!radeon_connector->ddc_bus) 2266 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 2267 } 2268 if (connector_type == DRM_MODE_CONNECTOR_DVII) { 2269 radeon_connector->dac_load_detect = true; 2270 drm_object_attach_property(&radeon_connector->base.base, 2271 rdev->mode_info.load_detect_property, 2272 1); 2273 } 2274 subpixel_order = SubPixelHorizontalRGB; 2275 connector->interlace_allowed = true; 2276 if (connector_type == DRM_MODE_CONNECTOR_DVII) 2277 connector->doublescan_allowed = true; 2278 else 2279 connector->doublescan_allowed = false; 2280 break; 2281 case DRM_MODE_CONNECTOR_SVIDEO: 2282 case DRM_MODE_CONNECTOR_Composite: 2283 case DRM_MODE_CONNECTOR_9PinDIN: 2284 drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); 2285 drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); 2286 radeon_connector->dac_load_detect = true; 2287 /* RS400,RC410,RS480 chipset seems to report a lot 2288 * of false positive on load detect, we haven't yet 2289 * found a way to make load detect reliable on those 2290 * chipset, thus just disable it for TV. 2291 */ 2292 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) 2293 radeon_connector->dac_load_detect = false; 2294 drm_object_attach_property(&radeon_connector->base.base, 2295 rdev->mode_info.load_detect_property, 2296 radeon_connector->dac_load_detect); 2297 drm_object_attach_property(&radeon_connector->base.base, 2298 rdev->mode_info.tv_std_property, 2299 radeon_combios_get_tv_info(rdev)); 2300 /* no HPD on analog connectors */ 2301 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 2302 connector->interlace_allowed = false; 2303 connector->doublescan_allowed = false; 2304 break; 2305 case DRM_MODE_CONNECTOR_LVDS: 2306 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); 2307 drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); 2308 if (i2c_bus->valid) { 2309 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 2310 if (!radeon_connector->ddc_bus) 2311 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 2312 } 2313 drm_object_attach_property(&radeon_connector->base.base, 2314 dev->mode_config.scaling_mode_property, 2315 DRM_MODE_SCALE_FULLSCREEN); 2316 subpixel_order = SubPixelHorizontalRGB; 2317 connector->interlace_allowed = false; 2318 connector->doublescan_allowed = false; 2319 break; 2320 } 2321 2322 if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { 2323 if (i2c_bus->valid) 2324 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 2325 } else 2326 connector->polled = DRM_CONNECTOR_POLL_HPD; 2327 connector->display_info.subpixel_order = subpixel_order; 2328 drm_connector_register(connector); 2329 } 2330