/* * Copyright 2007 Jérôme Glisse * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /* * Authors: * Jérôme Glisse */ #include "radeon_ms.h" extern struct radeon_ms_output radeon_ms_dac1; extern struct radeon_ms_output radeon_ms_dac2; extern const struct drm_output_funcs radeon_ms_output_funcs; static struct combios_connector_chip_info * radeon_ms_combios_get_connector_chip_info(struct drm_device *dev, int chip_num) { struct drm_radeon_private *dev_priv = dev->dev_private; struct radeon_ms_rom *rom = &dev_priv->rom; struct combios_header *header; struct combios_connector_table *connector_table; struct combios_connector_chip_info *connector_chip_info; uint32_t offset; int numof_chips, i; if (rom->type != ROM_COMBIOS || rom->rom_image == NULL) { return NULL; } header = rom->rom.combios_header; offset = header->usPointerToExtendedInitTable2; if ((offset + sizeof(struct combios_connector_table)) > rom->rom_size) { DRM_INFO("[radeon_ms] wrong COMBIOS connector offset\n"); return NULL; } if (!offset) { return NULL; } connector_table = (struct combios_connector_table *) &rom->rom_image[offset]; numof_chips = (connector_table->ucConnectorHeader & BIOS_CONNECTOR_HEADER__NUMBER_OF_CHIPS__MASK) >> BIOS_CONNECTOR_HEADER__NUMBER_OF_CHIPS__SHIFT; DRM_INFO("[radeon_ms] COMBIOS number of chip: %d (table rev: %d)\n", numof_chips, (connector_table->ucConnectorHeader & BIOS_CONNECTOR_HEADER__TABLE_REVISION__MASK) >> BIOS_CONNECTOR_HEADER__TABLE_REVISION__SHIFT); for (i = 0; i < numof_chips; i++) { int chip; connector_chip_info = &connector_table->sChipConnectorInfo[i]; chip = (connector_chip_info->ucChipHeader & BIOS_CHIPINFO_HEADER__CHIP_NUMBER__MASK) >> BIOS_CHIPINFO_HEADER__CHIP_NUMBER__SHIFT; DRM_INFO("[radeon_ms] COMBIOS chip: %d (asked for: %d)\n", chip, chip_num); if (chip == chip_num) { return connector_chip_info; } } return NULL; } static int radeon_combios_get_connector_infos(struct drm_device *dev, int connector_info, int *connector_type, int *ddc_line, int *tmds_type, int *dac_type) { struct drm_radeon_private *dev_priv = dev->dev_private; *connector_type = (connector_info & BIOS_CONNECTOR_INFO__TYPE__MASK) >> BIOS_CONNECTOR_INFO__TYPE__SHIFT; *ddc_line = (connector_info & BIOS_CONNECTOR_INFO__DDC_LINE__MASK) >> BIOS_CONNECTOR_INFO__DDC_LINE__SHIFT; *tmds_type = (connector_info & BIOS_CONNECTOR_INFO__TMDS_TYPE__MASK) >> BIOS_CONNECTOR_INFO__TMDS_TYPE__SHIFT; *dac_type = (connector_info & BIOS_CONNECTOR_INFO__DAC_TYPE__MASK) >> BIOS_CONNECTOR_INFO__DAC_TYPE__SHIFT; /* most XPRESS chips seem to specify DDC_CRT2 for their * VGA DDC port, however DDC never seems to work on that * port. Some have reported success on DDC_MONID, so * lets see what happens with that. */ if (dev_priv->family == CHIP_RS400 && *connector_type == BIOS_CONNECTOR_TYPE__CRT && *ddc_line == BIOS_DDC_LINE__CRT2) { *ddc_line = BIOS_DDC_LINE__MONID01; } /* XPRESS desktop chips seem to have a proprietary * connector listed for DVI-D, try and do the right * thing here. */ if (dev_priv->family == CHIP_RS400 && *connector_type == BIOS_CONNECTOR_TYPE__PROPRIETARY) { DRM_INFO("[radeon_ms] COMBIOS Proprietary connector " "found, assuming DVI-D\n"); *dac_type = 2; *tmds_type = BIOS_TMDS_TYPE__EXTERNAL; *connector_type = BIOS_CONNECTOR_TYPE__DVI_D; } return 0; } static int radeon_ms_combios_connector_add(struct drm_device *dev, int connector_number, int connector_type, uint32_t i2c_reg) { struct drm_radeon_private *dev_priv = dev->dev_private; struct radeon_ms_connector *connector = NULL; struct drm_output *output = NULL; connector = drm_alloc(sizeof(struct radeon_ms_connector), DRM_MEM_DRIVER); if (connector == NULL) { radeon_ms_connectors_destroy(dev); return -ENOMEM; } memset(connector, 0, sizeof(struct radeon_ms_connector)); connector->monitor_type = MT_NONE; connector->type = connector_type; connector->i2c_reg = i2c_reg; switch (connector->type) { case CONNECTOR_VGA: sprintf(connector->name, "VGA"); break; case CONNECTOR_DVI_I: sprintf(connector->name, "DVI-I"); break; case CONNECTOR_DVI_D: sprintf(connector->name, "DVI-D"); break; default: sprintf(connector->name, "UNKNOWN-CONNECTOR"); break; } if (i2c_reg) { connector->i2c = radeon_ms_i2c_create(dev, connector->i2c_reg, connector->name); if (connector->i2c == NULL) { radeon_ms_connectors_destroy(dev); return -ENOMEM; } } else { connector->i2c = NULL; } output = drm_output_create(dev, &radeon_ms_output_funcs, connector->type); if (output == NULL) { radeon_ms_connectors_destroy(dev); return -EINVAL; } connector->output = output; output->driver_private = connector; output->possible_crtcs = 0x3; dev_priv->connectors[connector_number] = connector; return 0; } int radeon_ms_combios_get_properties(struct drm_device *dev) { struct drm_radeon_private *dev_priv = dev->dev_private; struct radeon_ms_rom *rom = &dev_priv->rom; struct combios_pll_block *pll_block; struct combios_header *header; uint32_t offset; if (rom->type != ROM_COMBIOS || rom->rom_image == NULL) { return 0; } header = rom->rom.combios_header; offset = header->usPointerToPllInfoBlock; if ((offset + sizeof(struct combios_pll_block)) > rom->rom_size) { DRM_INFO("[radeon_ms] wrong COMBIOS pll block offset\n"); return 0; } if (!offset) { return 0; } pll_block = (struct combios_pll_block *)&rom->rom_image[offset]; dev_priv->properties.pll_reference_freq = pll_block->usDotClockRefFreq; dev_priv->properties.pll_reference_div = pll_block->usDotClockRefDiv; dev_priv->properties.pll_min_pll_freq = pll_block->ulDotClockMinFreq; dev_priv->properties.pll_max_pll_freq = pll_block->ulDotClockMaxFreq; dev_priv->properties.pll_reference_freq *= 10; dev_priv->properties.pll_min_pll_freq *= 10; dev_priv->properties.pll_max_pll_freq *= 10; DRM_INFO("[radeon_ms] COMBIOS pll reference frequency : %d\n", dev_priv->properties.pll_reference_freq); DRM_INFO("[radeon_ms] COMBIOS pll reference divider : %d\n", dev_priv->properties.pll_reference_div); DRM_INFO("[radeon_ms] COMBIOS pll minimum frequency : %d\n", dev_priv->properties.pll_min_pll_freq); DRM_INFO("[radeon_ms] COMBIOS pll maximum frequency : %d\n", dev_priv->properties.pll_max_pll_freq); return 1; } int radeon_ms_connectors_from_combios(struct drm_device *dev) { struct drm_radeon_private *dev_priv = dev->dev_private; struct combios_connector_chip_info *connector_chip_info; int connector_type, ddc_line, tmds_type, dac_type; int dac1, dac2, tmdsint, tmdsext; int numof_connector, i, c = 0, added, j; uint32_t i2c_reg; int ret; dac1 = dac2 = tmdsint = tmdsext = -1; connector_chip_info = radeon_ms_combios_get_connector_chip_info(dev, 1); if (connector_chip_info == NULL) { return -1; } numof_connector = (connector_chip_info->ucChipHeader & BIOS_CHIPINFO_HEADER__NUMBER_OF_CONNECTORS__MASK) >> BIOS_CHIPINFO_HEADER__NUMBER_OF_CONNECTORS__SHIFT; DRM_INFO("[radeon_ms] COMBIOS number of connector: %d\n", numof_connector); for (i = 0; i < numof_connector; i++) { int connector_info = connector_chip_info->sConnectorInfo[i]; ret = radeon_combios_get_connector_infos(dev, connector_info, &connector_type, &ddc_line, &tmds_type, &dac_type); switch (ddc_line) { case BIOS_DDC_LINE__MONID01: i2c_reg = GPIO_MONID; break; case BIOS_DDC_LINE__DVI: i2c_reg = GPIO_DVI_DDC; break; case BIOS_DDC_LINE__VGA: i2c_reg = GPIO_DDC1; break; case BIOS_DDC_LINE__CRT2: i2c_reg = GPIO_CRT2_DDC; break; case BIOS_DDC_LINE__GPIOPAD: i2c_reg = VIPPAD_EN; break; case BIOS_DDC_LINE__ZV_LCDPAD: i2c_reg = VIPPAD1_EN; break; default: i2c_reg = 0; break; } added = 0; switch (connector_type) { case BIOS_CONNECTOR_TYPE__CRT: ret = radeon_ms_combios_connector_add(dev, c, CONNECTOR_VGA, i2c_reg); if (ret) { return ret; } added = 1; break; case BIOS_CONNECTOR_TYPE__DVI_I: ret = radeon_ms_combios_connector_add(dev, c, CONNECTOR_DVI_I, i2c_reg); if (ret) { return ret; } added = 1; break; case BIOS_CONNECTOR_TYPE__DVI_D: ret = radeon_ms_combios_connector_add(dev, c, CONNECTOR_DVI_D, i2c_reg); if (ret) { return ret; } added = 1; break; default: break; } if (added) { j = 0; /* find to which output this connector is associated * by following same algo as in: * radeon_ms_outputs_from_combios*/ switch (dac_type) { case BIOS_DAC_TYPE__CRT: if (dac1 == -1) { dac1 = c; } dev_priv->connectors[c]->outputs[j++] = dac1; break; case BIOS_DAC_TYPE__NON_CRT: if (dac2 == -1) { dac2 = c; } dev_priv->connectors[c]->outputs[j++] = dac2; break; } #if 0 switch (tmds_type) { case BIOS_TMDS_TYPE__INTERNAL: if (tmdsint == -1) { tmdsint = c; } dev_priv->connectors[c]->outputs[j++] = tmdsint; break; case BIOS_TMDS_TYPE__EXTERNAL: if (tmdsext == -1) { tmdsext = c; } dev_priv->connectors[c]->outputs[j++] = tmdsext; break; } #endif c++; } } return c; } int radeon_ms_outputs_from_combios(struct drm_device *dev) { struct drm_radeon_private *dev_priv = dev->dev_private; struct combios_connector_chip_info *connector_chip_info; int connector_type, ddc_line, tmds_type, dac_type; int numof_connector, i, dac1_present, dac2_present, c = 0; int ret; dac1_present = dac2_present = 0; connector_chip_info = radeon_ms_combios_get_connector_chip_info(dev, 1); if (connector_chip_info == NULL) { return -1; } numof_connector = (connector_chip_info->ucChipHeader & BIOS_CHIPINFO_HEADER__NUMBER_OF_CONNECTORS__MASK) >> BIOS_CHIPINFO_HEADER__NUMBER_OF_CONNECTORS__SHIFT; DRM_INFO("[radeon_ms] COMBIOS number of connector: %d\n", numof_connector); for (i = 0; i < numof_connector; i++) { int connector_info = connector_chip_info->sConnectorInfo[i]; ret = radeon_combios_get_connector_infos(dev, connector_info, &connector_type, &ddc_line, &tmds_type, &dac_type); if (!dac1_present && dac_type == BIOS_DAC_TYPE__CRT) { dev_priv->outputs[c] = drm_alloc(sizeof(struct radeon_ms_output), DRM_MEM_DRIVER); if (dev_priv->outputs[c] == NULL) { radeon_ms_outputs_destroy(dev); return -ENOMEM; } memcpy(dev_priv->outputs[c], &radeon_ms_dac1, sizeof(struct radeon_ms_output)); dev_priv->outputs[c]->dev = dev; dev_priv->outputs[c]->initialize(dev_priv->outputs[c]); dac1_present = 1; c++; } if (!dac2_present && dac_type == BIOS_DAC_TYPE__NON_CRT) { dev_priv->outputs[c] = drm_alloc(sizeof(struct radeon_ms_output), DRM_MEM_DRIVER); if (dev_priv->outputs[c] == NULL) { radeon_ms_outputs_destroy(dev); return -ENOMEM; } memcpy(dev_priv->outputs[c], &radeon_ms_dac2, sizeof(struct radeon_ms_output)); dev_priv->outputs[c]->dev = dev; dev_priv->outputs[c]->initialize(dev_priv->outputs[c]); dac1_present = 1; c++; } } return c; } 97'>297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
/*
 * Copyright (c) 2006 Luc Verhaegen (quirks list)
 * Copyright (c) 2007 Intel Corporation
 *   Jesse Barnes <jesse.barnes@intel.com>
 *
 * DDC probing routines (drm_ddc_read & drm_do_probe_ddc_edid) originally from
 * FB layer.
 *   Copyright (C) 2006 Dennis Munsie <dmunsie@cecropia.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sub license,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER