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 "drmP.h" 27 #include "drm_edid.h" 28 #include "drm_crtc_helper.h" 29 #include "drm_fb_helper.h" 30 #include "radeon_drm.h" 31 #include "radeon.h" 32 #include "atom.h" 33 34 extern void 35 radeon_combios_connected_scratch_regs(struct drm_connector *connector, 36 struct drm_encoder *encoder, 37 bool connected); 38 extern void 39 radeon_atombios_connected_scratch_regs(struct drm_connector *connector, 40 struct drm_encoder *encoder, 41 bool connected); 42 43 extern void 44 radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder, 45 struct drm_connector *drm_connector); 46 47 void radeon_connector_hotplug(struct drm_connector *connector) 48 { 49 struct drm_device *dev = connector->dev; 50 struct radeon_device *rdev = dev->dev_private; 51 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 52 53 radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); 54 55 /* powering up/down the eDP panel generates hpd events which 56 * can interfere with modesetting. 57 */ 58 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) 59 return; 60 61 /* pre-r600 did not always have the hpd pins mapped accurately to connectors */ 62 if (rdev->family >= CHIP_R600) { 63 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) 64 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); 65 else 66 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 67 } 68 } 69 70 static void radeon_property_change_mode(struct drm_encoder *encoder) 71 { 72 struct drm_crtc *crtc = encoder->crtc; 73 74 if (crtc && crtc->enabled) { 75 drm_crtc_helper_set_mode(crtc, &crtc->mode, 76 crtc->x, crtc->y, crtc->fb); 77 } 78 } 79 static void 80 radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status) 81 { 82 struct drm_device *dev = connector->dev; 83 struct radeon_device *rdev = dev->dev_private; 84 struct drm_encoder *best_encoder = NULL; 85 struct drm_encoder *encoder = NULL; 86 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 87 struct drm_mode_object *obj; 88 bool connected; 89 int i; 90 91 best_encoder = connector_funcs->best_encoder(connector); 92 93 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 94 if (connector->encoder_ids[i] == 0) 95 break; 96 97 obj = drm_mode_object_find(connector->dev, 98 connector->encoder_ids[i], 99 DRM_MODE_OBJECT_ENCODER); 100 if (!obj) 101 continue; 102 103 encoder = obj_to_encoder(obj); 104 105 if ((encoder == best_encoder) && (status == connector_status_connected)) 106 connected = true; 107 else 108 connected = false; 109 110 if (rdev->is_atom_bios) 111 radeon_atombios_connected_scratch_regs(connector, encoder, connected); 112 else 113 radeon_combios_connected_scratch_regs(connector, encoder, connected); 114 115 } 116 } 117 118 struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type) 119 { 120 struct drm_mode_object *obj; 121 struct drm_encoder *encoder; 122 int i; 123 124 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 125 if (connector->encoder_ids[i] == 0) 126 break; 127 128 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); 129 if (!obj) 130 continue; 131 132 encoder = obj_to_encoder(obj); 133 if (encoder->encoder_type == encoder_type) 134 return encoder; 135 } 136 return NULL; 137 } 138 139 struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector) 140 { 141 int enc_id = connector->encoder_ids[0]; 142 struct drm_mode_object *obj; 143 struct drm_encoder *encoder; 144 145 /* pick the encoder ids */ 146 if (enc_id) { 147 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); 148 if (!obj) 149 return NULL; 150 encoder = obj_to_encoder(obj); 151 return encoder; 152 } 153 return NULL; 154 } 155 156 /* 157 * radeon_connector_analog_encoder_conflict_solve 158 * - search for other connectors sharing this encoder 159 * if priority is true, then set them disconnected if this is connected 160 * if priority is false, set us disconnected if they are connected 161 */ 162 static enum drm_connector_status 163 radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector, 164 struct drm_encoder *encoder, 165 enum drm_connector_status current_status, 166 bool priority) 167 { 168 struct drm_device *dev = connector->dev; 169 struct drm_connector *conflict; 170 struct radeon_connector *radeon_conflict; 171 int i; 172 173 list_for_each_entry(conflict, &dev->mode_config.connector_list, head) { 174 if (conflict == connector) 175 continue; 176 177 radeon_conflict = to_radeon_connector(conflict); 178 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 179 if (conflict->encoder_ids[i] == 0) 180 break; 181 182 /* if the IDs match */ 183 if (conflict->encoder_ids[i] == encoder->base.id) { 184 if (conflict->status != connector_status_connected) 185 continue; 186 187 if (radeon_conflict->use_digital) 188 continue; 189 190 if (priority == true) { 191 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict)); 192 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(connector)); 193 conflict->status = connector_status_disconnected; 194 radeon_connector_update_scratch_regs(conflict, connector_status_disconnected); 195 } else { 196 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector)); 197 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(conflict)); 198 current_status = connector_status_disconnected; 199 } 200 break; 201 } 202 } 203 } 204 return current_status; 205 206 } 207 208 static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encoder) 209 { 210 struct drm_device *dev = encoder->dev; 211 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 212 struct drm_display_mode *mode = NULL; 213 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 214 215 if (native_mode->hdisplay != 0 && 216 native_mode->vdisplay != 0 && 217 native_mode->clock != 0) { 218 mode = drm_mode_duplicate(dev, native_mode); 219 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; 220 drm_mode_set_name(mode); 221 222 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode->name); 223 } else if (native_mode->hdisplay != 0 && 224 native_mode->vdisplay != 0) { 225 /* mac laptops without an edid */ 226 /* Note that this is not necessarily the exact panel mode, 227 * but an approximation based on the cvt formula. For these 228 * systems we should ideally read the mode info out of the 229 * registers or add a mode table, but this works and is much 230 * simpler. 231 */ 232 mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false); 233 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; 234 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name); 235 } 236 return mode; 237 } 238 239 static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector) 240 { 241 struct drm_device *dev = encoder->dev; 242 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 243 struct drm_display_mode *mode = NULL; 244 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 245 int i; 246 struct mode_size { 247 int w; 248 int h; 249 } common_modes[17] = { 250 { 640, 480}, 251 { 720, 480}, 252 { 800, 600}, 253 { 848, 480}, 254 {1024, 768}, 255 {1152, 768}, 256 {1280, 720}, 257 {1280, 800}, 258 {1280, 854}, 259 {1280, 960}, 260 {1280, 1024}, 261 {1440, 900}, 262 {1400, 1050}, 263 {1680, 1050}, 264 {1600, 1200}, 265 {1920, 1080}, 266 {1920, 1200} 267 }; 268 269 for (i = 0; i < 17; i++) { 270 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { 271 if (common_modes[i].w > 1024 || 272 common_modes[i].h > 768) 273 continue; 274 } 275 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 276 if (common_modes[i].w > native_mode->hdisplay || 277 common_modes[i].h > native_mode->vdisplay || 278 (common_modes[i].w == native_mode->hdisplay && 279 common_modes[i].h == native_mode->vdisplay)) 280 continue; 281 } 282 if (common_modes[i].w < 320 || common_modes[i].h < 200) 283 continue; 284 285 mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); 286 drm_mode_probed_add(connector, mode); 287 } 288 } 289 290 int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property, 291 uint64_t val) 292 { 293 struct drm_device *dev = connector->dev; 294 struct radeon_device *rdev = dev->dev_private; 295 struct drm_encoder *encoder; 296 struct radeon_encoder *radeon_encoder; 297 298 if (property == rdev->mode_info.coherent_mode_property) { 299 struct radeon_encoder_atom_dig *dig; 300 bool new_coherent_mode; 301 302 /* need to find digital encoder on connector */ 303 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 304 if (!encoder) 305 return 0; 306 307 radeon_encoder = to_radeon_encoder(encoder); 308 309 if (!radeon_encoder->enc_priv) 310 return 0; 311 312 dig = radeon_encoder->enc_priv; 313 new_coherent_mode = val ? true : false; 314 if (dig->coherent_mode != new_coherent_mode) { 315 dig->coherent_mode = new_coherent_mode; 316 radeon_property_change_mode(&radeon_encoder->base); 317 } 318 } 319 320 if (property == rdev->mode_info.underscan_property) { 321 /* need to find digital encoder on connector */ 322 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 323 if (!encoder) 324 return 0; 325 326 radeon_encoder = to_radeon_encoder(encoder); 327 328 if (radeon_encoder->underscan_type != val) { 329 radeon_encoder->underscan_type = val; 330 radeon_property_change_mode(&radeon_encoder->base); 331 } 332 } 333 334 if (property == rdev->mode_info.underscan_hborder_property) { 335 /* need to find digital encoder on connector */ 336 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 337 if (!encoder) 338 return 0; 339 340 radeon_encoder = to_radeon_encoder(encoder); 341 342 if (radeon_encoder->underscan_hborder != val) { 343 radeon_encoder->underscan_hborder = val; 344 radeon_property_change_mode(&radeon_encoder->base); 345 } 346 } 347 348 if (property == rdev->mode_info.underscan_vborder_property) { 349 /* need to find digital encoder on connector */ 350 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 351 if (!encoder) 352 return 0; 353 354 radeon_encoder = to_radeon_encoder(encoder); 355 356 if (radeon_encoder->underscan_vborder != val) { 357 radeon_encoder->underscan_vborder = val; 358 radeon_property_change_mode(&radeon_encoder->base); 359 } 360 } 361 362 if (property == rdev->mode_info.tv_std_property) { 363 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC); 364 if (!encoder) { 365 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC); 366 } 367 368 if (!encoder) 369 return 0; 370 371 radeon_encoder = to_radeon_encoder(encoder); 372 if (!radeon_encoder->enc_priv) 373 return 0; 374 if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) { 375 struct radeon_encoder_atom_dac *dac_int; 376 dac_int = radeon_encoder->enc_priv; 377 dac_int->tv_std = val; 378 } else { 379 struct radeon_encoder_tv_dac *dac_int; 380 dac_int = radeon_encoder->enc_priv; 381 dac_int->tv_std = val; 382 } 383 radeon_property_change_mode(&radeon_encoder->base); 384 } 385 386 if (property == rdev->mode_info.load_detect_property) { 387 struct radeon_connector *radeon_connector = 388 to_radeon_connector(connector); 389 390 if (val == 0) 391 radeon_connector->dac_load_detect = false; 392 else 393 radeon_connector->dac_load_detect = true; 394 } 395 396 if (property == rdev->mode_info.tmds_pll_property) { 397 struct radeon_encoder_int_tmds *tmds = NULL; 398 bool ret = false; 399 /* need to find digital encoder on connector */ 400 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 401 if (!encoder) 402 return 0; 403 404 radeon_encoder = to_radeon_encoder(encoder); 405 406 tmds = radeon_encoder->enc_priv; 407 if (!tmds) 408 return 0; 409 410 if (val == 0) { 411 if (rdev->is_atom_bios) 412 ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds); 413 else 414 ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds); 415 } 416 if (val == 1 || ret == false) { 417 radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds); 418 } 419 radeon_property_change_mode(&radeon_encoder->base); 420 } 421 422 return 0; 423 } 424 425 static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder, 426 struct drm_connector *connector) 427 { 428 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 429 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 430 431 /* Try to get native mode details from EDID if necessary */ 432 if (!native_mode->clock) { 433 struct drm_display_mode *t, *mode; 434 435 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { 436 if (mode->hdisplay == native_mode->hdisplay && 437 mode->vdisplay == native_mode->vdisplay) { 438 *native_mode = *mode; 439 drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V); 440 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n"); 441 break; 442 } 443 } 444 } 445 if (!native_mode->clock) { 446 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n"); 447 radeon_encoder->rmx_type = RMX_OFF; 448 } 449 } 450 451 static int radeon_lvds_get_modes(struct drm_connector *connector) 452 { 453 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 454 struct drm_encoder *encoder; 455 int ret = 0; 456 struct drm_display_mode *mode; 457 458 if (radeon_connector->ddc_bus) { 459 ret = radeon_ddc_get_modes(radeon_connector); 460 if (ret > 0) { 461 encoder = radeon_best_single_encoder(connector); 462 if (encoder) { 463 radeon_fixup_lvds_native_mode(encoder, connector); 464 /* add scaled modes */ 465 radeon_add_common_modes(encoder, connector); 466 } 467 return ret; 468 } 469 } 470 471 encoder = radeon_best_single_encoder(connector); 472 if (!encoder) 473 return 0; 474 475 /* we have no EDID modes */ 476 mode = radeon_fp_native_mode(encoder); 477 if (mode) { 478 ret = 1; 479 drm_mode_probed_add(connector, mode); 480 /* add the width/height from vbios tables if available */ 481 connector->display_info.width_mm = mode->width_mm; 482 connector->display_info.height_mm = mode->height_mm; 483 /* add scaled modes */ 484 radeon_add_common_modes(encoder, connector); 485 } 486 487 return ret; 488 } 489 490 static int radeon_lvds_mode_valid(struct drm_connector *connector, 491 struct drm_display_mode *mode) 492 { 493 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 494 495 if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) 496 return MODE_PANEL; 497 498 if (encoder) { 499 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 500 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 501 502 /* AVIVO hardware supports downscaling modes larger than the panel 503 * to the panel size, but I'm not sure this is desirable. 504 */ 505 if ((mode->hdisplay > native_mode->hdisplay) || 506 (mode->vdisplay > native_mode->vdisplay)) 507 return MODE_PANEL; 508 509 /* if scaling is disabled, block non-native modes */ 510 if (radeon_encoder->rmx_type == RMX_OFF) { 511 if ((mode->hdisplay != native_mode->hdisplay) || 512 (mode->vdisplay != native_mode->vdisplay)) 513 return MODE_PANEL; 514 } 515 } 516 517 return MODE_OK; 518 } 519 520 static enum drm_connector_status 521 radeon_lvds_detect(struct drm_connector *connector, bool force) 522 { 523 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 524 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 525 enum drm_connector_status ret = connector_status_disconnected; 526 527 if (encoder) { 528 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 529 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 530 531 /* check if panel is valid */ 532 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) 533 ret = connector_status_connected; 534 535 } 536 537 /* check for edid as well */ 538 if (radeon_connector->edid) 539 ret = connector_status_connected; 540 else { 541 if (radeon_connector->ddc_bus) { 542 radeon_connector->edid = drm_get_edid(&radeon_connector->base, 543 &radeon_connector->ddc_bus->adapter); 544 if (radeon_connector->edid) 545 ret = connector_status_connected; 546 } 547 } 548 /* check acpi lid status ??? */ 549 550 radeon_connector_update_scratch_regs(connector, ret); 551 return ret; 552 } 553 554 static void radeon_connector_destroy(struct drm_connector *connector) 555 { 556 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 557 558 if (radeon_connector->edid) 559 kfree(radeon_connector->edid); 560 kfree(radeon_connector->con_priv); 561 drm_sysfs_connector_remove(connector); 562 drm_connector_cleanup(connector); 563 kfree(connector); 564 } 565 566 static int radeon_lvds_set_property(struct drm_connector *connector, 567 struct drm_property *property, 568 uint64_t value) 569 { 570 struct drm_device *dev = connector->dev; 571 struct radeon_encoder *radeon_encoder; 572 enum radeon_rmx_type rmx_type; 573 574 DRM_DEBUG_KMS("\n"); 575 if (property != dev->mode_config.scaling_mode_property) 576 return 0; 577 578 if (connector->encoder) 579 radeon_encoder = to_radeon_encoder(connector->encoder); 580 else { 581 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 582 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); 583 } 584 585 switch (value) { 586 case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break; 587 case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break; 588 case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break; 589 default: 590 case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break; 591 } 592 if (radeon_encoder->rmx_type == rmx_type) 593 return 0; 594 595 radeon_encoder->rmx_type = rmx_type; 596 597 radeon_property_change_mode(&radeon_encoder->base); 598 return 0; 599 } 600 601 602 struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = { 603 .get_modes = radeon_lvds_get_modes, 604 .mode_valid = radeon_lvds_mode_valid, 605 .best_encoder = radeon_best_single_encoder, 606 }; 607 608 struct drm_connector_funcs radeon_lvds_connector_funcs = { 609 .dpms = drm_helper_connector_dpms, 610 .detect = radeon_lvds_detect, 611 .fill_modes = drm_helper_probe_single_connector_modes, 612 .destroy = radeon_connector_destroy, 613 .set_property = radeon_lvds_set_property, 614 }; 615 616 static int radeon_vga_get_modes(struct drm_connector *connector) 617 { 618 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 619 int ret; 620 621 ret = radeon_ddc_get_modes(radeon_connector); 622 623 return ret; 624 } 625 626 static int radeon_vga_mode_valid(struct drm_connector *connector, 627 struct drm_display_mode *mode) 628 { 629 /* XXX check mode bandwidth */ 630 /* XXX verify against max DAC output frequency */ 631 return MODE_OK; 632 } 633 634 static enum drm_connector_status 635 radeon_vga_detect(struct drm_connector *connector, bool force) 636 { 637 struct drm_device *dev = connector->dev; 638 struct radeon_device *rdev = dev->dev_private; 639 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 640 struct drm_encoder *encoder; 641 struct drm_encoder_helper_funcs *encoder_funcs; 642 bool dret = false; 643 enum drm_connector_status ret = connector_status_disconnected; 644 645 encoder = radeon_best_single_encoder(connector); 646 if (!encoder) 647 ret = connector_status_disconnected; 648 649 if (radeon_connector->ddc_bus) 650 dret = radeon_ddc_probe(radeon_connector); 651 if (dret) { 652 if (radeon_connector->edid) { 653 kfree(radeon_connector->edid); 654 radeon_connector->edid = NULL; 655 } 656 radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); 657 658 if (!radeon_connector->edid) { 659 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", 660 drm_get_connector_name(connector)); 661 ret = connector_status_connected; 662 } else { 663 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); 664 665 /* some oems have boards with separate digital and analog connectors 666 * with a shared ddc line (often vga + hdmi) 667 */ 668 if (radeon_connector->use_digital && radeon_connector->shared_ddc) { 669 kfree(radeon_connector->edid); 670 radeon_connector->edid = NULL; 671 ret = connector_status_disconnected; 672 } else 673 ret = connector_status_connected; 674 } 675 } else { 676 677 /* if we aren't forcing don't do destructive polling */ 678 if (!force) 679 return connector->status; 680 681 if (radeon_connector->dac_load_detect && encoder) { 682 encoder_funcs = encoder->helper_private; 683 ret = encoder_funcs->detect(encoder, connector); 684 } 685 } 686 687 if (ret == connector_status_connected) 688 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); 689 690 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the 691 * vbios to deal with KVMs. If we have one and are not able to detect a monitor 692 * by other means, assume the CRT is connected and use that EDID. 693 */ 694 if ((!rdev->is_atom_bios) && 695 (ret == connector_status_disconnected) && 696 rdev->mode_info.bios_hardcoded_edid_size) { 697 ret = connector_status_connected; 698 } 699 700 radeon_connector_update_scratch_regs(connector, ret); 701 return ret; 702 } 703 704 struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = { 705 .get_modes = radeon_vga_get_modes, 706 .mode_valid = radeon_vga_mode_valid, 707 .best_encoder = radeon_best_single_encoder, 708 }; 709 710 struct drm_connector_funcs radeon_vga_connector_funcs = { 711 .dpms = drm_helper_connector_dpms, 712 .detect = radeon_vga_detect, 713 .fill_modes = drm_helper_probe_single_connector_modes, 714 .destroy = radeon_connector_destroy, 715 .set_property = radeon_connector_set_property, 716 }; 717 718 static int radeon_tv_get_modes(struct drm_connector *connector) 719 { 720 struct drm_device *dev = connector->dev; 721 struct radeon_device *rdev = dev->dev_private; 722 struct drm_display_mode *tv_mode; 723 struct drm_encoder *encoder; 724 725 encoder = radeon_best_single_encoder(connector); 726 if (!encoder) 727 return 0; 728 729 /* avivo chips can scale any mode */ 730 if (rdev->family >= CHIP_RS600) 731 /* add scaled modes */ 732 radeon_add_common_modes(encoder, connector); 733 else { 734 /* only 800x600 is supported right now on pre-avivo chips */ 735 tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false); 736 tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; 737 drm_mode_probed_add(connector, tv_mode); 738 } 739 return 1; 740 } 741 742 static int radeon_tv_mode_valid(struct drm_connector *connector, 743 struct drm_display_mode *mode) 744 { 745 if ((mode->hdisplay > 1024) || (mode->vdisplay > 768)) 746 return MODE_CLOCK_RANGE; 747 return MODE_OK; 748 } 749 750 static enum drm_connector_status 751 radeon_tv_detect(struct drm_connector *connector, bool force) 752 { 753 struct drm_encoder *encoder; 754 struct drm_encoder_helper_funcs *encoder_funcs; 755 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 756 enum drm_connector_status ret = connector_status_disconnected; 757 758 if (!radeon_connector->dac_load_detect) 759 return ret; 760 761 encoder = radeon_best_single_encoder(connector); 762 if (!encoder) 763 ret = connector_status_disconnected; 764 else { 765 encoder_funcs = encoder->helper_private; 766 ret = encoder_funcs->detect(encoder, connector); 767 } 768 if (ret == connector_status_connected) 769 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); 770 radeon_connector_update_scratch_regs(connector, ret); 771 return ret; 772 } 773 774 struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = { 775 .get_modes = radeon_tv_get_modes, 776 .mode_valid = radeon_tv_mode_valid, 777 .best_encoder = radeon_best_single_encoder, 778 }; 779 780 struct drm_connector_funcs radeon_tv_connector_funcs = { 781 .dpms = drm_helper_connector_dpms, 782 .detect = radeon_tv_detect, 783 .fill_modes = drm_helper_probe_single_connector_modes, 784 .destroy = radeon_connector_destroy, 785 .set_property = radeon_connector_set_property, 786 }; 787 788 static int radeon_dvi_get_modes(struct drm_connector *connector) 789 { 790 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 791 int ret; 792 793 ret = radeon_ddc_get_modes(radeon_connector); 794 return ret; 795 } 796 797 /* 798 * DVI is complicated 799 * Do a DDC probe, if DDC probe passes, get the full EDID so 800 * we can do analog/digital monitor detection at this point. 801 * If the monitor is an analog monitor or we got no DDC, 802 * we need to find the DAC encoder object for this connector. 803 * If we got no DDC, we do load detection on the DAC encoder object. 804 * If we got analog DDC or load detection passes on the DAC encoder 805 * we have to check if this analog encoder is shared with anyone else (TV) 806 * if its shared we have to set the other connector to disconnected. 807 */ 808 static enum drm_connector_status 809 radeon_dvi_detect(struct drm_connector *connector, bool force) 810 { 811 struct drm_device *dev = connector->dev; 812 struct radeon_device *rdev = dev->dev_private; 813 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 814 struct drm_encoder *encoder = NULL; 815 struct drm_encoder_helper_funcs *encoder_funcs; 816 struct drm_mode_object *obj; 817 int i; 818 enum drm_connector_status ret = connector_status_disconnected; 819 bool dret = false; 820 821 if (radeon_connector->ddc_bus) 822 dret = radeon_ddc_probe(radeon_connector); 823 if (dret) { 824 if (radeon_connector->edid) { 825 kfree(radeon_connector->edid); 826 radeon_connector->edid = NULL; 827 } 828 radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); 829 830 if (!radeon_connector->edid) { 831 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", 832 drm_get_connector_name(connector)); 833 } else { 834 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); 835 836 /* some oems have boards with separate digital and analog connectors 837 * with a shared ddc line (often vga + hdmi) 838 */ 839 if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) { 840 kfree(radeon_connector->edid); 841 radeon_connector->edid = NULL; 842 ret = connector_status_disconnected; 843 } else 844 ret = connector_status_connected; 845 846 /* This gets complicated. We have boards with VGA + HDMI with a 847 * shared DDC line and we have boards with DVI-D + HDMI with a shared 848 * DDC line. The latter is more complex because with DVI<->HDMI adapters 849 * you don't really know what's connected to which port as both are digital. 850 */ 851 if (radeon_connector->shared_ddc && (ret == connector_status_connected)) { 852 struct drm_connector *list_connector; 853 struct radeon_connector *list_radeon_connector; 854 list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) { 855 if (connector == list_connector) 856 continue; 857 list_radeon_connector = to_radeon_connector(list_connector); 858 if (list_radeon_connector->shared_ddc && 859 (list_radeon_connector->ddc_bus->rec.i2c_id == 860 radeon_connector->ddc_bus->rec.i2c_id)) { 861 /* cases where both connectors are digital */ 862 if (list_connector->connector_type != DRM_MODE_CONNECTOR_VGA) { 863 /* hpd is our only option in this case */ 864 if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { 865 kfree(radeon_connector->edid); 866 radeon_connector->edid = NULL; 867 ret = connector_status_disconnected; 868 } 869 } 870 } 871 } 872 } 873 } 874 } 875 876 if ((ret == connector_status_connected) && (radeon_connector->use_digital == true)) 877 goto out; 878 879 if (!force) { 880 ret = connector->status; 881 goto out; 882 } 883 884 /* find analog encoder */ 885 if (radeon_connector->dac_load_detect) { 886 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 887 if (connector->encoder_ids[i] == 0) 888 break; 889 890 obj = drm_mode_object_find(connector->dev, 891 connector->encoder_ids[i], 892 DRM_MODE_OBJECT_ENCODER); 893 if (!obj) 894 continue; 895 896 encoder = obj_to_encoder(obj); 897 898 encoder_funcs = encoder->helper_private; 899 if (encoder_funcs->detect) { 900 if (ret != connector_status_connected) { 901 ret = encoder_funcs->detect(encoder, connector); 902 if (ret == connector_status_connected) { 903 radeon_connector->use_digital = false; 904 } 905 } 906 break; 907 } 908 } 909 } 910 911 if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) && 912 encoder) { 913 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); 914 } 915 916 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the 917 * vbios to deal with KVMs. If we have one and are not able to detect a monitor 918 * by other means, assume the DFP is connected and use that EDID. In most 919 * cases the DVI port is actually a virtual KVM port connected to the service 920 * processor. 921 */ 922 if ((!rdev->is_atom_bios) && 923 (ret == connector_status_disconnected) && 924 rdev->mode_info.bios_hardcoded_edid_size) { 925 radeon_connector->use_digital = true; 926 ret = connector_status_connected; 927 } 928 929 out: 930 /* updated in get modes as well since we need to know if it's analog or digital */ 931 radeon_connector_update_scratch_regs(connector, ret); 932 return ret; 933 } 934 935 /* okay need to be smart in here about which encoder to pick */ 936 struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector) 937 { 938 int enc_id = connector->encoder_ids[0]; 939 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 940 struct drm_mode_object *obj; 941 struct drm_encoder *encoder; 942 int i; 943 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 944 if (connector->encoder_ids[i] == 0) 945 break; 946 947 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); 948 if (!obj) 949 continue; 950 951 encoder = obj_to_encoder(obj); 952 953 if (radeon_connector->use_digital == true) { 954 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) 955 return encoder; 956 } else { 957 if (encoder->encoder_type == DRM_MODE_ENCODER_DAC || 958 encoder->encoder_type == DRM_MODE_ENCODER_TVDAC) 959 return encoder; 960 } 961 } 962 963 /* see if we have a default encoder TODO */ 964 965 /* then check use digitial */ 966 /* pick the first one */ 967 if (enc_id) { 968 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); 969 if (!obj) 970 return NULL; 971 encoder = obj_to_encoder(obj); 972 return encoder; 973 } 974 return NULL; 975 } 976 977 static void radeon_dvi_force(struct drm_connector *connector) 978 { 979 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 980 if (connector->force == DRM_FORCE_ON) 981 radeon_connector->use_digital = false; 982 if (connector->force == DRM_FORCE_ON_DIGITAL) 983 radeon_connector->use_digital = true; 984 } 985 986 static int radeon_dvi_mode_valid(struct drm_connector *connector, 987 struct drm_display_mode *mode) 988 { 989 struct drm_device *dev = connector->dev; 990 struct radeon_device *rdev = dev->dev_private; 991 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 992 993 /* XXX check mode bandwidth */ 994 995 /* clocks over 135 MHz have heat issues with DVI on RV100 */ 996 if (radeon_connector->use_digital && 997 (rdev->family == CHIP_RV100) && 998 (mode->clock > 135000)) 999 return MODE_CLOCK_HIGH; 1000 1001 if (radeon_connector->use_digital && (mode->clock > 165000)) { 1002 if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) || 1003 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) || 1004 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) 1005 return MODE_OK; 1006 else if (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_A) { 1007 if (ASIC_IS_DCE3(rdev)) { 1008 /* HDMI 1.3+ supports max clock of 340 Mhz */ 1009 if (mode->clock > 340000) 1010 return MODE_CLOCK_HIGH; 1011 else 1012 return MODE_OK; 1013 } else 1014 return MODE_CLOCK_HIGH; 1015 } else 1016 return MODE_CLOCK_HIGH; 1017 } 1018 return MODE_OK; 1019 } 1020 1021 struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = { 1022 .get_modes = radeon_dvi_get_modes, 1023 .mode_valid = radeon_dvi_mode_valid, 1024 .best_encoder = radeon_dvi_encoder, 1025 }; 1026 1027 struct drm_connector_funcs radeon_dvi_connector_funcs = { 1028 .dpms = drm_helper_connector_dpms, 1029 .detect = radeon_dvi_detect, 1030 .fill_modes = drm_helper_probe_single_connector_modes, 1031 .set_property = radeon_connector_set_property, 1032 .destroy = radeon_connector_destroy, 1033 .force = radeon_dvi_force, 1034 }; 1035 1036 static void radeon_dp_connector_destroy(struct drm_connector *connector) 1037 { 1038 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1039 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1040 1041 if (radeon_connector->edid) 1042 kfree(radeon_connector->edid); 1043 if (radeon_dig_connector->dp_i2c_bus) 1044 radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus); 1045 kfree(radeon_connector->con_priv); 1046 drm_sysfs_connector_remove(connector); 1047 drm_connector_cleanup(connector); 1048 kfree(connector); 1049 } 1050 1051 static int radeon_dp_get_modes(struct drm_connector *connector) 1052 { 1053 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1054 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1055 int ret; 1056 1057 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 1058 struct drm_encoder *encoder; 1059 struct drm_display_mode *mode; 1060 1061 if (!radeon_dig_connector->edp_on) 1062 atombios_set_edp_panel_power(connector, 1063 ATOM_TRANSMITTER_ACTION_POWER_ON); 1064 ret = radeon_ddc_get_modes(radeon_connector); 1065 if (!radeon_dig_connector->edp_on) 1066 atombios_set_edp_panel_power(connector, 1067 ATOM_TRANSMITTER_ACTION_POWER_OFF); 1068 1069 if (ret > 0) { 1070 encoder = radeon_best_single_encoder(connector); 1071 if (encoder) { 1072 radeon_fixup_lvds_native_mode(encoder, connector); 1073 /* add scaled modes */ 1074 radeon_add_common_modes(encoder, connector); 1075 } 1076 return ret; 1077 } 1078 1079 encoder = radeon_best_single_encoder(connector); 1080 if (!encoder) 1081 return 0; 1082 1083 /* we have no EDID modes */ 1084 mode = radeon_fp_native_mode(encoder); 1085 if (mode) { 1086 ret = 1; 1087 drm_mode_probed_add(connector, mode); 1088 /* add the width/height from vbios tables if available */ 1089 connector->display_info.width_mm = mode->width_mm; 1090 connector->display_info.height_mm = mode->height_mm; 1091 /* add scaled modes */ 1092 radeon_add_common_modes(encoder, connector); 1093 } 1094 } else 1095 ret = radeon_ddc_get_modes(radeon_connector); 1096 1097 return ret; 1098 } 1099 1100 bool radeon_connector_encoder_is_dp_bridge(struct drm_connector *connector) 1101 { 1102 struct drm_mode_object *obj; 1103 struct drm_encoder *encoder; 1104 struct radeon_encoder *radeon_encoder; 1105 int i; 1106 bool found = false; 1107 1108 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1109 if (connector->encoder_ids[i] == 0) 1110 break; 1111 1112 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); 1113 if (!obj) 1114 continue; 1115 1116 encoder = obj_to_encoder(obj); 1117 radeon_encoder = to_radeon_encoder(encoder); 1118 1119 switch (radeon_encoder->encoder_id) { 1120 case ENCODER_OBJECT_ID_TRAVIS: 1121 case ENCODER_OBJECT_ID_NUTMEG: 1122 found = true; 1123 break; 1124 default: 1125 break; 1126 } 1127 } 1128 1129 return found; 1130 } 1131 1132 bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector) 1133 { 1134 struct drm_mode_object *obj; 1135 struct drm_encoder *encoder; 1136 struct radeon_encoder *radeon_encoder; 1137 int i; 1138 bool found = false; 1139 1140 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1141 if (connector->encoder_ids[i] == 0) 1142 break; 1143 1144 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); 1145 if (!obj) 1146 continue; 1147 1148 encoder = obj_to_encoder(obj); 1149 radeon_encoder = to_radeon_encoder(encoder); 1150 if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2) 1151 found = true; 1152 } 1153 1154 return found; 1155 } 1156 1157 bool radeon_connector_is_dp12_capable(struct drm_connector *connector) 1158 { 1159 struct drm_device *dev = connector->dev; 1160 struct radeon_device *rdev = dev->dev_private; 1161 1162 if (ASIC_IS_DCE5(rdev) && 1163 (rdev->clock.dp_extclk >= 53900) && 1164 radeon_connector_encoder_is_hbr2(connector)) { 1165 return true; 1166 } 1167 1168 return false; 1169 } 1170 1171 static enum drm_connector_status 1172 radeon_dp_detect(struct drm_connector *connector, bool force) 1173 { 1174 struct drm_device *dev = connector->dev; 1175 struct radeon_device *rdev = dev->dev_private; 1176 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1177 enum drm_connector_status ret = connector_status_disconnected; 1178 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1179 1180 if (radeon_connector->edid) { 1181 kfree(radeon_connector->edid); 1182 radeon_connector->edid = NULL; 1183 } 1184 1185 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 1186 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 1187 if (encoder) { 1188 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1189 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 1190 1191 /* check if panel is valid */ 1192 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) 1193 ret = connector_status_connected; 1194 } 1195 /* eDP is always DP */ 1196 radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; 1197 if (!radeon_dig_connector->edp_on) 1198 atombios_set_edp_panel_power(connector, 1199 ATOM_TRANSMITTER_ACTION_POWER_ON); 1200 if (radeon_dp_getdpcd(radeon_connector)) 1201 ret = connector_status_connected; 1202 if (!radeon_dig_connector->edp_on) 1203 atombios_set_edp_panel_power(connector, 1204 ATOM_TRANSMITTER_ACTION_POWER_OFF); 1205 } else { 1206 radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); 1207 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { 1208 ret = connector_status_connected; 1209 if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) 1210 radeon_dp_getdpcd(radeon_connector); 1211 } else { 1212 if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { 1213 if (radeon_dp_getdpcd(radeon_connector)) 1214 ret = connector_status_connected; 1215 } else { 1216 if (radeon_ddc_probe(radeon_connector)) 1217 ret = connector_status_connected; 1218 } 1219 } 1220 } 1221 1222 radeon_connector_update_scratch_regs(connector, ret); 1223 return ret; 1224 } 1225 1226 static int radeon_dp_mode_valid(struct drm_connector *connector, 1227 struct drm_display_mode *mode) 1228 { 1229 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1230 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1231 1232 /* XXX check mode bandwidth */ 1233 1234 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 1235 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 1236 1237 if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) 1238 return MODE_PANEL; 1239 1240 if (encoder) { 1241 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1242 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 1243 1244 /* AVIVO hardware supports downscaling modes larger than the panel 1245 * to the panel size, but I'm not sure this is desirable. 1246 */ 1247 if ((mode->hdisplay > native_mode->hdisplay) || 1248 (mode->vdisplay > native_mode->vdisplay)) 1249 return MODE_PANEL; 1250 1251 /* if scaling is disabled, block non-native modes */ 1252 if (radeon_encoder->rmx_type == RMX_OFF) { 1253 if ((mode->hdisplay != native_mode->hdisplay) || 1254 (mode->vdisplay != native_mode->vdisplay)) 1255 return MODE_PANEL; 1256 } 1257 } 1258 return MODE_OK; 1259 } else { 1260 if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || 1261 (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) 1262 return radeon_dp_mode_valid_helper(connector, mode); 1263 else 1264 return MODE_OK; 1265 } 1266 } 1267 1268 struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { 1269 .get_modes = radeon_dp_get_modes, 1270 .mode_valid = radeon_dp_mode_valid, 1271 .best_encoder = radeon_dvi_encoder, 1272 }; 1273 1274 struct drm_connector_funcs radeon_dp_connector_funcs = { 1275 .dpms = drm_helper_connector_dpms, 1276 .detect = radeon_dp_detect, 1277 .fill_modes = drm_helper_probe_single_connector_modes, 1278 .set_property = radeon_connector_set_property, 1279 .destroy = radeon_dp_connector_destroy, 1280 .force = radeon_dvi_force, 1281 }; 1282 1283 void 1284 radeon_add_atom_connector(struct drm_device *dev, 1285 uint32_t connector_id, 1286 uint32_t supported_device, 1287 int connector_type, 1288 struct radeon_i2c_bus_rec *i2c_bus, 1289 uint32_t igp_lane_info, 1290 uint16_t connector_object_id, 1291 struct radeon_hpd *hpd, 1292 struct radeon_router *router) 1293 { 1294 struct radeon_device *rdev = dev->dev_private; 1295 struct drm_connector *connector; 1296 struct radeon_connector *radeon_connector; 1297 struct radeon_connector_atom_dig *radeon_dig_connector; 1298 struct drm_encoder *encoder; 1299 struct radeon_encoder *radeon_encoder; 1300 uint32_t subpixel_order = SubPixelNone; 1301 bool shared_ddc = false; 1302 bool is_dp_bridge = false; 1303 1304 if (connector_type == DRM_MODE_CONNECTOR_Unknown) 1305 return; 1306 1307 /* if the user selected tv=0 don't try and add the connector */ 1308 if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) || 1309 (connector_type == DRM_MODE_CONNECTOR_Composite) || 1310 (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) && 1311 (radeon_tv == 0)) 1312 return; 1313 1314 /* see if we already added it */ 1315 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 1316 radeon_connector = to_radeon_connector(connector); 1317 if (radeon_connector->connector_id == connector_id) { 1318 radeon_connector->devices |= supported_device; 1319 return; 1320 } 1321 if (radeon_connector->ddc_bus && i2c_bus->valid) { 1322 if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) { 1323 radeon_connector->shared_ddc = true; 1324 shared_ddc = true; 1325 } 1326 if (radeon_connector->router_bus && router->ddc_valid && 1327 (radeon_connector->router.router_id == router->router_id)) { 1328 radeon_connector->shared_ddc = false; 1329 shared_ddc = false; 1330 } 1331 } 1332 } 1333 1334 /* check if it's a dp bridge */ 1335 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 1336 radeon_encoder = to_radeon_encoder(encoder); 1337 if (radeon_encoder->devices & supported_device) { 1338 switch (radeon_encoder->encoder_id) { 1339 case ENCODER_OBJECT_ID_TRAVIS: 1340 case ENCODER_OBJECT_ID_NUTMEG: 1341 is_dp_bridge = true; 1342 break; 1343 default: 1344 break; 1345 } 1346 } 1347 } 1348 1349 radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); 1350 if (!radeon_connector) 1351 return; 1352 1353 connector = &radeon_connector->base; 1354 1355 radeon_connector->connector_id = connector_id; 1356 radeon_connector->devices = supported_device; 1357 radeon_connector->shared_ddc = shared_ddc; 1358 radeon_connector->connector_object_id = connector_object_id; 1359 radeon_connector->hpd = *hpd; 1360 radeon_connector->router = *router; 1361 if (router->ddc_valid || router->cd_valid) { 1362 radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info); 1363 if (!radeon_connector->router_bus) 1364 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n"); 1365 } 1366 1367 if (is_dp_bridge) { 1368 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1369 if (!radeon_dig_connector) 1370 goto failed; 1371 radeon_dig_connector->igp_lane_info = igp_lane_info; 1372 radeon_connector->con_priv = radeon_dig_connector; 1373 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); 1374 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); 1375 if (i2c_bus->valid) { 1376 /* add DP i2c bus */ 1377 if (connector_type == DRM_MODE_CONNECTOR_eDP) 1378 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); 1379 else 1380 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); 1381 if (!radeon_dig_connector->dp_i2c_bus) 1382 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); 1383 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1384 if (!radeon_connector->ddc_bus) 1385 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1386 } 1387 switch (connector_type) { 1388 case DRM_MODE_CONNECTOR_VGA: 1389 case DRM_MODE_CONNECTOR_DVIA: 1390 default: 1391 connector->interlace_allowed = true; 1392 connector->doublescan_allowed = true; 1393 break; 1394 case DRM_MODE_CONNECTOR_DVII: 1395 case DRM_MODE_CONNECTOR_DVID: 1396 case DRM_MODE_CONNECTOR_HDMIA: 1397 case DRM_MODE_CONNECTOR_HDMIB: 1398 case DRM_MODE_CONNECTOR_DisplayPort: 1399 drm_connector_attach_property(&radeon_connector->base, 1400 rdev->mode_info.underscan_property, 1401 UNDERSCAN_OFF); 1402 drm_connector_attach_property(&radeon_connector->base, 1403 rdev->mode_info.underscan_hborder_property, 1404 0); 1405 drm_connector_attach_property(&radeon_connector->base, 1406 rdev->mode_info.underscan_vborder_property, 1407 0); 1408 subpixel_order = SubPixelHorizontalRGB; 1409 connector->interlace_allowed = true; 1410 if (connector_type == DRM_MODE_CONNECTOR_HDMIB) 1411 connector->doublescan_allowed = true; 1412 else 1413 connector->doublescan_allowed = false; 1414 break; 1415 case DRM_MODE_CONNECTOR_LVDS: 1416 case DRM_MODE_CONNECTOR_eDP: 1417 drm_connector_attach_property(&radeon_connector->base, 1418 dev->mode_config.scaling_mode_property, 1419 DRM_MODE_SCALE_FULLSCREEN); 1420 subpixel_order = SubPixelHorizontalRGB; 1421 connector->interlace_allowed = false; 1422 connector->doublescan_allowed = false; 1423 break; 1424 } 1425 } else { 1426 switch (connector_type) { 1427 case DRM_MODE_CONNECTOR_VGA: 1428 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 1429 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); 1430 if (i2c_bus->valid) { 1431 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1432 if (!radeon_connector->ddc_bus) 1433 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1434 } 1435 radeon_connector->dac_load_detect = true; 1436 drm_connector_attach_property(&radeon_connector->base, 1437 rdev->mode_info.load_detect_property, 1438 1); 1439 /* no HPD on analog connectors */ 1440 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1441 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 1442 connector->interlace_allowed = true; 1443 connector->doublescan_allowed = true; 1444 break; 1445 case DRM_MODE_CONNECTOR_DVIA: 1446 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 1447 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); 1448 if (i2c_bus->valid) { 1449 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1450 if (!radeon_connector->ddc_bus) 1451 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1452 } 1453 radeon_connector->dac_load_detect = true; 1454 drm_connector_attach_property(&radeon_connector->base, 1455 rdev->mode_info.load_detect_property, 1456 1); 1457 /* no HPD on analog connectors */ 1458 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1459 connector->interlace_allowed = true; 1460 connector->doublescan_allowed = true; 1461 break; 1462 case DRM_MODE_CONNECTOR_DVII: 1463 case DRM_MODE_CONNECTOR_DVID: 1464 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1465 if (!radeon_dig_connector) 1466 goto failed; 1467 radeon_dig_connector->igp_lane_info = igp_lane_info; 1468 radeon_connector->con_priv = radeon_dig_connector; 1469 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); 1470 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); 1471 if (i2c_bus->valid) { 1472 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1473 if (!radeon_connector->ddc_bus) 1474 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1475 } 1476 subpixel_order = SubPixelHorizontalRGB; 1477 drm_connector_attach_property(&radeon_connector->base, 1478 rdev->mode_info.coherent_mode_property, 1479 1); 1480 if (ASIC_IS_AVIVO(rdev)) { 1481 drm_connector_attach_property(&radeon_connector->base, 1482 rdev->mode_info.underscan_property, 1483 UNDERSCAN_OFF); 1484 drm_connector_attach_property(&radeon_connector->base, 1485 rdev->mode_info.underscan_hborder_property, 1486 0); 1487 drm_connector_attach_property(&radeon_connector->base, 1488 rdev->mode_info.underscan_vborder_property, 1489 0); 1490 } 1491 if (connector_type == DRM_MODE_CONNECTOR_DVII) { 1492 radeon_connector->dac_load_detect = true; 1493 drm_connector_attach_property(&radeon_connector->base, 1494 rdev->mode_info.load_detect_property, 1495 1); 1496 } 1497 connector->interlace_allowed = true; 1498 if (connector_type == DRM_MODE_CONNECTOR_DVII) 1499 connector->doublescan_allowed = true; 1500 else 1501 connector->doublescan_allowed = false; 1502 break; 1503 case DRM_MODE_CONNECTOR_HDMIA: 1504 case DRM_MODE_CONNECTOR_HDMIB: 1505 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1506 if (!radeon_dig_connector) 1507 goto failed; 1508 radeon_dig_connector->igp_lane_info = igp_lane_info; 1509 radeon_connector->con_priv = radeon_dig_connector; 1510 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); 1511 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); 1512 if (i2c_bus->valid) { 1513 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1514 if (!radeon_connector->ddc_bus) 1515 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1516 } 1517 drm_connector_attach_property(&radeon_connector->base, 1518 rdev->mode_info.coherent_mode_property, 1519 1); 1520 if (ASIC_IS_AVIVO(rdev)) { 1521 drm_connector_attach_property(&radeon_connector->base, 1522 rdev->mode_info.underscan_property, 1523 UNDERSCAN_OFF); 1524 drm_connector_attach_property(&radeon_connector->base, 1525 rdev->mode_info.underscan_hborder_property, 1526 0); 1527 drm_connector_attach_property(&radeon_connector->base, 1528 rdev->mode_info.underscan_vborder_property, 1529 0); 1530 } 1531 subpixel_order = SubPixelHorizontalRGB; 1532 connector->interlace_allowed = true; 1533 if (connector_type == DRM_MODE_CONNECTOR_HDMIB) 1534 connector->doublescan_allowed = true; 1535 else 1536 connector->doublescan_allowed = false; 1537 break; 1538 case DRM_MODE_CONNECTOR_DisplayPort: 1539 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1540 if (!radeon_dig_connector) 1541 goto failed; 1542 radeon_dig_connector->igp_lane_info = igp_lane_info; 1543 radeon_connector->con_priv = radeon_dig_connector; 1544 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); 1545 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); 1546 if (i2c_bus->valid) { 1547 /* add DP i2c bus */ 1548 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); 1549 if (!radeon_dig_connector->dp_i2c_bus) 1550 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); 1551 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1552 if (!radeon_connector->ddc_bus) 1553 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1554 } 1555 subpixel_order = SubPixelHorizontalRGB; 1556 drm_connector_attach_property(&radeon_connector->base, 1557 rdev->mode_info.coherent_mode_property, 1558 1); 1559 if (ASIC_IS_AVIVO(rdev)) { 1560 drm_connector_attach_property(&radeon_connector->base, 1561 rdev->mode_info.underscan_property, 1562 UNDERSCAN_OFF); 1563 drm_connector_attach_property(&radeon_connector->base, 1564 rdev->mode_info.underscan_hborder_property, 1565 0); 1566 drm_connector_attach_property(&radeon_connector->base, 1567 rdev->mode_info.underscan_vborder_property, 1568 0); 1569 } 1570 connector->interlace_allowed = true; 1571 /* in theory with a DP to VGA converter... */ 1572 connector->doublescan_allowed = false; 1573 break; 1574 case DRM_MODE_CONNECTOR_eDP: 1575 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1576 if (!radeon_dig_connector) 1577 goto failed; 1578 radeon_dig_connector->igp_lane_info = igp_lane_info; 1579 radeon_connector->con_priv = radeon_dig_connector; 1580 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); 1581 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); 1582 if (i2c_bus->valid) { 1583 /* add DP i2c bus */ 1584 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); 1585 if (!radeon_dig_connector->dp_i2c_bus) 1586 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); 1587 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1588 if (!radeon_connector->ddc_bus) 1589 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1590 } 1591 drm_connector_attach_property(&radeon_connector->base, 1592 dev->mode_config.scaling_mode_property, 1593 DRM_MODE_SCALE_FULLSCREEN); 1594 subpixel_order = SubPixelHorizontalRGB; 1595 connector->interlace_allowed = false; 1596 connector->doublescan_allowed = false; 1597 break; 1598 case DRM_MODE_CONNECTOR_SVIDEO: 1599 case DRM_MODE_CONNECTOR_Composite: 1600 case DRM_MODE_CONNECTOR_9PinDIN: 1601 drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); 1602 drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); 1603 radeon_connector->dac_load_detect = true; 1604 drm_connector_attach_property(&radeon_connector->base, 1605 rdev->mode_info.load_detect_property, 1606 1); 1607 drm_connector_attach_property(&radeon_connector->base, 1608 rdev->mode_info.tv_std_property, 1609 radeon_atombios_get_tv_info(rdev)); 1610 /* no HPD on analog connectors */ 1611 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1612 connector->interlace_allowed = false; 1613 connector->doublescan_allowed = false; 1614 break; 1615 case DRM_MODE_CONNECTOR_LVDS: 1616 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1617 if (!radeon_dig_connector) 1618 goto failed; 1619 radeon_dig_connector->igp_lane_info = igp_lane_info; 1620 radeon_connector->con_priv = radeon_dig_connector; 1621 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); 1622 drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); 1623 if (i2c_bus->valid) { 1624 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1625 if (!radeon_connector->ddc_bus) 1626 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1627 } 1628 drm_connector_attach_property(&radeon_connector->base, 1629 dev->mode_config.scaling_mode_property, 1630 DRM_MODE_SCALE_FULLSCREEN); 1631 subpixel_order = SubPixelHorizontalRGB; 1632 connector->interlace_allowed = false; 1633 connector->doublescan_allowed = false; 1634 break; 1635 } 1636 } 1637 1638 if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { 1639 if (i2c_bus->valid) 1640 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 1641 } else 1642 connector->polled = DRM_CONNECTOR_POLL_HPD; 1643 1644 connector->display_info.subpixel_order = subpixel_order; 1645 drm_sysfs_connector_add(connector); 1646 return; 1647 1648 failed: 1649 drm_connector_cleanup(connector); 1650 kfree(connector); 1651 } 1652 1653 void 1654 radeon_add_legacy_connector(struct drm_device *dev, 1655 uint32_t connector_id, 1656 uint32_t supported_device, 1657 int connector_type, 1658 struct radeon_i2c_bus_rec *i2c_bus, 1659 uint16_t connector_object_id, 1660 struct radeon_hpd *hpd) 1661 { 1662 struct radeon_device *rdev = dev->dev_private; 1663 struct drm_connector *connector; 1664 struct radeon_connector *radeon_connector; 1665 uint32_t subpixel_order = SubPixelNone; 1666 1667 if (connector_type == DRM_MODE_CONNECTOR_Unknown) 1668 return; 1669 1670 /* if the user selected tv=0 don't try and add the connector */ 1671 if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) || 1672 (connector_type == DRM_MODE_CONNECTOR_Composite) || 1673 (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) && 1674 (radeon_tv == 0)) 1675 return; 1676 1677 /* see if we already added it */ 1678 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 1679 radeon_connector = to_radeon_connector(connector); 1680 if (radeon_connector->connector_id == connector_id) { 1681 radeon_connector->devices |= supported_device; 1682 return; 1683 } 1684 } 1685 1686 radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); 1687 if (!radeon_connector) 1688 return; 1689 1690 connector = &radeon_connector->base; 1691 1692 radeon_connector->connector_id = connector_id; 1693 radeon_connector->devices = supported_device; 1694 radeon_connector->connector_object_id = connector_object_id; 1695 radeon_connector->hpd = *hpd; 1696 switch (connector_type) { 1697 case DRM_MODE_CONNECTOR_VGA: 1698 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 1699 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); 1700 if (i2c_bus->valid) { 1701 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1702 if (!radeon_connector->ddc_bus) 1703 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1704 } 1705 radeon_connector->dac_load_detect = true; 1706 drm_connector_attach_property(&radeon_connector->base, 1707 rdev->mode_info.load_detect_property, 1708 1); 1709 /* no HPD on analog connectors */ 1710 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1711 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 1712 connector->interlace_allowed = true; 1713 connector->doublescan_allowed = true; 1714 break; 1715 case DRM_MODE_CONNECTOR_DVIA: 1716 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 1717 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); 1718 if (i2c_bus->valid) { 1719 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1720 if (!radeon_connector->ddc_bus) 1721 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1722 } 1723 radeon_connector->dac_load_detect = true; 1724 drm_connector_attach_property(&radeon_connector->base, 1725 rdev->mode_info.load_detect_property, 1726 1); 1727 /* no HPD on analog connectors */ 1728 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1729 connector->interlace_allowed = true; 1730 connector->doublescan_allowed = true; 1731 break; 1732 case DRM_MODE_CONNECTOR_DVII: 1733 case DRM_MODE_CONNECTOR_DVID: 1734 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); 1735 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); 1736 if (i2c_bus->valid) { 1737 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1738 if (!radeon_connector->ddc_bus) 1739 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1740 } 1741 if (connector_type == DRM_MODE_CONNECTOR_DVII) { 1742 radeon_connector->dac_load_detect = true; 1743 drm_connector_attach_property(&radeon_connector->base, 1744 rdev->mode_info.load_detect_property, 1745 1); 1746 } 1747 subpixel_order = SubPixelHorizontalRGB; 1748 connector->interlace_allowed = true; 1749 if (connector_type == DRM_MODE_CONNECTOR_DVII) 1750 connector->doublescan_allowed = true; 1751 else 1752 connector->doublescan_allowed = false; 1753 break; 1754 case DRM_MODE_CONNECTOR_SVIDEO: 1755 case DRM_MODE_CONNECTOR_Composite: 1756 case DRM_MODE_CONNECTOR_9PinDIN: 1757 drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); 1758 drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); 1759 radeon_connector->dac_load_detect = true; 1760 /* RS400,RC410,RS480 chipset seems to report a lot 1761 * of false positive on load detect, we haven't yet 1762 * found a way to make load detect reliable on those 1763 * chipset, thus just disable it for TV. 1764 */ 1765 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) 1766 radeon_connector->dac_load_detect = false; 1767 drm_connector_attach_property(&radeon_connector->base, 1768 rdev->mode_info.load_detect_property, 1769 radeon_connector->dac_load_detect); 1770 drm_connector_attach_property(&radeon_connector->base, 1771 rdev->mode_info.tv_std_property, 1772 radeon_combios_get_tv_info(rdev)); 1773 /* no HPD on analog connectors */ 1774 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1775 connector->interlace_allowed = false; 1776 connector->doublescan_allowed = false; 1777 break; 1778 case DRM_MODE_CONNECTOR_LVDS: 1779 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); 1780 drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); 1781 if (i2c_bus->valid) { 1782 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1783 if (!radeon_connector->ddc_bus) 1784 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); 1785 } 1786 drm_connector_attach_property(&radeon_connector->base, 1787 dev->mode_config.scaling_mode_property, 1788 DRM_MODE_SCALE_FULLSCREEN); 1789 subpixel_order = SubPixelHorizontalRGB; 1790 connector->interlace_allowed = false; 1791 connector->doublescan_allowed = false; 1792 break; 1793 } 1794 1795 if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { 1796 if (i2c_bus->valid) 1797 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 1798 } else 1799 connector->polled = DRM_CONNECTOR_POLL_HPD; 1800 connector->display_info.subpixel_order = subpixel_order; 1801 drm_sysfs_connector_add(connector); 1802 if (connector_type == DRM_MODE_CONNECTOR_LVDS) { 1803 struct drm_encoder *drm_encoder; 1804 1805 list_for_each_entry(drm_encoder, &dev->mode_config.encoder_list, head) { 1806 struct radeon_encoder *radeon_encoder; 1807 1808 radeon_encoder = to_radeon_encoder(drm_encoder); 1809 if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_LVDS) 1810 radeon_legacy_backlight_init(radeon_encoder, connector); 1811 } 1812 } 1813 } 1814