diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2013-04-23 08:03:34 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-04-23 16:19:26 -0400 |
commit | a65851af59387146a28a928c3e7bb17dabc5db72 (patch) | |
tree | 7207836d2c2fdfbe933d790a6dc3186ebd681059 /drivers/gpu | |
parent | ae4edb8089df67d25fbd9386012a335a64aca287 (diff) |
drm/i915: Make data/link N value power of two
The BIOS uses power of two values for the data/link N value.
Follow suit to make the Zotac DP to dual-HDMI dongle work.
v2: Clean up the magic numbers and defines
Change the N clamping to be a bit easier on the eye
Rename intel_reduce_ratio to intel_reduce_m_n_ratio
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49402
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59810
Tested-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/i915/i915_reg.h | 12 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 26 |
2 files changed, 22 insertions, 16 deletions
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 31de7e4b1f3e..83f9c26e1adb 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
@@ -2652,14 +2652,14 @@ | |||
2652 | #define _PIPEB_GMCH_DATA_M 0x71050 | 2652 | #define _PIPEB_GMCH_DATA_M 0x71050 |
2653 | 2653 | ||
2654 | /* Transfer unit size for display port - 1, default is 0x3f (for TU size 64) */ | 2654 | /* Transfer unit size for display port - 1, default is 0x3f (for TU size 64) */ |
2655 | #define PIPE_GMCH_DATA_M_TU_SIZE_MASK (0x3f << 25) | 2655 | #define TU_SIZE(x) (((x)-1) << 25) /* default size 64 */ |
2656 | #define PIPE_GMCH_DATA_M_TU_SIZE_SHIFT 25 | 2656 | #define TU_SIZE_MASK (0x3f << 25) |
2657 | 2657 | ||
2658 | #define PIPE_GMCH_DATA_M_MASK (0xffffff) | 2658 | #define DATA_LINK_M_N_MASK (0xffffff) |
2659 | #define DATA_LINK_N_MAX (0x800000) | ||
2659 | 2660 | ||
2660 | #define _PIPEA_GMCH_DATA_N 0x70054 | 2661 | #define _PIPEA_GMCH_DATA_N 0x70054 |
2661 | #define _PIPEB_GMCH_DATA_N 0x71054 | 2662 | #define _PIPEB_GMCH_DATA_N 0x71054 |
2662 | #define PIPE_GMCH_DATA_N_MASK (0xffffff) | ||
2663 | 2663 | ||
2664 | /* | 2664 | /* |
2665 | * Computing Link M and N values for the Display Port link | 2665 | * Computing Link M and N values for the Display Port link |
@@ -2674,11 +2674,9 @@ | |||
2674 | 2674 | ||
2675 | #define _PIPEA_DP_LINK_M 0x70060 | 2675 | #define _PIPEA_DP_LINK_M 0x70060 |
2676 | #define _PIPEB_DP_LINK_M 0x71060 | 2676 | #define _PIPEB_DP_LINK_M 0x71060 |
2677 | #define PIPEA_DP_LINK_M_MASK (0xffffff) | ||
2678 | 2677 | ||
2679 | #define _PIPEA_DP_LINK_N 0x70064 | 2678 | #define _PIPEA_DP_LINK_N 0x70064 |
2680 | #define _PIPEB_DP_LINK_N 0x71064 | 2679 | #define _PIPEB_DP_LINK_N 0x71064 |
2681 | #define PIPEA_DP_LINK_N_MASK (0xffffff) | ||
2682 | 2680 | ||
2683 | #define PIPE_GMCH_DATA_M(pipe) _PIPE(pipe, _PIPEA_GMCH_DATA_M, _PIPEB_GMCH_DATA_M) | 2681 | #define PIPE_GMCH_DATA_M(pipe) _PIPE(pipe, _PIPEA_GMCH_DATA_M, _PIPEB_GMCH_DATA_M) |
2684 | #define PIPE_GMCH_DATA_N(pipe) _PIPE(pipe, _PIPEA_GMCH_DATA_N, _PIPEB_GMCH_DATA_N) | 2682 | #define PIPE_GMCH_DATA_N(pipe) _PIPE(pipe, _PIPEA_GMCH_DATA_N, _PIPEB_GMCH_DATA_N) |
@@ -3404,8 +3402,6 @@ | |||
3404 | 3402 | ||
3405 | 3403 | ||
3406 | #define _PIPEA_DATA_M1 (dev_priv->info->display_mmio_offset + 0x60030) | 3404 | #define _PIPEA_DATA_M1 (dev_priv->info->display_mmio_offset + 0x60030) |
3407 | #define TU_SIZE(x) (((x)-1) << 25) /* default size 64 */ | ||
3408 | #define TU_SIZE_MASK 0x7e000000 | ||
3409 | #define PIPE_DATA_M1_OFFSET 0 | 3405 | #define PIPE_DATA_M1_OFFSET 0 |
3410 | #define _PIPEA_DATA_N1 (dev_priv->info->display_mmio_offset + 0x60034) | 3406 | #define _PIPEA_DATA_N1 (dev_priv->info->display_mmio_offset + 0x60034) |
3411 | #define PIPE_DATA_N1_OFFSET 0 | 3407 | #define PIPE_DATA_N1_OFFSET 0 |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 6e423e04c35e..efe829919755 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -4084,26 +4084,36 @@ static int i830_get_display_clock_speed(struct drm_device *dev) | |||
4084 | } | 4084 | } |
4085 | 4085 | ||
4086 | static void | 4086 | static void |
4087 | intel_reduce_ratio(uint32_t *num, uint32_t *den) | 4087 | intel_reduce_m_n_ratio(uint32_t *num, uint32_t *den) |
4088 | { | 4088 | { |
4089 | while (*num > 0xffffff || *den > 0xffffff) { | 4089 | while (*num > DATA_LINK_M_N_MASK || |
4090 | *den > DATA_LINK_M_N_MASK) { | ||
4090 | *num >>= 1; | 4091 | *num >>= 1; |
4091 | *den >>= 1; | 4092 | *den >>= 1; |
4092 | } | 4093 | } |
4093 | } | 4094 | } |
4094 | 4095 | ||
4096 | static void compute_m_n(unsigned int m, unsigned int n, | ||
4097 | uint32_t *ret_m, uint32_t *ret_n) | ||
4098 | { | ||
4099 | *ret_n = min_t(unsigned int, roundup_pow_of_two(n), DATA_LINK_N_MAX); | ||
4100 | *ret_m = div_u64((uint64_t) m * *ret_n, n); | ||
4101 | intel_reduce_m_n_ratio(ret_m, ret_n); | ||
4102 | } | ||
4103 | |||
4095 | void | 4104 | void |
4096 | intel_link_compute_m_n(int bits_per_pixel, int nlanes, | 4105 | intel_link_compute_m_n(int bits_per_pixel, int nlanes, |
4097 | int pixel_clock, int link_clock, | 4106 | int pixel_clock, int link_clock, |
4098 | struct intel_link_m_n *m_n) | 4107 | struct intel_link_m_n *m_n) |
4099 | { | 4108 | { |
4100 | m_n->tu = 64; | 4109 | m_n->tu = 64; |
4101 | m_n->gmch_m = bits_per_pixel * pixel_clock; | 4110 | |
4102 | m_n->gmch_n = link_clock * nlanes * 8; | 4111 | compute_m_n(bits_per_pixel * pixel_clock, |
4103 | intel_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n); | 4112 | link_clock * nlanes * 8, |
4104 | m_n->link_m = pixel_clock; | 4113 | &m_n->gmch_m, &m_n->gmch_n); |
4105 | m_n->link_n = link_clock; | 4114 | |
4106 | intel_reduce_ratio(&m_n->link_m, &m_n->link_n); | 4115 | compute_m_n(pixel_clock, link_clock, |
4116 | &m_n->link_m, &m_n->link_n); | ||
4107 | } | 4117 | } |
4108 | 4118 | ||
4109 | static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv) | 4119 | static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv) |