drm/i915: Make data/link N value power of two
Subsystems (2)
RFC PATCH 1/1 drm/i915: Make data/link N value power of two
From: Ville Syrjälä <[email protected]>
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.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49402
---
Warning: I've only tested this with the Zotac dongle hooked to my 1080p Samsumg telly. Whether or not it works with other displays is an open question.
drivers/gpu/drm/i915/intel_display.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +17 -6
@@ -4151,18 +4151,29 @@ intel_reduce_ratio(uint32_t *num, uint32_t *den) } } +static void compute_m_n (int m,int n,uint32_t *ret_m,uint32_t *ret_n) +{ +if (n >=1 <<23 ) + *ret_n =1 <<23 ; +else + *ret_n =roundup_pow_of_two (n); + *ret_m =div_u64 ((uint64_t ) m * *ret_n, n); +intel_reduce_ratio (ret_m, ret_n); +} +void intel_link_compute_m_n (int bits_per_pixel,int nlanes,int pixel_clock,int link_clock,struct intel_link_m_n *m_n) { m_n->tu =64 ; - m_n->gmch_m = bits_per_pixel * pixel_clock; - m_n->gmch_n = link_clock * nlanes *8 ; -intel_reduce_ratio (&m_n->gmch_m, &m_n->gmch_n); - m_n->link_m = pixel_clock; - m_n->link_n = link_clock; -intel_reduce_ratio (&m_n->link_m, &m_n->link_n); + +compute_m_n (bits_per_pixel * pixel_clock, + link_clock * nlanes *8 , + &m_n->gmch_m, &m_n->gmch_n); + +compute_m_n (pixel_clock, link_clock, + &m_n->link_m, &m_n->link_n); }static inline bool intel_panel_use_ssc (struct drm_i915_private *dev_priv)
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · On Mon, Apr 22, 2013 at 05:23:50PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
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.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49402
Signed-off-by Ville Syrjälä <[email protected]>
It should work, but I'd be impressed if someone could dig up a rationale as to what is going wrong...
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 8 lines · On Mon, Apr 22, 2013 at 05:23:50PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
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.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49402
Signed-off-by Ville Syrjälä <[email protected]>
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 8 lines · On Mon, Apr 22, 2013 at 05:23:50PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
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.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49402
Signed-off-by Ville Syrjälä <[email protected]>
Since it took me a while to fire up my brain and understand the magic values ... can we please have some #defines for the magic 23 = 24 -1 and the magic 0xffffff = 1 << (24) - 1 ?
Also maybe call intel_reduce_ratio intel_reduce_m_n_ratio or so while at it.
Quoted 4 lines
---
Warning: I've only tested this with the Zotac dongle hooked to my 1080p Samsumg telly. Whether or not it works with other displays is an open question.
It's pretty early for 3.10, so I think we can just stick this into -fixes and see what happens.
-Daniel
Quoted 51 lines
drivers/gpu/drm/i915/intel_display.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/intel_display.c +17
-6@@ -4151,18 +4151,29 @@ intel_reduce_ratio(uint32_t *num, uint32_t *den) } } +static void compute_m_n (int m,int n,uint32_t *ret_m,uint32_t *ret_n) +{ +if (n >=1 <<23 ) + *ret_n =1 <<23 ; +else + *ret_n =roundup_pow_of_two (n); + *ret_m =div_u64 ((uint64_t ) m * *ret_n, n); +intel_reduce_ratio (ret_m, ret_n); +} +void intel_link_compute_m_n (int bits_per_pixel,int nlanes,int pixel_clock,int link_clock,struct intel_link_m_n *m_n) { m_n->tu =64 ; - m_n->gmch_m = bits_per_pixel * pixel_clock; - m_n->gmch_n = link_clock * nlanes *8 ; -intel_reduce_ratio (&m_n->gmch_m, &m_n->gmch_n); - m_n->link_m = pixel_clock; - m_n->link_n = link_clock; -intel_reduce_ratio (&m_n->link_m, &m_n->link_n); + +compute_m_n (bits_per_pixel * pixel_clock, + link_clock * nlanes *8 , + &m_n->gmch_m, &m_n->gmch_n); + +compute_m_n (pixel_clock, link_clock, + &m_n->link_m, &m_n->link_n); }static inline bool intel_panel_use_ssc (struct drm_i915_private *dev_priv)Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH v2 1/1 drm/i915: Make data/link N value power of two
From: Ville Syrjälä <[email protected]>
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
---
The N clamping now happens after the power of two rounding, but given the current clock speeds I don't think we're running out of bits yet.
drivers/gpu/drm/i915/i915_reg.h | 12 ++++-------- drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +4 -8
@@ -2770,14 +2770,14 @@#define _PIPEB_GMCH_DATA_M 0x71050/* Transfer unit size for display port - 1, default is 0x3f (for TU size 64) */ -#define PIPE_GMCH_DATA_M_TU_SIZE_MASK (0x3f << 25) -#define PIPE_GMCH_DATA_M_TU_SIZE_SHIFT 25 +#define TU_SIZE (x) (((x)-1) << 25)/* default size 64 */ +#define TU_SIZE_MASK (0x3f << 25) -#define PIPE_GMCH_DATA_M_MASK (0xffffff) +#define DATA_LINK_M_N_MASK (0xffffff) +#define DATA_LINK_N_MAX (0x800000)#define _PIPEA_GMCH_DATA_N 0x70054#define _PIPEB_GMCH_DATA_N 0x71054 -#define PIPE_GMCH_DATA_N_MASK (0xffffff)/* * Computing Link M and N values for the Display Port link
@@ -2792,11 +2792,9 @@#define _PIPEA_DP_LINK_M 0x70060#define _PIPEB_DP_LINK_M 0x71060 -#define PIPEA_DP_LINK_M_MASK (0xffffff)#define _PIPEA_DP_LINK_N 0x70064#define _PIPEB_DP_LINK_N 0x71064 -#define PIPEA_DP_LINK_N_MASK (0xffffff)#define PIPE_GMCH_DATA_M (pipe) _PIPE(pipe, _PIPEA_GMCH_DATA_M, _PIPEB_GMCH_DATA_M)#define PIPE_GMCH_DATA_N (pipe) _PIPE(pipe, _PIPEA_GMCH_DATA_N, _PIPEB_GMCH_DATA_N)
@@ -3522,8 +3520,6 @@#define _PIPEA_DATA_M1 (dev_priv->info->display_mmio_offset + 0x60030) -#define TU_SIZE (x) (((x)-1) << 25)/* default size 64 */ -#define TU_SIZE_MASK 0x7e000000#define PIPE_DATA_M1_OFFSET 0#define _PIPEA_DATA_N1 (dev_priv->info->display_mmio_offset + 0x60034)#define PIPE_DATA_N1_OFFSET 0
drivers/gpu/drm/i915/intel_display.c +18 -8
@@ -4143,26 +4143,36 @@ static int i830_get_display_clock_speed(struct drm_device *dev) }static void -intel_reduce_ratio (uint32_t *num,uint32_t *den) +intel_reduce_m_n_ratio (uint32_t *num,uint32_t *den) { -while (*num >0xffffff || *den >0xffffff ) { +while (*num >DATA_LINK_M_N_MASK || + *den >DATA_LINK_M_N_MASK ) { *num >>=1 ; *den >>=1 ; } } +static void compute_m_n (unsigned int m,unsigned int n, +uint32_t *ret_m,uint32_t *ret_n) +{ + *ret_n = min_t(unsigned int, roundup_pow_of_two(n), DATA_LINK_N_MAX); + *ret_m =div_u64 ((uint64_t ) m * *ret_n, n); +intel_reduce_m_n_ratio (ret_m, ret_n); +} +void intel_link_compute_m_n (int bits_per_pixel,int nlanes,int pixel_clock,int link_clock,struct intel_link_m_n *m_n) { m_n->tu =64 ; - m_n->gmch_m = bits_per_pixel * pixel_clock; - m_n->gmch_n = link_clock * nlanes *8 ; -intel_reduce_ratio (&m_n->gmch_m, &m_n->gmch_n); - m_n->link_m = pixel_clock; - m_n->link_n = link_clock; -intel_reduce_ratio (&m_n->link_m, &m_n->link_n); + +compute_m_n (bits_per_pixel * pixel_clock, + link_clock * nlanes *8 , + &m_n->gmch_m, &m_n->gmch_n); + +compute_m_n (pixel_clock, link_clock, + &m_n->link_m, &m_n->link_n); }static inline bool intel_panel_use_ssc (struct drm_i915_private *dev_priv)
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 46 lines · On Mon, 22 Apr 2013 17:23:50 +0300 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
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.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49402
Signed-off-by Ville Syrjälä <[email protected]>---
Warning: I've only tested this with the Zotac dongle hooked to my 1080p Samsumg telly. Whether or not it works with other displays is an open question.drivers/gpu/drm/i915/intel_display.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/intel_display.c +10
-6@@ -4151,18 +4151,29 @@ intel_reduce_ratio(uint32_t *num, uint32_t *den) } } +static void compute_m_n (int m,int n,uint32_t *ret_m,uint32_t *ret_n) +{ +if (n >=1 <<23 ) + *ret_n =1 <<23 ; +else + *ret_n =roundup_pow_of_two (n); + *ret_m =div_u64 ((uint64_t ) m * *ret_n, n); +intel_reduce_ratio (ret_m, ret_n); +} +void intel_link_compute_m_n (int bits_per_pixel,int nlanes,int pixel_clock,int link_clock,struct intel_link_m_n *m_n) { m_n->tu =64 ; - m_n->gmch_m = bits_per_pixel * pixel_clock; - m_n->gmch_n = link_clock * nlanes *8 ; -intel_reduce_ratio (&m_n->gmch_m, &m_n->gmch_n); - m_n->link_m = pixel_clock; - m_n->link_n = link_clock; -intel_reduce_ratio (&m_n->link_m, &m_n->link_n);
drivers/gpu/drm/i915/intel_display.c intel_reduce_ratio(uint32_t *num, uint32_t *den) · line 4179
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +7
-0+ +compute_m_n (bits_per_pixel * pixel_clock, + link_clock * nlanes *8 , + &m_n->gmch_m, &m_n->gmch_n); + +compute_m_n (pixel_clock, link_clock, + &m_n->link_m, &m_n->link_n); }static inline bool intel_panel_use_ssc (struct drm_i915_private *dev_priv)
You can add my Tested-by: to this one, it seems to fix
https://bugs.freedesktop.org/show_bug.cgi?id=59810 as well.
Art, is this something we've just missed and should have been doing all along?
Thanks,
Signature · 5 lines
Jesse Barnes, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx