drm/kms/radeon: cleanup combios TV table like DDX.

The fallback case wasn't getting executed properly if there
was no TV table, which my T42 M7 hasn't got.

Signed-off-by: Dave Airlie <airlied@redhat.com>

+19 -29
+19 -29
drivers/gpu/drm/radeon/radeon_combios.c
··· 685 0x00780000, /* rs480 */ 686 }; 687 688 - static struct radeon_encoder_tv_dac 689 - *radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev) 690 { 691 - struct radeon_encoder_tv_dac *tv_dac = NULL; 692 - 693 - tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 694 - 695 - if (!tv_dac) 696 - return NULL; 697 - 698 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 699 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 700 tv_dac->ps2_tvdac_adj = 0x00880000; 701 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 702 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 703 - 704 - return tv_dac; 705 } 706 707 struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ··· 705 uint16_t dac_info; 706 uint8_t rev, bg, dac; 707 struct radeon_encoder_tv_dac *tv_dac = NULL; 708 709 if (rdev->bios == NULL) 710 - return radeon_legacy_get_tv_dac_info_from_table(rdev); 711 712 /* first check TV table */ 713 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 714 if (dac_info) { 715 - tv_dac = 716 - kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 717 - 718 - if (!tv_dac) 719 - return NULL; 720 - 721 rev = RBIOS8(dac_info + 0x3); 722 if (rev > 4) { 723 bg = RBIOS8(dac_info + 0xc) & 0xf; ··· 730 bg = RBIOS8(dac_info + 0x10) & 0xf; 731 dac = RBIOS8(dac_info + 0x11) & 0xf; 732 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 733 } else if (rev > 1) { 734 bg = RBIOS8(dac_info + 0xc) & 0xf; 735 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; ··· 743 bg = RBIOS8(dac_info + 0xe) & 0xf; 744 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 745 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 746 } 747 - 748 tv_dac->tv_std = radeon_combios_get_tv_info(encoder); 749 - 750 - } else { 751 /* then check CRT table */ 752 dac_info = 753 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 754 if (dac_info) { 755 - tv_dac = 756 - kzalloc(sizeof(struct radeon_encoder_tv_dac), 757 - GFP_KERNEL); 758 - 759 - if (!tv_dac) 760 - return NULL; 761 - 762 rev = RBIOS8(dac_info) & 0x3; 763 if (rev < 2) { 764 bg = RBIOS8(dac_info + 0x3) & 0xf; ··· 760 (bg << 16) | (dac << 20); 761 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 762 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 763 } else { 764 bg = RBIOS8(dac_info + 0x4) & 0xf; 765 dac = RBIOS8(dac_info + 0x5) & 0xf; ··· 768 (bg << 16) | (dac << 20); 769 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 770 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 771 } 772 } else { 773 DRM_INFO("No TV DAC info found in BIOS\n"); 774 - return radeon_legacy_get_tv_dac_info_from_table(rdev); 775 } 776 } 777 778 return tv_dac; 779 }
··· 685 0x00780000, /* rs480 */ 686 }; 687 688 + static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev, 689 + struct radeon_encoder_tv_dac *tv_dac) 690 { 691 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 692 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 693 tv_dac->ps2_tvdac_adj = 0x00880000; 694 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 695 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 696 + return; 697 } 698 699 struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ··· 713 uint16_t dac_info; 714 uint8_t rev, bg, dac; 715 struct radeon_encoder_tv_dac *tv_dac = NULL; 716 + int found = 0; 717 + 718 + tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 719 + if (!tv_dac) 720 + return NULL; 721 722 if (rdev->bios == NULL) 723 + goto out; 724 725 /* first check TV table */ 726 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 727 if (dac_info) { 728 rev = RBIOS8(dac_info + 0x3); 729 if (rev > 4) { 730 bg = RBIOS8(dac_info + 0xc) & 0xf; ··· 739 bg = RBIOS8(dac_info + 0x10) & 0xf; 740 dac = RBIOS8(dac_info + 0x11) & 0xf; 741 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 742 + found = 1; 743 } else if (rev > 1) { 744 bg = RBIOS8(dac_info + 0xc) & 0xf; 745 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; ··· 751 bg = RBIOS8(dac_info + 0xe) & 0xf; 752 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 753 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 754 + found = 1; 755 } 756 tv_dac->tv_std = radeon_combios_get_tv_info(encoder); 757 + } 758 + if (!found) { 759 /* then check CRT table */ 760 dac_info = 761 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 762 if (dac_info) { 763 rev = RBIOS8(dac_info) & 0x3; 764 if (rev < 2) { 765 bg = RBIOS8(dac_info + 0x3) & 0xf; ··· 775 (bg << 16) | (dac << 20); 776 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 777 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 778 + found = 1; 779 } else { 780 bg = RBIOS8(dac_info + 0x4) & 0xf; 781 dac = RBIOS8(dac_info + 0x5) & 0xf; ··· 782 (bg << 16) | (dac << 20); 783 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 784 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 785 + found = 1; 786 } 787 } else { 788 DRM_INFO("No TV DAC info found in BIOS\n"); 789 } 790 } 791 + 792 + out: 793 + if (!found) /* fallback to defaults */ 794 + radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac); 795 796 return tv_dac; 797 }