diff options
author | Paulo Zanoni <paulo.r.zanoni@intel.com> | 2012-12-06 13:51:50 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-12-17 08:40:22 -0500 |
commit | f0a3424e964ec8e934497a0724cd1d58690fd9ab (patch) | |
tree | 42029c5f05ed80c7a38e0c0b6166a8ffed55f0cd /drivers/gpu/drm/i915/intel_dp.c | |
parent | a0e63c22ee6daae8fda98e1c6eaff5f5f1e2ba31 (diff) |
drm/i915: add intel_dp_set_signal_levels
So we can de-duplicate code that's inside intel_dp_start_link_train
and intel_dp_complete_link_train.
V2: Rebase since patch 3/5 was discarded.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_dp.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_dp.c | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 185bf4e7614e..2d3b26832397 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
@@ -1587,7 +1587,7 @@ intel_get_adjust_train(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_ST | |||
1587 | } | 1587 | } |
1588 | 1588 | ||
1589 | static uint32_t | 1589 | static uint32_t |
1590 | intel_dp_signal_levels(uint8_t train_set) | 1590 | intel_gen4_signal_levels(uint8_t train_set) |
1591 | { | 1591 | { |
1592 | uint32_t signal_levels = 0; | 1592 | uint32_t signal_levels = 0; |
1593 | 1593 | ||
@@ -1685,7 +1685,7 @@ intel_gen7_edp_signal_levels(uint8_t train_set) | |||
1685 | 1685 | ||
1686 | /* Gen7.5's (HSW) DP voltage swing and pre-emphasis control */ | 1686 | /* Gen7.5's (HSW) DP voltage swing and pre-emphasis control */ |
1687 | static uint32_t | 1687 | static uint32_t |
1688 | intel_dp_signal_levels_hsw(uint8_t train_set) | 1688 | intel_hsw_signal_levels(uint8_t train_set) |
1689 | { | 1689 | { |
1690 | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | | 1690 | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | |
1691 | DP_TRAIN_PRE_EMPHASIS_MASK); | 1691 | DP_TRAIN_PRE_EMPHASIS_MASK); |
@@ -1717,6 +1717,34 @@ intel_dp_signal_levels_hsw(uint8_t train_set) | |||
1717 | } | 1717 | } |
1718 | } | 1718 | } |
1719 | 1719 | ||
1720 | /* Properly updates "DP" with the correct signal levels. */ | ||
1721 | static void | ||
1722 | intel_dp_set_signal_levels(struct intel_dp *intel_dp, uint32_t *DP) | ||
1723 | { | ||
1724 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); | ||
1725 | struct drm_device *dev = intel_dig_port->base.base.dev; | ||
1726 | uint32_t signal_levels, mask; | ||
1727 | uint8_t train_set = intel_dp->train_set[0]; | ||
1728 | |||
1729 | if (IS_HASWELL(dev)) { | ||
1730 | signal_levels = intel_hsw_signal_levels(train_set); | ||
1731 | mask = DDI_BUF_EMP_MASK; | ||
1732 | } else if (IS_GEN7(dev) && is_cpu_edp(intel_dp) && !IS_VALLEYVIEW(dev)) { | ||
1733 | signal_levels = intel_gen7_edp_signal_levels(train_set); | ||
1734 | mask = EDP_LINK_TRAIN_VOL_EMP_MASK_IVB; | ||
1735 | } else if (IS_GEN6(dev) && is_cpu_edp(intel_dp)) { | ||
1736 | signal_levels = intel_gen6_edp_signal_levels(train_set); | ||
1737 | mask = EDP_LINK_TRAIN_VOL_EMP_MASK_SNB; | ||
1738 | } else { | ||
1739 | signal_levels = intel_gen4_signal_levels(train_set); | ||
1740 | mask = DP_VOLTAGE_MASK | DP_PRE_EMPHASIS_MASK; | ||
1741 | } | ||
1742 | |||
1743 | DRM_DEBUG_KMS("Using signal levels %08x\n", signal_levels); | ||
1744 | |||
1745 | *DP = (*DP & ~mask) | signal_levels; | ||
1746 | } | ||
1747 | |||
1720 | static bool | 1748 | static bool |
1721 | intel_dp_set_link_train(struct intel_dp *intel_dp, | 1749 | intel_dp_set_link_train(struct intel_dp *intel_dp, |
1722 | uint32_t dp_reg_value, | 1750 | uint32_t dp_reg_value, |
@@ -1853,24 +1881,8 @@ intel_dp_start_link_train(struct intel_dp *intel_dp) | |||
1853 | for (;;) { | 1881 | for (;;) { |
1854 | /* Use intel_dp->train_set[0] to set the voltage and pre emphasis values */ | 1882 | /* Use intel_dp->train_set[0] to set the voltage and pre emphasis values */ |
1855 | uint8_t link_status[DP_LINK_STATUS_SIZE]; | 1883 | uint8_t link_status[DP_LINK_STATUS_SIZE]; |
1856 | uint32_t signal_levels; | 1884 | |
1857 | 1885 | intel_dp_set_signal_levels(intel_dp, &DP); | |
1858 | if (IS_HASWELL(dev)) { | ||
1859 | signal_levels = intel_dp_signal_levels_hsw( | ||
1860 | intel_dp->train_set[0]); | ||
1861 | DP = (DP & ~DDI_BUF_EMP_MASK) | signal_levels; | ||
1862 | } else if (IS_GEN7(dev) && is_cpu_edp(intel_dp) && !IS_VALLEYVIEW(dev)) { | ||
1863 | signal_levels = intel_gen7_edp_signal_levels(intel_dp->train_set[0]); | ||
1864 | DP = (DP & ~EDP_LINK_TRAIN_VOL_EMP_MASK_IVB) | signal_levels; | ||
1865 | } else if (IS_GEN6(dev) && is_cpu_edp(intel_dp)) { | ||
1866 | signal_levels = intel_gen6_edp_signal_levels(intel_dp->train_set[0]); | ||
1867 | DP = (DP & ~EDP_LINK_TRAIN_VOL_EMP_MASK_SNB) | signal_levels; | ||
1868 | } else { | ||
1869 | signal_levels = intel_dp_signal_levels(intel_dp->train_set[0]); | ||
1870 | DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels; | ||
1871 | } | ||
1872 | DRM_DEBUG_KMS("training pattern 1 signal levels %08x\n", | ||
1873 | signal_levels); | ||
1874 | 1886 | ||
1875 | /* Set training pattern 1 */ | 1887 | /* Set training pattern 1 */ |
1876 | if (!intel_dp_set_link_train(intel_dp, DP, | 1888 | if (!intel_dp_set_link_train(intel_dp, DP, |
@@ -1926,7 +1938,6 @@ intel_dp_start_link_train(struct intel_dp *intel_dp) | |||
1926 | void | 1938 | void |
1927 | intel_dp_complete_link_train(struct intel_dp *intel_dp) | 1939 | intel_dp_complete_link_train(struct intel_dp *intel_dp) |
1928 | { | 1940 | { |
1929 | struct drm_device *dev = intel_dp_to_dev(intel_dp); | ||
1930 | bool channel_eq = false; | 1941 | bool channel_eq = false; |
1931 | int tries, cr_tries; | 1942 | int tries, cr_tries; |
1932 | uint32_t DP = intel_dp->DP; | 1943 | uint32_t DP = intel_dp->DP; |
@@ -1936,8 +1947,6 @@ intel_dp_complete_link_train(struct intel_dp *intel_dp) | |||
1936 | cr_tries = 0; | 1947 | cr_tries = 0; |
1937 | channel_eq = false; | 1948 | channel_eq = false; |
1938 | for (;;) { | 1949 | for (;;) { |
1939 | /* Use intel_dp->train_set[0] to set the voltage and pre emphasis values */ | ||
1940 | uint32_t signal_levels; | ||
1941 | uint8_t link_status[DP_LINK_STATUS_SIZE]; | 1950 | uint8_t link_status[DP_LINK_STATUS_SIZE]; |
1942 | 1951 | ||
1943 | if (cr_tries > 5) { | 1952 | if (cr_tries > 5) { |
@@ -1946,19 +1955,7 @@ intel_dp_complete_link_train(struct intel_dp *intel_dp) | |||
1946 | break; | 1955 | break; |
1947 | } | 1956 | } |
1948 | 1957 | ||
1949 | if (IS_HASWELL(dev)) { | 1958 | intel_dp_set_signal_levels(intel_dp, &DP); |
1950 | signal_levels = intel_dp_signal_levels_hsw(intel_dp->train_set[0]); | ||
1951 | DP = (DP & ~DDI_BUF_EMP_MASK) | signal_levels; | ||
1952 | } else if (IS_GEN7(dev) && is_cpu_edp(intel_dp) && !IS_VALLEYVIEW(dev)) { | ||
1953 | signal_levels = intel_gen7_edp_signal_levels(intel_dp->train_set[0]); | ||
1954 | DP = (DP & ~EDP_LINK_TRAIN_VOL_EMP_MASK_IVB) | signal_levels; | ||
1955 | } else if (IS_GEN6(dev) && is_cpu_edp(intel_dp)) { | ||
1956 | signal_levels = intel_gen6_edp_signal_levels(intel_dp->train_set[0]); | ||
1957 | DP = (DP & ~EDP_LINK_TRAIN_VOL_EMP_MASK_SNB) | signal_levels; | ||
1958 | } else { | ||
1959 | signal_levels = intel_dp_signal_levels(intel_dp->train_set[0]); | ||
1960 | DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels; | ||
1961 | } | ||
1962 | 1959 | ||
1963 | /* channel eq pattern */ | 1960 | /* channel eq pattern */ |
1964 | if (!intel_dp_set_link_train(intel_dp, DP, | 1961 | if (!intel_dp_set_link_train(intel_dp, DP, |