drm/i915: get mode clock when reading the pipe config
Subsystems (2)
PATCH 1/1 drm/i915: get mode clock when reading the pipe config
We need this for comparing modes between configuration changes.
--- drivers/gpu/drm/i915/intel_display.c | 49 +++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +43 -6
@@ -45,6 +45,11 @@ bool intel_pipe_has_type(struct drm_crtc *crtc, int type);static void intel_increase_pllclock (struct drm_crtc *crtc);static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on); +static void i9xx_crtc_clock_get (struct intel_crtc *crtc, +struct intel_crtc_config *pipe_config); +static void ironlake_crtc_clock_get (struct intel_crtc *crtc, +struct intel_crtc_config *pipe_config); +typedef struct {int min, max; }intel_range_t ;
@@ -4981,6 +4986,8 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc,intel_get_pipe_timings (crtc, pipe_config); +i9xx_crtc_clock_get (crtc, pipe_config); +return true; }
@@ -5900,6 +5907,8 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,intel_get_pipe_timings (crtc, pipe_config); +ironlake_crtc_clock_get (crtc, pipe_config); +return true; }
@@ -6048,6 +6057,8 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,intel_get_pipe_timings (crtc, pipe_config); +ironlake_crtc_clock_get (crtc, pipe_config); +return true; }
@@ -6902,11 +6913,12 @@ void intel_release_load_detect_pipe(struct drm_connector *connector, }/* Returns the clock of the currently programmed mode of the given pipe. */ -static int intel_crtc_clock_get (struct drm_device *dev,struct drm_crtc *crtc) +static void i9xx_crtc_clock_get (struct intel_crtc *crtc, +struct intel_crtc_config *pipe_config) { +struct drm_device *dev = crtc->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; -struct intel_crtc *intel_crtc =to_intel_crtc (crtc); -int pipe = intel_crtc->pipe; +int pipe = pipe_config->cpu_transcoder;u32 dpll =I915_READ (DPLL (pipe));u32 fp;intel_clock_t clock;
@@ -6945,7 +6957,8 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)default :DRM_DEBUG_KMS ("Unknown DPLL mode %08x in programmed " "mode\n" , (int )(dpll &DPLL_MODE_MASK )); -return 0 ; + pipe_config->adjusted_mode.clock =0 ; +return ; }/* XXX: Handle the 100Mhz refclk */
@@ -6984,8 +6997,28 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)* i830PllIsValid() because it relies on the xf86_config connector * configuration being accurate, which it isn't necessarily. */ + pipe_config->adjusted_mode.clock = clock.dot; +} + +static void ironlake_crtc_clock_get (struct intel_crtc *crtc, +struct intel_crtc_config *pipe_config) +{ +struct drm_device *dev = crtc->base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +enum transcoder cpu_transcoder = pipe_config->cpu_transcoder; +int clock; +u32 link_m; + +/* +* PCH platforms make this easy: we can just use the LINK_M1 reg. +* Note: this may be the pixel clock for a fitted mode, in which +* case it won't match the native mode clock. That means we won't be +* able to do a simple flip in the fastboot case. +*/ + link_m =I915_READ (PIPE_LINK_M1 (cpu_transcoder)); + clock = link_m; -return clock.dot; + pipe_config->adjusted_mode.clock = clock; }/** Returns the currently programmed mode of the given pipe. */
@@ -6996,6 +7029,7 @@ struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,struct intel_crtc *intel_crtc =to_intel_crtc (crtc);enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;struct drm_display_mode *mode; +struct intel_crtc_config pipe_config;int htot =I915_READ (HTOTAL (cpu_transcoder));int hsync =I915_READ (HSYNC (cpu_transcoder));int vtot =I915_READ (VTOTAL (cpu_transcoder));
@@ -7005,7 +7039,10 @@ struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,if (!mode)return NULL ; - mode->clock =intel_crtc_clock_get (dev, crtc); + pipe_config.cpu_transcoder = intel_crtc->pipe; +i9xx_crtc_clock_get (intel_crtc, &pipe_config); + + mode->clock = pipe_config.adjusted_mode.clock; mode->hdisplay = (htot &0xffff ) +1 ; mode->htotal = ((htot &0xffff0000 ) >>16 ) +1 ; mode->hsync_start = (hsync &0xffff ) +1 ;
Signature · 1 line
1.7.9.5
PATCH 1/1 drm/i915: get mode clock when reading the pipe config v2
We need this for comparing modes between configuration changes.
v2: try harder to calulate non-simple pixel clocks (Daniel)
call get_clock after getting the encoder config, needed for pixel multiply (Jesse)
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_crt.c | 1 + drivers/gpu/drm/i915/intel_display.c | 80 +++++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_dp.c | 8 ++++ drivers/gpu/drm/i915/intel_drv.h | 3 ++ drivers/gpu/drm/i915/intel_dvo.c | 1 + drivers/gpu/drm/i915/intel_hdmi.c | 1 + drivers/gpu/drm/i915/intel_lvds.c | 1 + drivers/gpu/drm/i915/intel_sdvo.c | 2 + 9 files changed, 91 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -305,6 +305,7 @@ struct drm_i915_display_funcs {* fills out the pipe-config with the hw state. */ bool (*get_pipe_config)(struct intel_crtc *,struct intel_crtc_config *); +void (*get_clock)(struct intel_crtc *,struct intel_crtc_config *);int (*crtc_mode_set)(struct drm_crtc *crtc,int x,int y,struct drm_framebuffer *old_fb);
drivers/gpu/drm/i915/intel_crt.c +1 -0
@@ -101,6 +101,7 @@ static void intel_crt_get_config(struct intel_encoder *encoder, flags |=DRM_MODE_FLAG_NVSYNC ; pipe_config->adjusted_mode.flags |= flags; + pipe_config->pixel_multiplier =1 ; }static void intel_disable_crt (struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_display.c +73 -7
150 lines not on this page · raw message
drivers/gpu/drm/i915/intel_dp.c +8 -0
@@ -1403,6 +1403,14 @@ static void intel_dp_get_config(struct intel_encoder *encoder, flags |=DRM_MODE_FLAG_NVSYNC ; pipe_config->adjusted_mode.flags |= flags; + pipe_config->pixel_multiplier =1 ; + +if (is_cpu_edp (intel_dp)) { +if ((I915_READ (DP_A ) &DP_PLL_FREQ_MASK ) ==DP_PLL_FREQ_160MHZ ) + pipe_config->cpu_edp_link_rate =162000 ; +else + pipe_config->cpu_edp_link_rate =270000 ; + } }static void intel_disable_dp (struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_drv.h +3 -0
@@ -272,6 +272,9 @@ struct intel_crtc_config {/* FDI configuration, only valid if has_pch_encoder is set. */ int fdi_lanes;struct intel_link_m_n fdi_m_n; + +/* CPU eDP config */ +int cpu_edp_link_rate; };struct intel_crtc {
drivers/gpu/drm/i915/intel_dvo.c +1 -0
@@ -143,6 +143,7 @@ static void intel_dvo_get_config(struct intel_encoder *encoder, flags |=DRM_MODE_FLAG_PVSYNC ; pipe_config->adjusted_mode.flags |= flags; + pipe_config->pixel_multiplier =1 ; }static void intel_disable_dvo (struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_hdmi.c +1 -0
@@ -678,6 +678,7 @@ static void intel_hdmi_get_config(struct intel_encoder *encoder, flags |=DRM_MODE_FLAG_NVSYNC ; pipe_config->adjusted_mode.flags |= flags; + pipe_config->pixel_multiplier =1 ; }static void intel_enable_hdmi (struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_lvds.c +1 -0
@@ -105,6 +105,7 @@ static void intel_lvds_get_config(struct intel_encoder *encoder, flags |=DRM_MODE_FLAG_NVSYNC ; pipe_config->adjusted_mode.flags |= flags; + pipe_config->pixel_multiplier =1 ; }/* The LVDS pin pair needs to be on before the DPLLs are enabled.
drivers/gpu/drm/i915/intel_sdvo.c +2 -0
@@ -1284,6 +1284,8 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, flags |=DRM_MODE_FLAG_NVSYNC ; pipe_config->adjusted_mode.flags |= flags; +/* FIXME: get real multiplier from DPLL or SDVO reg */ + pipe_config->pixel_multiplier =1 ; }static void intel_disable_sdvo (struct intel_encoder *encoder)
Signature · 1 line
1.7.9.5
Re: [PATCH] drm/i915: get mode clock when reading the pipe config v2
Quoted 6 lines · On Fri, 3 May 2013 15:34:41 -0700 Jesse Barnes <[email protected]>…
We need this for comparing modes between configuration changes.
v2: try harder to calulate non-simple pixel clocks (Daniel)
callget_clockafter getting the encoder config, needed for pixel multiply (Jesse)
In reply to danvet's questions:
- I can move the pixel multiplier into get_config; I thought some of our encoder regs had a bit that could be used
- if I do that, I don't need to call get_clock separately; it needs the pixel multiplier to calculate m/n correctly, so that's why I had to put it after the encoder get_config
I added pipe config checks for the new mode flags, and I get warnings now, but I don't want to add one for the clock just yet. Maybe after everything is in and working we can add one...
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Re: [PATCH] drm/i915: get mode clock when reading the pipe config v2
Quoted 17 lines · Jesse Barnes
Quoted 6 lines · On Fri, 3 May 2013 15:34:41 -0700 Jesse Barnes <[email protected]>…
We need this for comparing modes between configuration changes.
v2: try harder to calulate non-simple pixel clocks (Daniel)
callget_clockafter getting the encoder config, needed for pixel multiply (Jesse)In reply to danvet's questions:
- I can move the pixel multiplier intoget_config; I thought some of our encoder regs had a bit that could be used
- if I do that, I don't need to callget_clockseparately; it needs the pixel multiplier to calculate m/n correctly, so that's why I had to put it after the encoderget_config
Quoted 3 lines
I added pipe config checks for the new mode flags, and I get warnings now, but I don't want to add one for the clock just yet. Maybe after everything is in and working we can add one...
Yeah, if you have something known-broken in the pipe config check it'll shadow all follow-up checks. So I think you could just smash the clock comparison at the bottom with a big warning why it needs to be there.
Mode flags otoh I think we should be able to get right. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch