From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/7] drm/i915: Extract intel_mode_vtotal()
Date: Wed, 29 May 2024 12:06:46 +0300 [thread overview]
Message-ID: <87sey1j8bd.fsf@intel.com> (raw)
In-Reply-To: <20240528185647.7765-4-ville.syrjala@linux.intel.com>
On Tue, 28 May 2024, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> We have several copies of code calculating the hardware's
> idea of vtotal. Pull that to a helper, similar to
> intel_mode_vblank_{start,end}().
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_vblank.c | 40 +++++++++------------
> drivers/gpu/drm/i915/display/intel_vblank.h | 1 +
> 2 files changed, 18 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c
> index ba56015f2c40..31fa5867e1a7 100644
> --- a/drivers/gpu/drm/i915/display/intel_vblank.c
> +++ b/drivers/gpu/drm/i915/display/intel_vblank.c
> @@ -207,9 +207,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
> if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
> return __intel_get_crtc_scanline_from_timestamp(crtc);
>
> - vtotal = mode->crtc_vtotal;
> - if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> - vtotal /= 2;
> + vtotal = intel_mode_vtotal(mode);
>
> position = intel_de_read_fw(dev_priv, PIPEDSL(pipe)) & PIPEDSL_LINE_MASK;
>
> @@ -249,11 +247,7 @@ int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
> {
> const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
> const struct drm_display_mode *mode = &vblank->hwmode;
> - int vtotal;
> -
> - vtotal = mode->crtc_vtotal;
> - if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> - vtotal /= 2;
> + int vtotal = intel_mode_vtotal(mode);
>
> return (scanline + vtotal - crtc->scanline_offset) % vtotal;
> }
> @@ -310,13 +304,10 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
>
> htotal = mode->crtc_htotal;
> hsync_start = mode->crtc_hsync_start;
> - vtotal = mode->crtc_vtotal;
> + vtotal = intel_mode_vtotal(mode);
> vbl_start = intel_mode_vblank_start(mode);
> vbl_end = intel_mode_vblank_end(mode);
>
> - if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> - vtotal /= 2;
> -
> /*
> * Enter vblank critical section, as we will do multiple
> * timing critical raw register reads, potentially with
> @@ -508,19 +499,12 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state)
> * However if queried just before the start of vblank we'll get an
> * answer that's slightly in the future.
> */
> - if (DISPLAY_VER(i915) == 2) {
> - int vtotal;
> -
> - vtotal = adjusted_mode->crtc_vtotal;
> - if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE)
> - vtotal /= 2;
> -
> - return vtotal - 1;
> - } else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
> + if (DISPLAY_VER(i915) == 2)
> + return intel_mode_vtotal(adjusted_mode) - 1;
> + else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
> return 2;
> - } else {
> + else
> return 1;
> - }
> }
>
> void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
> @@ -592,6 +576,16 @@ int intel_mode_vblank_end(const struct drm_display_mode *mode)
> return vblank_end;
> }
>
> +int intel_mode_vtotal(const struct drm_display_mode *mode)
> +{
> + int vtotal = mode->crtc_vtotal;
> +
> + if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> + vtotal /= 2;
> +
> + return vtotal;
> +}
> +
> void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
> const struct intel_crtc_state *new_crtc_state,
> struct intel_vblank_evade_ctx *evade)
> diff --git a/drivers/gpu/drm/i915/display/intel_vblank.h b/drivers/gpu/drm/i915/display/intel_vblank.h
> index 6f11fd070f19..b51ae2c1039e 100644
> --- a/drivers/gpu/drm/i915/display/intel_vblank.h
> +++ b/drivers/gpu/drm/i915/display/intel_vblank.h
> @@ -22,6 +22,7 @@ struct intel_vblank_evade_ctx {
>
> int intel_mode_vblank_start(const struct drm_display_mode *mode);
> int intel_mode_vblank_end(const struct drm_display_mode *mode);
> +int intel_mode_vtotal(const struct drm_display_mode *mode);
>
> void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
> const struct intel_crtc_state *new_crtc_state,
--
Jani Nikula, Intel
next prev parent reply other threads:[~2024-05-29 9:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 18:56 [PATCH 0/7] drm/i915: Cleanups around scanline arithmetic Ville Syrjala
2024-05-28 18:56 ` [PATCH 1/7] drm/i915: Reuse intel_mode_vblank_start() Ville Syrjala
2024-05-29 9:03 ` Jani Nikula
2024-05-28 18:56 ` [PATCH 2/7] drm/i915: Extract intel_mode_vblank_end() Ville Syrjala
2024-05-29 9:05 ` Jani Nikula
2024-05-28 18:56 ` [PATCH 3/7] drm/i915: Extract intel_mode_vtotal() Ville Syrjala
2024-05-29 9:06 ` Jani Nikula [this message]
2024-05-28 18:56 ` [PATCH 4/7] drm/i915: Simplify scanline_offset handling for gen2 Ville Syrjala
2024-05-29 9:20 ` Jani Nikula
2024-05-28 18:56 ` [PATCH 5/7] drm/i915: Move intel_crtc_scanline_offset() Ville Syrjala
2024-05-29 9:22 ` Jani Nikula
2024-05-28 18:56 ` [PATCH 6/7] drm/i915: Switch intel_usecs_to_scanlines() to 64bit maths Ville Syrjala
2024-05-29 9:22 ` Jani Nikula
2024-05-28 18:56 ` [PATCH 7/7] drm/i915/dsb: Convert dewake_scanline to a hw scanline number earlier Ville Syrjala
2024-05-29 9:32 ` Jani Nikula
2024-05-28 20:01 ` ✓ Fi.CI.BAT: success for drm/i915: Cleanups around scanline arithmetic Patchwork
2024-05-29 14:15 ` ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sey1j8bd.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox