Re: [PATCH 05/16] drm/i915/skl+: NV12 related changes for WM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ideal case would have been an enum for nv12 planes with y and uv parameters, to indicate in code, but I will at least prefer the plane_num variable should be replaced by plane_id, as plane_number 0 and 1 confuses.

With that change, feel free to use:

Reviewed-by: Shashank Sharma <shashank.sharma@xxxxxxxxx>

Regards
Shashank
On 2/14/2018 10:27 AM, Vidya Srinivas wrote:
From: Mahesh Kumar <mahesh1.kumar@xxxxxxxxx>

NV12 requires WM calculation for UV plane as well.
UV plane WM should also fulfill all the WM related restrictions.

v2: Addressed review comments from Shashank Sharma.

Signed-off-by: Mahesh Kumar <mahesh1.kumar@xxxxxxxxx>
---
  drivers/gpu/drm/i915/i915_drv.h  |  1 +
  drivers/gpu/drm/i915/intel_drv.h |  1 +
  drivers/gpu/drm/i915/intel_pm.c  | 55 +++++++++++++++++++++++++++++++---------
  3 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b9914bb..9a9a645 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1463,6 +1463,7 @@ struct skl_wm_level {
  struct skl_wm_params {
  	bool x_tiled, y_tiled;
  	bool rc_surface;
+	bool is_planar;
  	uint32_t width;
  	uint8_t cpp;
  	uint32_t plane_pixel_rate;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index f13decc..6402d6d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -594,6 +594,7 @@ struct intel_pipe_wm {
struct skl_plane_wm {
  	struct skl_wm_level wm[8];
+	struct skl_wm_level uv_wm[8];
  	struct skl_wm_level trans_wm;
  	bool is_planar;
  };
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index bc0e2bf..2a0cc0b 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -4422,7 +4422,7 @@ static int
  skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv,
  			    struct intel_crtc_state *cstate,
  			    const struct intel_plane_state *intel_pstate,
-			    struct skl_wm_params *wp)
+			    struct skl_wm_params *wp, int plane_num)
  {
  	struct intel_plane *plane = to_intel_plane(intel_pstate->base.plane);
  	const struct drm_plane_state *pstate = &intel_pstate->base;
@@ -4435,6 +4435,12 @@ skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv,
  	if (!intel_wm_plane_visible(cstate, intel_pstate))
  		return 0;
+ /* only NV12 format has two planes */
+	if (plane_num == 1 && fb->format->format != DRM_FORMAT_NV12) {
+		DRM_DEBUG_KMS("Non NV12 format have single plane\n");
+		return -EINVAL;
+	}
+
  	wp->y_tiled = fb->modifier == I915_FORMAT_MOD_Y_TILED ||
  		      fb->modifier == I915_FORMAT_MOD_Yf_TILED ||
  		      fb->modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
@@ -4442,6 +4448,7 @@ skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv,
  	wp->x_tiled = fb->modifier == I915_FORMAT_MOD_X_TILED;
  	wp->rc_surface = fb->modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
  			 fb->modifier == I915_FORMAT_MOD_Yf_TILED_CCS;
+	wp->is_planar = fb->format->format == DRM_FORMAT_NV12;
if (plane->id == PLANE_CURSOR) {
  		wp->width = intel_pstate->base.crtc_w;
@@ -4454,7 +4461,10 @@ skl_compute_plane_wm_params(const struct drm_i915_private *dev_priv,
  		wp->width = drm_rect_width(&intel_pstate->base.src) >> 16;
  	}
- wp->cpp = fb->format->cpp[0];
+	if (plane_num == 1 && wp->is_planar)
+		wp->width /= 2;
+
+	wp->cpp = fb->format->cpp[plane_num];
  	wp->plane_pixel_rate = skl_adjusted_plane_pixel_rate(cstate,
  							     intel_pstate);
@@ -4652,7 +4662,8 @@ skl_compute_wm_levels(const struct drm_i915_private *dev_priv,
  		      struct intel_crtc_state *cstate,
  		      const struct intel_plane_state *intel_pstate,
  		      const struct skl_wm_params *wm_params,
-		      struct skl_plane_wm *wm)
+		      struct skl_plane_wm *wm,
+		      int plane_num)
  {
  	struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc);
  	struct drm_plane *plane = intel_pstate->base.plane;
@@ -4660,15 +4671,19 @@ skl_compute_wm_levels(const struct drm_i915_private *dev_priv,
  	uint16_t ddb_blocks;
  	enum pipe pipe = intel_crtc->pipe;
  	int level, max_level = ilk_wm_max_level(dev_priv);
+	enum plane_id plane_id = intel_plane->id;
  	int ret;
if (WARN_ON(!intel_pstate->base.fb))
  		return -EINVAL;
- ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][intel_plane->id]);
+	ddb_blocks = plane_num ?
+		     skl_ddb_entry_size(&ddb->uv_plane[pipe][plane_id]) :
+		     skl_ddb_entry_size(&ddb->plane[pipe][plane_id]);
for (level = 0; level <= max_level; level++) {
-		struct skl_wm_level *result = &wm->wm[level];
+		struct skl_wm_level *result = plane_num ? &wm->uv_wm[level] :
+							  &wm->wm[level];
ret = skl_compute_plane_wm(dev_priv,
  					   cstate,
@@ -4683,9 +4698,6 @@ skl_compute_wm_levels(const struct drm_i915_private *dev_priv,
  			return ret;
  	}
- if (intel_pstate->base.fb->format->format == DRM_FORMAT_NV12)
-		wm->is_nv12 = true;
-
  	return 0;
  }
@@ -4794,20 +4806,39 @@ static int skl_build_pipe_wm(struct intel_crtc_state *cstate, wm = &pipe_wm->planes[plane_id];
  		ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][plane_id]);
-		memset(&wm_params, 0, sizeof(struct skl_wm_params));
ret = skl_compute_plane_wm_params(dev_priv, cstate,
-						  intel_pstate, &wm_params);
+						  intel_pstate, &wm_params, 0);
  		if (ret)
  			return ret;
ret = skl_compute_wm_levels(dev_priv, ddb, cstate,
-					    intel_pstate, &wm_params, wm);
+					    intel_pstate, &wm_params, wm, 0);
  		if (ret)
  			return ret;
+
  		skl_compute_transition_wm(cstate, &wm_params, &wm->wm[0],
  					  ddb_blocks, &wm->trans_wm);
+
+		/* uv plane watermarks must also be validated for NV12/Planar */
+		if (wm_params.is_planar) {
+			memset(&wm_params, 0, sizeof(struct skl_wm_params));
+			wm->is_planar = true;
+
+			ret = skl_compute_plane_wm_params(dev_priv, cstate,
+							  intel_pstate,
+							  &wm_params, 1);
+			if (ret)
+				return ret;
+
+			ret = skl_compute_wm_levels(dev_priv, ddb, cstate,
+						    intel_pstate, &wm_params,
+						    wm, 1);
+			if (ret)
+				return ret;
+		}
  	}
+
  	pipe_wm->linetime = skl_compute_linetime_wm(cstate);
return 0;
@@ -4862,7 +4893,7 @@ static void skl_write_plane_wm(struct intel_crtc *intel_crtc,
  		return skl_ddb_entry_write(dev_priv,
  					   PLANE_BUF_CFG(pipe, plane_id),
  					   &ddb->plane[pipe][plane_id]);
-	if (wm->is_nv12) {
+	if (wm->is_planar) {
  		skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane_id),
  				    &ddb->uv_plane[pipe][plane_id]);
  		skl_ddb_entry_write(dev_priv,

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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux