Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/bridge: analogix-anx78xx: Avoid drm_dp_link helpers

During the discussion of patches that enhance the drm_dp_link helpers it
was concluded that these helpers aren't very useful to begin with. Start
pushing the equivalent code into individual drivers to ultimately remove
them.

v4: use bulk DPCD writes if possible (Daniel Vetter)

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20191022145211.2258525-1-thierry.reding@gmail.com

+39 -17
+39 -17
drivers/gpu/drm/bridge/analogix-anx78xx.c
··· 71 71 struct i2c_client *client; 72 72 struct edid *edid; 73 73 struct drm_connector connector; 74 - struct drm_dp_link link; 75 74 struct anx78xx_platform_data pdata; 76 75 struct mutex lock; 77 76 ··· 747 748 748 749 static int anx78xx_dp_link_training(struct anx78xx *anx78xx) 749 750 { 750 - u8 dp_bw, value; 751 + u8 dp_bw, dpcd[2]; 751 752 int err; 752 753 753 754 err = regmap_write(anx78xx->map[I2C_IDX_RX_P0], SP_HDMI_MUTE_CTRL_REG, ··· 800 801 if (err) 801 802 return err; 802 803 803 - /* Check link capabilities */ 804 - err = drm_dp_link_probe(&anx78xx->aux, &anx78xx->link); 805 - if (err < 0) { 806 - DRM_ERROR("Failed to probe link capabilities: %d\n", err); 807 - return err; 808 - } 804 + /* 805 + * Power up the sink (DP_SET_POWER register is only available on DPCD 806 + * v1.1 and later). 807 + */ 808 + if (anx78xx->dpcd[DP_DPCD_REV] >= 0x11) { 809 + err = drm_dp_dpcd_readb(&anx78xx->aux, DP_SET_POWER, &dpcd[0]); 810 + if (err < 0) { 811 + DRM_ERROR("Failed to read DP_SET_POWER register: %d\n", 812 + err); 813 + return err; 814 + } 809 815 810 - /* Power up the sink */ 811 - err = drm_dp_link_power_up(&anx78xx->aux, &anx78xx->link); 812 - if (err < 0) { 813 - DRM_ERROR("Failed to power up DisplayPort link: %d\n", err); 814 - return err; 816 + dpcd[0] &= ~DP_SET_POWER_MASK; 817 + dpcd[0] |= DP_SET_POWER_D0; 818 + 819 + err = drm_dp_dpcd_writeb(&anx78xx->aux, DP_SET_POWER, dpcd[0]); 820 + if (err < 0) { 821 + DRM_ERROR("Failed to power up DisplayPort link: %d\n", 822 + err); 823 + return err; 824 + } 825 + 826 + /* 827 + * According to the DP 1.1 specification, a "Sink Device must 828 + * exit the power saving state within 1 ms" (Section 2.5.3.1, 829 + * Table 5-52, "Sink Control Field" (register 0x600). 830 + */ 831 + usleep_range(1000, 2000); 815 832 } 816 833 817 834 /* Possibly enable downspread on the sink */ ··· 866 851 if (err) 867 852 return err; 868 853 869 - value = drm_dp_link_rate_to_bw_code(anx78xx->link.rate); 854 + dpcd[0] = drm_dp_max_link_rate(anx78xx->dpcd); 855 + dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]); 870 856 err = regmap_write(anx78xx->map[I2C_IDX_TX_P0], 871 - SP_DP_MAIN_LINK_BW_SET_REG, value); 857 + SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]); 872 858 if (err) 873 859 return err; 874 860 875 - err = drm_dp_link_configure(&anx78xx->aux, &anx78xx->link); 861 + dpcd[1] = drm_dp_max_lane_count(anx78xx->dpcd); 862 + 863 + if (drm_dp_enhanced_frame_cap(anx78xx->dpcd)) 864 + dpcd[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN; 865 + 866 + err = drm_dp_dpcd_write(&anx78xx->aux, DP_LINK_BW_SET, dpcd, 867 + sizeof(dpcd)); 876 868 if (err < 0) { 877 - DRM_ERROR("Failed to configure DisplayPort link: %d\n", err); 869 + DRM_ERROR("Failed to configure link: %d\n", err); 878 870 return err; 879 871 } 880 872