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