All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mahesh Kumar <mahesh1.kumar@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: paulo.r.zanoni@intel.com, maarten.lankhorst@intel.com
Subject: [PATCH 04/11] drm/i915/skl+: calculate pixel_rate & relative_data_rate in fixed point
Date: Mon,  8 May 2017 17:18:55 +0530	[thread overview]
Message-ID: <20170508114902.18965-5-mahesh1.kumar@intel.com> (raw)
In-Reply-To: <20170508114902.18965-1-mahesh1.kumar@intel.com>

This patch make changes to calculate adjusted plane pixel rate &
plane downscale amount using fixed_point functions available.
This patch will give uniformity in code, & will help to avoid mixing of
32bit uint32_t variable for fixed-16.16 with fixed_16_16_t variables in
later patch in the series.

Signed-off-by: Mahesh Kumar <mahesh1.kumar@intel.com>
---
 drivers/gpu/drm/i915/intel_pm.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 66b542ba47ad..6414701ef09e 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3360,26 +3360,27 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  * Return value is provided in 16.16 fixed point form to retain fractional part.
  * Caller should take care of dividing & rounding off the value.
  */
-static uint32_t
+static uint_fixed_16_16_t
 skl_plane_downscale_amount(const struct intel_crtc_state *cstate,
 			   const struct intel_plane_state *pstate)
 {
 	struct intel_plane *plane = to_intel_plane(pstate->base.plane);
-	uint32_t downscale_h, downscale_w;
 	uint32_t src_w, src_h, dst_w, dst_h;
+	uint_fixed_16_16_t fp_w_ratio, fp_h_ratio;
+	uint_fixed_16_16_t downscale_h, downscale_w;
 
 	if (WARN_ON(!intel_wm_plane_visible(cstate, pstate)))
-		return DRM_PLANE_HELPER_NO_SCALING;
+		return u32_to_fixed_16_16(0);
 
 	/* n.b., src is 16.16 fixed point, dst is whole integer */
 	if (plane->id == PLANE_CURSOR) {
-		src_w = pstate->base.src_w;
-		src_h = pstate->base.src_h;
+		src_w = pstate->base.src_w >> 16;
+		src_h = pstate->base.src_h >> 16;
 		dst_w = pstate->base.crtc_w;
 		dst_h = pstate->base.crtc_h;
 	} else {
-		src_w = drm_rect_width(&pstate->base.src);
-		src_h = drm_rect_height(&pstate->base.src);
+		src_w = drm_rect_width(&pstate->base.src) >> 16;
+		src_h = drm_rect_height(&pstate->base.src) >> 16;
 		dst_w = drm_rect_width(&pstate->base.dst);
 		dst_h = drm_rect_height(&pstate->base.dst);
 	}
@@ -3387,11 +3388,13 @@ skl_plane_downscale_amount(const struct intel_crtc_state *cstate,
 	if (drm_rotation_90_or_270(pstate->base.rotation))
 		swap(dst_w, dst_h);
 
-	downscale_h = max(src_h / dst_h, (uint32_t)DRM_PLANE_HELPER_NO_SCALING);
-	downscale_w = max(src_w / dst_w, (uint32_t)DRM_PLANE_HELPER_NO_SCALING);
+	fp_w_ratio = fixed_16_16_div(src_w, dst_w);
+	fp_h_ratio = fixed_16_16_div(src_h, dst_h);
+	downscale_w = max_fixed_16_16(fp_w_ratio, u32_to_fixed_16_16(1));
+	downscale_h = max_fixed_16_16(fp_h_ratio, u32_to_fixed_16_16(1));
 
 	/* Provide result in 16.16 fixed point */
-	return (uint64_t)downscale_w * downscale_h >> 16;
+	return mul_fixed_16_16(downscale_w, downscale_h);
 }
 
 static unsigned int
@@ -3401,10 +3404,11 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 {
 	struct intel_plane *plane = to_intel_plane(pstate->plane);
 	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
-	uint32_t down_scale_amount, data_rate;
+	uint32_t data_rate;
 	uint32_t width = 0, height = 0;
 	struct drm_framebuffer *fb;
 	u32 format;
+	uint_fixed_16_16_t down_scale_amount;
 
 	if (!intel_pstate->base.visible)
 		return 0;
@@ -3438,7 +3442,7 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 
 	down_scale_amount = skl_plane_downscale_amount(cstate, intel_pstate);
 
-	return (uint64_t)data_rate * down_scale_amount >> 16;
+	return mul_u32_fixed_16_16_round_up(data_rate, down_scale_amount);
 }
 
 /*
@@ -3724,8 +3728,7 @@ static uint32_t skl_adjusted_plane_pixel_rate(const struct intel_crtc_state *cst
 					      struct intel_plane_state *pstate)
 {
 	uint64_t adjusted_pixel_rate;
-	uint64_t downscale_amount;
-	uint64_t pixel_rate;
+	uint_fixed_16_16_t downscale_amount;
 
 	/* Shouldn't reach here on disabled planes... */
 	if (WARN_ON(!intel_wm_plane_visible(cstate, pstate)))
@@ -3738,10 +3741,8 @@ static uint32_t skl_adjusted_plane_pixel_rate(const struct intel_crtc_state *cst
 	adjusted_pixel_rate = cstate->pixel_rate;
 	downscale_amount = skl_plane_downscale_amount(cstate, pstate);
 
-	pixel_rate = adjusted_pixel_rate * downscale_amount >> 16;
-	WARN_ON(pixel_rate != clamp_t(uint32_t, pixel_rate, 0, ~0));
-
-	return pixel_rate;
+	return mul_u32_fixed_16_16_round_up(adjusted_pixel_rate,
+					    downscale_amount);
 }
 
 static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-05-08 11:45 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 11:48 [PATCH 00/11] Implement DDB algorithm and WM cleanup Mahesh Kumar
2017-05-08 11:48 ` [PATCH 01/11] drm/i915: fix naming of fixed_16_16 wrapper Mahesh Kumar
2017-05-12  0:21   ` Matt Roper
2017-05-08 11:48 ` [PATCH 02/11] drm/i915: Add more wrapper for fixed_point_16_16 operations Mahesh Kumar
2017-05-10 12:37   ` Maarten Lankhorst
2017-05-12  0:22   ` Matt Roper
2017-05-12  8:55     ` Mahesh Kumar
2017-05-08 11:48 ` [PATCH 03/11] drm/i915: Use fixed_16_16 wrapper for division operation Mahesh Kumar
2017-05-12  0:22   ` Matt Roper
2017-05-08 11:48 ` Mahesh Kumar [this message]
2017-05-12  0:22   ` [PATCH 04/11] drm/i915/skl+: calculate pixel_rate & relative_data_rate in fixed point Matt Roper
2017-05-08 11:48 ` [PATCH 05/11] drm/i915/skl: Fail the flip if no FB for WM calculation Mahesh Kumar
2017-05-08 11:48   ` Lankhorst, Maarten
2017-05-08 12:01     ` Mahesh Kumar
2017-05-12  0:22       ` Matt Roper
2017-05-08 11:48 ` [PATCH 06/11] drm/i915/skl+: no need to memset again Mahesh Kumar
2017-05-12  0:23   ` Matt Roper
2017-05-08 11:48 ` [PATCH 07/11] drm/i915/skl+: Fail the flip if ddb min requirement exceeds pipe allocation Mahesh Kumar
2017-05-08 14:12   ` Ander Conselvan De Oliveira
2017-05-09  7:50     ` Mahesh Kumar
2017-05-09  7:52     ` Mahesh Kumar
2017-05-12  0:23   ` Matt Roper
2017-05-12 13:44     ` Mahesh Kumar
2017-05-08 11:48 ` [PATCH 08/11] drm/i915/skl+: Watermark calculation cleanup Mahesh Kumar
2017-05-12  0:23   ` Matt Roper
2017-05-12 13:47     ` Mahesh Kumar
2017-05-08 11:49 ` [PATCH 09/11] drm/i915/skl+: use linetime latency if ddb size is not available Mahesh Kumar
2017-05-08 11:49 ` [PATCH 10/11] drm/i915/skl: New ddb allocation algorithm Mahesh Kumar
2017-05-12 22:24   ` Matt Roper
2017-05-15  8:15     ` Mahesh Kumar
2017-05-08 11:49 ` [PATCH 11/11] drm/i915/skl+: consider max supported plane pixel rate while scaling Mahesh Kumar
2017-05-10 13:22   ` Maarten Lankhorst
2017-05-11  8:36     ` Mahesh Kumar
2017-05-11  9:48       ` Maarten Lankhorst
2017-05-11 10:59         ` Mahesh Kumar
2017-05-11 13:05         ` [PATCH v4 " Mahesh Kumar
2017-05-11  9:18     ` [PATCH v2] " Mahesh Kumar
2017-05-08 12:37 ` ✓ Fi.CI.BAT: success for Implement DDB algorithm and WM cleanup (rev2) Patchwork
2017-05-09  8:12 ` ✓ Fi.CI.BAT: success for Implement DDB algorithm and WM cleanup (rev4) Patchwork
2017-05-11  9:35 ` ✓ Fi.CI.BAT: success for Implement DDB algorithm and WM cleanup (rev5) Patchwork
2017-05-11 14:11 ` ✓ Fi.CI.BAT: success for Implement DDB algorithm and WM cleanup (rev6) Patchwork
2017-05-12  0:21 ` [PATCH 00/11] Implement DDB algorithm and WM cleanup Matt Roper
2017-05-12  8:25   ` Mahesh Kumar

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=20170508114902.18965-5-mahesh1.kumar@intel.com \
    --to=mahesh1.kumar@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@intel.com \
    --cc=paulo.r.zanoni@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.