drm/i915: adjusted_mode.clock vs. port_clock vs. pixel_multiplier
Subsystems (2)
cover drm/i915: adjusted_mode.clock vs. port_clock vs. pixel_multiplier
As I mentioned before, I'd like adjusted_mode.clock to be the pipe pixel clock. So to me it looks like all we need to do to store the pixel multiplied clock into port_clock, and then adjusted_mode.clock can stay as the non-multiplied pixel clock.
Seems simple enough. But a big warning here, I didn't test this at all yet. Also I don't have any SDVO hardware to make sure I didn't fumble something on that side.
PATCH 1/2 drm/i915: Don't factor in pixel multplier when deriving dotclock from link clock and M/N values
From: Ville Syrjälä <[email protected]>
We feed the non-multiplied clock to intel_link_compute_m_n(), so the opposite operation should use the same order of operations. So we just multiply by pixel_multiplier in the end now.
--- drivers/gpu/drm/i915/intel_display.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_display.c +7 -8
@@ -7372,20 +7372,18 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc,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 link_freq, repeat; +int link_freq;u64 clock;u32 link_m, link_n; - repeat = pipe_config->pixel_multiplier; -/* * The calculation for the data clock is: -* pixel_clock = ((m/n)*(link_clock * nr_lanes * repeat))/bpp +* pixel_clock = ((m/n)*(link_clock * nr_lanes))/bpp * But we want to avoid losing precison if possible, so: -* pixel_clock = ((m * link_clock * nr_lanes * repeat)/(n*bpp)) +* pixel_clock = ((m * link_clock * nr_lanes)/(n*bpp)) * * and the link clock is simpler: -* link_clock = (m * link_clock * repeat) / n +* link_clock = (m * link_clock) / n */ /*
@@ -7407,10 +7405,11 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc,if (!link_m || !link_n)return ; - clock = ((u64 )link_m * (u64 )link_freq * (u64 )repeat); + clock = ((u64 )link_m * (u64 )link_freq);do_div (clock, link_n); - pipe_config->adjusted_mode.clock = clock; + pipe_config->adjusted_mode.clock = clock * + pipe_config->pixel_multiplier; }/** Returns the currently programmed mode of the given pipe. */
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915: Make adjusted_mode.clock non-pixel multiplied
In reply to [email protected]From: Ville Syrjälä <[email protected]>
It would be easier if adjusted_mode.clock would be the pipe pixel clock, and it actually is, except for the cases where pixel_multiplier > 1.
So let's change intel_sdvo to use port_clock as the multiplied clock, and then we can leave adjusted_mode.clock as pipe pixel clock.
--- drivers/gpu/drm/i915/intel_display.c | 10 ++++------ drivers/gpu/drm/i915/intel_sdvo.c | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_display.c +4 -6
@@ -4095,7 +4095,6 @@ retry: link_bw =intel_fdi_link_freq (dev) *MHz (100 )/KHz (1 )/10 ; fdi_dotclock = adjusted_mode->clock; - fdi_dotclock /= pipe_config->pixel_multiplier; lane =ironlake_get_lanes_required (fdi_dotclock, link_bw, pipe_config->pipe_bpp);
@@ -7362,8 +7361,7 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc, } } - pipe_config->adjusted_mode.clock = clock.dot * - pipe_config->pixel_multiplier; + pipe_config->adjusted_mode.clock = clock.dot; } static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
@@ -7408,8 +7406,7 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc, clock = ((u64 )link_m * (u64 )link_freq);do_div (clock, link_n); - pipe_config->adjusted_mode.clock = clock * - pipe_config->pixel_multiplier; + pipe_config->adjusted_mode.clock = clock; }/** Returns the currently programmed mode of the given pipe. */
@@ -8360,7 +8357,8 @@ encoder_retry:/* Set default port clock if not overwritten by the encoder. Needs to be * done afterwards in case the encoder adjusts the mode. */ if (!pipe_config->port_clock) - pipe_config->port_clock = pipe_config->adjusted_mode.clock; + pipe_config->port_clock = pipe_config->adjusted_mode.clock * + pipe_config->pixel_multiplier; ret =intel_crtc_compute_config (to_intel_crtc (crtc), pipe_config);if (ret <0 ) {
drivers/gpu/drm/i915/intel_sdvo.c +1 -2
@@ -1059,7 +1059,7 @@ intel_sdvo_get_preferred_input_mode(struct intel_sdvo *intel_sdvo,static void i9xx_adjust_sdvo_tv_clock (struct intel_crtc_config *pipe_config) { -unsigned dotclock = pipe_config->adjusted_mode.clock; +unsigned dotclock = pipe_config->port_clock;struct dpll *clock = &pipe_config->dpll;/* SDVO TV has fixed PLL values depend on its clock range,
@@ -1124,7 +1124,6 @@ static bool intel_sdvo_compute_config(struct intel_encoder *encoder,*/ pipe_config->pixel_multiplier =intel_sdvo_get_pixel_multiplier (adjusted_mode); - adjusted_mode->clock *= pipe_config->pixel_multiplier;if (intel_sdvo->color_range_auto) {/* See CEA-861-E - 5.1 Default Encoding Parameters */
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Make adjusted_mode.clock non-pixel multiplied
Quoted 9 lines · On Tue, Sep 03, 2013 at 04:21:04PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
It would be easier if adjusted_mode.clock would be the pipe pixel clock, and it actually is, except for the cases where
pixel_multiplier> 1.So let's change
intel_sdvoto useport_clockas the multiplied clock, and then we can leave adjusted_mode.clock as pipe pixel clock.Signed-off-by Ville Syrjälä <[email protected]>
Yeah I think this makes sense. Comment updates for port_clock in intel_drv.h to also mention the pixel multiplier would be good. Plus adding a fuzzy port_clock check to the config comparator - teaching intel_fuzzy_clock_check to just compare two clocks and adding a PIPE_CONF_FUZZY_CLOCK_CHECK macro for both adjusted_mode.clock and port_clock would be great.
Of course we still need to make those checks conditional on !HSW :(
Cheers, Daniel
Quoted 75 lines
--- drivers/gpu/drm/i915/intel_display.c | 10 ++++------ drivers/gpu/drm/i915/intel_sdvo.c | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-)drivers/gpu/drm/i915/intel_display.c +4
-6@@ -4095,7 +4095,6 @@ retry: link_bw =intel_fdi_link_freq (dev) *MHz (100 )/KHz (1 )/10 ; fdi_dotclock = adjusted_mode->clock; - fdi_dotclock /= pipe_config->pixel_multiplier; lane =ironlake_get_lanes_required (fdi_dotclock, link_bw, pipe_config->pipe_bpp);@@ -7362,8 +7361,7 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc, } } - pipe_config->adjusted_mode.clock = clock.dot * - pipe_config->pixel_multiplier; + pipe_config->adjusted_mode.clock = clock.dot; } static void ironlake_crtc_clock_get(struct intel_crtc *crtc,@@ -7408,8 +7406,7 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc, clock = ((u64 )link_m * (u64 )link_freq);do_div (clock, link_n); - pipe_config->adjusted_mode.clock = clock * - pipe_config->pixel_multiplier; + pipe_config->adjusted_mode.clock = clock; }/** Returns the currently programmed mode of the given pipe. */ @@ -8360,7 +8357,8 @@ encoder_retry:/* Set default port clock if not overwritten by the encoder. Needs to be * done afterwards in case the encoder adjusts the mode. */ if (!pipe_config->port_clock) - pipe_config->port_clock = pipe_config->adjusted_mode.clock; + pipe_config->port_clock = pipe_config->adjusted_mode.clock * + pipe_config->pixel_multiplier; ret =intel_crtc_compute_config (to_intel_crtc (crtc), pipe_config);if (ret <0 ) {drivers/gpu/drm/i915/intel_sdvo.c +1
-2@@ -1059,7 +1059,7 @@ intel_sdvo_get_preferred_input_mode(struct intel_sdvo *intel_sdvo,static void i9xx_adjust_sdvo_tv_clock (struct intel_crtc_config *pipe_config) { -unsigned dotclock = pipe_config->adjusted_mode.clock; +unsigned dotclock = pipe_config->port_clock;struct dpll *clock = &pipe_config->dpll;/* SDVO TV has fixed PLL values depend on its clock range, @@ -1124,7 +1124,6 @@ static bool intel_sdvo_compute_config(struct intel_encoder *encoder,*/ pipe_config->pixel_multiplier =intel_sdvo_get_pixel_multiplier (adjusted_mode); - adjusted_mode->clock *= pipe_config->pixel_multiplier;if (intel_sdvo->color_range_auto) {/* See CEA-861-E - 5.1 Default Encoding Parameters */ 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