Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org, Animesh Manna <animesh.manna@intel.com>
Subject: [PATCH v2 08/13] drm/i915: Introduce intel_scanlines_to_usecs()
Date: Mon, 30 Sep 2024 20:04:10 +0300	[thread overview]
Message-ID: <20240930170415.23841-9-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20240930170415.23841-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Introduce intel_scanlines_to_usecs() as a counterpart to
intel_usecs_to_scanlines().

We'll have some use for this in DSB code as we want to do
relative scanline waits to evade the delayed vblank, but
unfortunately DSB can't do relative scanline waits (only
absolute). So we'll instead convert the relative scanline
count to usec and do a relative usec wait instead (which the
DSB knows how to do).

Reviewed-by: Animesh Manna <animesh.manna@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_crtc.c | 11 +++++++++++
 drivers/gpu/drm/i915/display/intel_crtc.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index 3a28d8450a38..8ed8dd5fe458 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -483,6 +483,17 @@ int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
 				1000 * adjusted_mode->crtc_htotal);
 }
 
+int intel_scanlines_to_usecs(const struct drm_display_mode *adjusted_mode,
+			     int scanlines)
+{
+	/* paranoia */
+	if (!adjusted_mode->crtc_clock)
+		return 1;
+
+	return DIV_ROUND_UP_ULL(mul_u32_u32(scanlines, adjusted_mode->crtc_htotal * 1000),
+				adjusted_mode->crtc_clock);
+}
+
 /**
  * intel_pipe_update_start() - start update of a set of display registers
  * @state: the atomic state
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.h b/drivers/gpu/drm/i915/display/intel_crtc.h
index a58ecd11bba2..34ffbd2ee1b7 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.h
+++ b/drivers/gpu/drm/i915/display/intel_crtc.h
@@ -31,6 +31,8 @@ struct intel_display;
 
 int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
 			     int usecs);
+int intel_scanlines_to_usecs(const struct drm_display_mode *adjusted_mode,
+			     int scanlines);
 void intel_crtc_arm_vblank_event(struct intel_crtc_state *crtc_state);
 u32 intel_crtc_max_vblank_count(const struct intel_crtc_state *crtc_state);
 int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe);
-- 
2.45.2


  parent reply	other threads:[~2024-09-30 17:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 17:04 [PATCH v2 00/13] drm/i915: Use DSB for plane/color management commits Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 01/13] drm/i915/dsb: Avoid reads of the DSB buffer for indexed register writes Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 02/13] drm/i915: Prepare clear color before wait_for_dependencies() Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 03/13] drm/i915/dsb: Generate the DSB buffer in commit_tail() Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 04/13] drm/i915/dsb: Enable programmable DSB interrupt Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 05/13] drm/i915/dsb: Introduce intel_dsb_vblank_evade() Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 06/13] drm/i915/dsb: Introduce intel_dsb_wait_usec() Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 07/13] drm/i915/dsb: Introduce intel_dsb_wait_vblanks() Ville Syrjala
2024-09-30 17:04 ` Ville Syrjala [this message]
2024-09-30 17:04 ` [PATCH v2 09/13] drm/i915/dsb: Introduce intel_dsb_wait_vblank_delay() Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 10/13] drm/i915: Extract intel_crtc_prepare_vblank_event() Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 11/13] drm/i915: Plumb 'dsb' all way to the plane hooks Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 12/13] drm/i915: Plumb 'dsb' all way to the color commit hooks Ville Syrjala
2024-09-30 17:04 ` [PATCH v2 13/13] drm/i915/dsb: Use DSB for plane/color management updates Ville Syrjala
2024-09-30 23:18 ` ✓ CI.Patch_applied: success for drm/i915: Use DSB for plane/color management commits Patchwork
2024-09-30 23:19 ` ✗ CI.checkpatch: warning " Patchwork
2024-09-30 23:20 ` ✓ CI.KUnit: success " Patchwork
2024-09-30 23:31 ` ✓ CI.Build: " Patchwork
2024-09-30 23:34 ` ✓ CI.Hooks: " Patchwork
2024-09-30 23:35 ` ✗ CI.checksparse: warning " Patchwork
2024-09-30 23:58 ` ✓ CI.BAT: success " Patchwork
2024-10-01  9:45 ` ✗ CI.FULL: failure " Patchwork
2024-10-03 21:52 ` [PATCH v2 00/13] " Ville Syrjälä

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=20240930170415.23841-9-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=animesh.manna@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    /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