Skip to contentSkip to conversation

drm/i915: Add a per-pipe plane identifier enum (v2)

PATCH In review [email protected] 6 participants 22 messages Nov 22, 2016 – Dec 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover drm/i915: Add a per-pipe plane identifier enum (v2)

From: Ville Syrjälä <[email protected]>

I ended up tweaking quite a few of the patches (and even adding a new one) based on Paulo's review, so figured I'd repost the entire thing.

I didn't do the _ID_ rename thing, at least not yet. I'll have to think about it more if I could come up with some nice way to deal with the per-pipe id vs. the A/B/C plane id.

Anyways, enough of these got r-bs so that I can at least move forward with VLV/CHV watermark rewrite #4 now.

Ville Syrjälä (9):
drm/i915: Add per-pipe plane identifier
drm/i915: Add crtc->plane_ids_mask
drm/i915: Use enum plane_id in SKL wm code
drm/i915: Use enum plane_id in SKL plane code
drm/i915: Use enum plane_id in VLV/CHV sprite code drm/i915: Use enum plane_id in VLV/CHV wm code
drm/i915: s/plane/plane_id/ in skl+ plane register defines drm/i915: Don't populate plane->plane for cursors and sprites drm/i915: Rename the local 'plane' variable to 'plane_id' in primary
plane code

 drivers/gpu/drm/i915/i915_drv.h      |  30 ++++-
 drivers/gpu/drm/i915/i915_reg.h      | 104 +++++++-------
 drivers/gpu/drm/i915/intel_display.c |  96 ++++++-------
 drivers/gpu/drm/i915/intel_drv.h     |   6 +-
 drivers/gpu/drm/i915/intel_pm.c      | 253 ++++++++++++++++-------------------
 drivers/gpu/drm/i915/intel_sprite.c  | 118 ++++++++--------
 6 files changed, 304 insertions(+), 303 deletions(-)
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v2 1/9 drm/i915: Add per-pipe plane identifier

From: Ville Syrjälä <[email protected]>

As I told people in [1] we really should not be confusing enum plane as a per-pipe plane identifier. Looks like that happened nonetheless, so let's fix it up by splitting the two into two enums.

We'll also want something we just directly pass to various register offset macros and whatnot on SKL+. So let's make this new thing work for that. Currently we pass intel_plane->plane for the "sprites" and just a hardcoded zero for the "primary" planes. We want to get rid of that hardocoding so that we can share the same code for all planes (apart from the legacy cursor of course).

[1] https://lists.freedesktop.org/archives/intel-gfx/2015-September/076082.html

---
 drivers/gpu/drm/i915/i915_drv.h      | 28 +++++++++++++++++++++-------
 drivers/gpu/drm/i915/intel_display.c |  2 ++
 drivers/gpu/drm/i915/intel_drv.h     |  3 ++-
 drivers/gpu/drm/i915/intel_sprite.c  |  1 +
 4 files changed, 26 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +21 -7
index c7d5f7a30fe8..6c9864287b29 100644
@@ -180,22 +180,36 @@ static inline bool transcoder_is_dsi(enum transcoder transcoder)
 }
 
 /*
- * I915_MAX_PLANES in the enum below is the maximum (across all platforms)
- * number of planes per CRTC.  Not all platforms really have this many planes,
- * which means some arrays of size I915_MAX_PLANES may have unused entries
- * between the topmost sprite plane and the cursor plane.
+ * Global legacy plane identifier. Valid only for primary/sprite
+ * planes on pre-g4x, and only for primary planes on g4x+.
  */
 enum plane {
-	PLANE_A = 0,
+	PLANE_A,
 	PLANE_B,
 	PLANE_C,
-	PLANE_CURSOR,
-	I915_MAX_PLANES,
 };
 #define plane_name(p) ((p) + 'A')
 
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev_priv)->num_sprites[(p)] + (s) + 'A')
 
+/*
+ * Per-pipe plane identifier.
+ * I915_MAX_PLANES in the enum below is the maximum (across all platforms)
+ * number of planes per CRTC.  Not all platforms really have this many planes,
+ * which means some arrays of size I915_MAX_PLANES may have unused entries
+ * between the topmost sprite plane and the cursor plane.
+ *
+ * This is expected to be passed to various register macros
+ * (eg. PLANE_CTL(), PS_PLANE_SEL(), etc.) so adjust with care.
+ */
+enum plane_id {
+	PLANE_PRIMARY,
+	PLANE_SPRITE0,
+	PLANE_SPRITE1,
+	PLANE_CURSOR,
+	I915_MAX_PLANES,
+};
+
 enum port {
 	PORT_NONE = -1,
 	PORT_A = 0,
drivers/gpu/drm/i915/intel_display.c +2 -0
index b7a7ed82c325..dfd3dbe6a92a 100644
@@ -14988,6 +14988,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
 		primary->plane = (enum plane) !pipe;
 	else
 		primary->plane = (enum plane) pipe;
+	primary->id = PLANE_PRIMARY;
 	primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe);
 	primary->check_plane = intel_check_primary_plane;
 
@@ -15187,6 +15188,7 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
 	cursor->max_downscale = 1;
 	cursor->pipe = pipe;
 	cursor->plane = pipe;
+	cursor->id = PLANE_CURSOR;
 	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);
 	cursor->check_plane = intel_check_cursor_plane;
 	cursor->update_plane = intel_update_cursor_plane;
drivers/gpu/drm/i915/intel_drv.h +2 -1
index cd132c216a67..b2a0409330a9 100644
@@ -766,7 +766,8 @@ struct intel_plane_wm_parameters {
 
 struct intel_plane {
 	struct drm_plane base;
-	int plane;
+	u8 plane;
+	enum plane_id id;
 	enum pipe pipe;
 	bool can_scale;
 	int max_downscale;
drivers/gpu/drm/i915/intel_sprite.c +1 -0
index 8f131a08d440..b5f750364e99 100644
@@ -1112,6 +1112,7 @@ intel_sprite_plane_create(struct drm_i915_private *dev_priv,
 
 	intel_plane->pipe = pipe;
 	intel_plane->plane = plane;
+	intel_plane->id = PLANE_SPRITE0 + plane;
 	intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane);
 	intel_plane->check_plane = intel_check_sprite_plane;
 
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH v2 2/9 drm/i915: Add crtc->plane_ids_mask

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a mask of which planes are available for each pipe. This doesn't quite work for old platforms with dynamic plane<->pipe assignment, but as we don't support that sort of stuff (yet) we can get away with it.

The main use I have for this is the for_each_plane_id_on_crtc() macro for iterating over all possible planes on the crtc. I suppose we could not add the mask, and instead iterate by comparing intel_plane->pipe but then we'd need a local intel_plane variable which is just unnecessary clutter in some cases. But I'm not hung up on this, so if people prefer the other option I could be convinced to use it.

v2: Use BIT() in the iterator macro too (Paulo)

---
 drivers/gpu/drm/i915/i915_drv.h      | 4 ++++
 drivers/gpu/drm/i915/intel_display.c | 3 +++
 drivers/gpu/drm/i915/intel_drv.h     | 3 ++-
 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 6c9864287b29..90bd31d71a81 100644
@@ -210,6 +210,10 @@ enum plane_id {
 	I915_MAX_PLANES,
 };
 
+#define for_each_plane_id_on_crtc(__crtc, __p) \
+	for ((__p) = PLANE_PRIMARY; (__p) < I915_MAX_PLANES; (__p)++) \
+		for_each_if ((__crtc)->plane_ids_mask & BIT(__p))
+
 enum port {
 	PORT_NONE = -1,
 	PORT_A = 0,
drivers/gpu/drm/i915/intel_display.c +3 -0
index dfd3dbe6a92a..6c3032f04d54 100644
@@ -15277,6 +15277,7 @@ static int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe)
 		ret = PTR_ERR(primary);
 		goto fail;
 	}
+	intel_crtc->plane_ids_mask |= BIT(primary->id);
 
 	for_each_sprite(dev_priv, pipe, sprite) {
 		struct intel_plane *plane;
@@ -15286,6 +15287,7 @@ static int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe)
 			ret = PTR_ERR(plane);
 			goto fail;
 		}
+		intel_crtc->plane_ids_mask |= BIT(plane->id);
 	}
 
 	cursor = intel_cursor_plane_create(dev_priv, pipe);
@@ -15293,6 +15295,7 @@ static int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe)
 		ret = PTR_ERR(cursor);
 		goto fail;
 	}
+	intel_crtc->plane_ids_mask |= BIT(cursor->id);
 
 	ret = drm_crtc_init_with_planes(&dev_priv->drm, &intel_crtc->base,
 					&primary->base, &cursor->base,
drivers/gpu/drm/i915/intel_drv.h +2 -1
index b2a0409330a9..c1b245853ba9 100644
@@ -691,8 +691,9 @@ struct intel_crtc {
 	 * some outputs connected to this crtc.
 	 */
 	bool active;
-	unsigned long enabled_power_domains;
 	bool lowfreq_avail;
+	u8 plane_ids_mask;
+	unsigned long enabled_power_domains;
 	struct intel_overlay *overlay;
 	struct intel_flip_work *flip_work;
 
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH v2 3/9 drm/i915: Use enum plane_id in SKL wm code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Nuke skl_wm_plane_id() and just use the new intel_plane->id.

v2: Convert skl_write_plane_wm() as well
v3: Convert skl_pipe_wm_get_hw_state() correctly
v4: Rebase due to changes in the wm code
Drop the cursor FIXME from the total data rate calc (Paulo) Use the "[PLANE:%d:%s]" format in debug print (Paulo)

Cc Matt Roper <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 180 +++++++++++++++++-----------------------
 1 file changed, 77 insertions(+), 103 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +77 -103
index bbb1eaf1e6db..e6351445016d 100644
@@ -2867,28 +2867,6 @@ bool ilk_disable_lp_wm(struct drm_device *dev)
 #define SKL_SAGV_BLOCK_TIME	30 /* µs */
 
 /*
- * Return the index of a plane in the SKL DDB and wm result arrays.  Primary
- * plane is always in slot 0, cursor is always in slot I915_MAX_PLANES-1, and
- * other universal planes are in indices 1..n.  Note that this may leave unused
- * indices between the top "sprite" plane and the cursor.
- */
-static int
-skl_wm_plane_id(const struct intel_plane *plane)
-{
-	switch (plane->base.type) {
-	case DRM_PLANE_TYPE_PRIMARY:
-		return 0;
-	case DRM_PLANE_TYPE_CURSOR:
-		return PLANE_CURSOR;
-	case DRM_PLANE_TYPE_OVERLAY:
-		return plane->plane + 1;
-	default:
-		MISSING_CASE(plane->base.type);
-		return plane->plane;
-	}
-}
-
-/*
  * FIXME: We still don't have the proper code detect if we need to apply the WA,
  * so assume we'll always need it in order to avoid underruns.
  */
@@ -3026,7 +3004,6 @@ bool intel_can_enable_sagv(struct drm_atomic_state *state)
 	struct intel_crtc *crtc;
 	struct intel_plane *plane;
 	struct intel_crtc_state *cstate;
-	struct skl_plane_wm *wm;
 	enum pipe pipe;
 	int level, latency;
 
@@ -3053,7 +3030,8 @@ bool intel_can_enable_sagv(struct drm_atomic_state *state)
 		return false;
 
 	for_each_intel_plane_on_crtc(dev, crtc, plane) {
-		wm = &cstate->wm.skl.optimal.planes[skl_wm_plane_id(plane)];
+		struct skl_plane_wm *wm =
+			&cstate->wm.skl.optimal.planes[plane->id];
 
 		/* Skip this plane if it's not enabled */
 		if (!wm->wm[0].plane_en)
@@ -3156,28 +3134,29 @@ static void skl_ddb_entry_init_from_hw(struct skl_ddb_entry *entry, u32 reg)
 void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
 			  struct skl_ddb_allocation *ddb /* out */)
 {
-	enum pipe pipe;
-	int plane;
-	u32 val;
+	struct intel_crtc *crtc;
 
 	memset(ddb, 0, sizeof(*ddb));
 
-	for_each_pipe(dev_priv, pipe) {
+	for_each_intel_crtc(&dev_priv->drm, crtc) {
 		enum intel_display_power_domain power_domain;
+		enum plane_id plane_id;
+		enum pipe pipe = crtc->pipe;
 
 		power_domain = POWER_DOMAIN_PIPE(pipe);
 		if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
 			continue;
 
-		for_each_universal_plane(dev_priv, pipe, plane) {
-			val = I915_READ(PLANE_BUF_CFG(pipe, plane));
-			skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane],
-						   val);
-		}
+		for_each_plane_id_on_crtc(crtc, plane_id) {
+			u32 val;
+
+			if (plane_id != PLANE_CURSOR)
+				val = I915_READ(PLANE_BUF_CFG(pipe, plane_id));
+			else
+				val = I915_READ(CUR_BUF_CFG(pipe));
 
-		val = I915_READ(CUR_BUF_CFG(pipe));
-		skl_ddb_entry_init_from_hw(&ddb->plane[pipe][PLANE_CURSOR],
-					   val);
+			skl_ddb_entry_init_from_hw(&ddb->plane[pipe][plane_id], val);
+		}
 
 		intel_display_power_put(dev_priv, power_domain);
 	}
@@ -3278,30 +3257,28 @@ skl_get_total_relative_data_rate(struct intel_crtc_state *intel_cstate,
 	struct drm_crtc_state *cstate = &intel_cstate->base;
 	struct drm_atomic_state *state = cstate->state;
 	struct drm_plane *plane;
-	const struct intel_plane *intel_plane;
 	const struct drm_plane_state *pstate;
-	unsigned int rate, total_data_rate = 0;
-	int id;
+	unsigned int total_data_rate = 0;
 
 	if (WARN_ON(!state))
 		return 0;
 
 	/* Calculate and cache data rate for each plane */
 	drm_atomic_crtc_state_for_each_plane_state(plane, pstate, cstate) {
-		id = skl_wm_plane_id(to_intel_plane(plane));
-		intel_plane = to_intel_plane(plane);
+		enum plane_id plane_id = to_intel_plane(plane)->id;
+		unsigned int rate;
 
 		/* packed/uv */
 		rate = skl_plane_relative_data_rate(intel_cstate,
 						    pstate, 0);
-		plane_data_rate[id] = rate;
+		plane_data_rate[plane_id] = rate;
 
 		total_data_rate += rate;
 
 		/* y-plane */
 		rate = skl_plane_relative_data_rate(intel_cstate,
 						    pstate, 1);
-		plane_y_data_rate[id] = rate;
+		plane_y_data_rate[plane_id] = rate;
 
 		total_data_rate += rate;
 	}
@@ -3380,17 +3357,16 @@ skl_ddb_calc_min(const struct intel_crtc_state *cstate, int num_active,
 	struct drm_plane *plane;
 
 	drm_atomic_crtc_state_for_each_plane_state(plane, pstate, &cstate->base) {
-		struct intel_plane *intel_plane = to_intel_plane(plane);
-		int id = skl_wm_plane_id(intel_plane);
+		enum plane_id plane_id = to_intel_plane(plane)->id;
 
-		if (id == PLANE_CURSOR)
+		if (plane_id == PLANE_CURSOR)
 			continue;
 
 		if (!pstate->visible)
 			continue;
 
-		minimum[id] = skl_ddb_min_alloc(pstate, 0);
-		y_minimum[id] = skl_ddb_min_alloc(pstate, 1);
+		minimum[plane_id] = skl_ddb_min_alloc(pstate, 0);
+		y_minimum[plane_id] = skl_ddb_min_alloc(pstate, 1);
 	}
 
 	minimum[PLANE_CURSOR] = skl_cursor_allocation(num_active);
@@ -3410,8 +3386,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 	uint16_t minimum[I915_MAX_PLANES] = {};
 	uint16_t y_minimum[I915_MAX_PLANES] = {};
 	unsigned int total_data_rate;
+	enum plane_id plane_id;
 	int num_active;
-	int id, i;
 	unsigned plane_data_rate[I915_MAX_PLANES] = {};
 	unsigned plane_y_data_rate[I915_MAX_PLANES] = {};
 
@@ -3442,9 +3418,9 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 	 * proportional to the data rate.
 	 */
 
-	for (i = 0; i < I915_MAX_PLANES; i++) {
-		alloc_size -= minimum[i];
-		alloc_size -= y_minimum[i];
+	for_each_plane_id_on_crtc(intel_crtc, plane_id) {
+		alloc_size -= minimum[plane_id];
+		alloc_size -= y_minimum[plane_id];
 	}
 
 	ddb->plane[pipe][PLANE_CURSOR].start = alloc->end - minimum[PLANE_CURSOR];
@@ -3463,28 +3439,28 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 		return 0;
 
 	start = alloc->start;
-	for (id = 0; id < I915_MAX_PLANES; id++) {
+	for_each_plane_id_on_crtc(intel_crtc, plane_id) {
 		unsigned int data_rate, y_data_rate;
 		uint16_t plane_blocks, y_plane_blocks = 0;
 
-		if (id == PLANE_CURSOR)
+		if (plane_id == PLANE_CURSOR)
 			continue;
 
-		data_rate = plane_data_rate[id];
+		data_rate = plane_data_rate[plane_id];
 
 		/*
 		 * allocation for (packed formats) or (uv-plane part of planar format):
 		 * promote the expression to 64 bits to avoid overflowing, the
 		 * result is < available as data_rate / total_data_rate < 1
 		 */
-		plane_blocks = minimum[id];
+		plane_blocks = minimum[plane_id];
 		plane_blocks += div_u64((uint64_t)alloc_size * data_rate,
 					total_data_rate);
 
 		/* Leave disabled planes at (0,0) */
 		if (data_rate) {
-			ddb->plane[pipe][id].start = start;
-			ddb->plane[pipe][id].end = start + plane_blocks;
+			ddb->plane[pipe][plane_id].start = start;
+			ddb->plane[pipe][plane_id].end = start + plane_blocks;
 		}
 
 		start += plane_blocks;
@@ -3492,15 +3468,15 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 		/*
 		 * allocation for y_plane part of planar format:
 		 */
-		y_data_rate = plane_y_data_rate[id];
+		y_data_rate = plane_y_data_rate[plane_id];
 
-		y_plane_blocks = y_minimum[id];
+		y_plane_blocks = y_minimum[plane_id];
 		y_plane_blocks += div_u64((uint64_t)alloc_size * y_data_rate,
 					total_data_rate);
 
 		if (y_data_rate) {
-			ddb->y_plane[pipe][id].start = start;
-			ddb->y_plane[pipe][id].end = start + y_plane_blocks;
+			ddb->y_plane[pipe][plane_id].start = start;
+			ddb->y_plane[pipe][plane_id].end = start + y_plane_blocks;
 		}
 
 		start += y_plane_blocks;
@@ -3692,12 +3668,12 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 		if (level) {
 			return 0;
 		} else {
+			struct drm_plane *plane = pstate->plane;
+
 			DRM_DEBUG_KMS("Requested display configuration exceeds system watermark limitations\n");
-			DRM_DEBUG_KMS("Plane %d.%d: blocks required = %u/%u, lines required = %u/31\n",
-				      to_intel_crtc(cstate->base.crtc)->pipe,
-				      skl_wm_plane_id(to_intel_plane(pstate->plane)),
+			DRM_DEBUG_KMS("[PLANE:%d:%s] blocks required = %u/%u, lines required = %u/31\n",
+				      plane->base.id, plane->name,
 				      res_blocks, ddb_allocation, res_lines);
-
 			return -EINVAL;
 		}
 	}
@@ -3724,7 +3700,6 @@ skl_compute_wm_level(const struct drm_i915_private *dev_priv,
 	uint16_t ddb_blocks;
 	enum pipe pipe = intel_crtc->pipe;
 	int ret;
-	int i = skl_wm_plane_id(intel_plane);
 
 	if (state)
 		intel_pstate =
@@ -3747,7 +3722,7 @@ skl_compute_wm_level(const struct drm_i915_private *dev_priv,
 
 	WARN_ON(!intel_pstate->base.fb);
 
-	ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][i]);
+	ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][intel_plane->id]);
 
 	ret = skl_compute_plane_wm(dev_priv,
 				   cstate,
@@ -3810,7 +3785,7 @@ static int skl_build_pipe_wm(struct intel_crtc_state *cstate,
 	for_each_intel_plane_mask(&dev_priv->drm,
 				  intel_plane,
 				  cstate->base.plane_mask) {
-		wm = &pipe_wm->planes[skl_wm_plane_id(intel_plane)];
+		wm = &pipe_wm->planes[intel_plane->id];
 
 		for (level = 0; level <= max_level; level++) {
 			ret = skl_compute_wm_level(dev_priv, ddb, cstate,
@@ -3854,7 +3829,7 @@ static void skl_write_wm_level(struct drm_i915_private *dev_priv,
 void skl_write_plane_wm(struct intel_crtc *intel_crtc,
 			const struct skl_plane_wm *wm,
 			const struct skl_ddb_allocation *ddb,
-			int plane)
+			enum plane_id plane_id)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
 	struct drm_device *dev = crtc->dev;
@@ -3863,16 +3838,16 @@ void skl_write_plane_wm(struct intel_crtc *intel_crtc,
 	enum pipe pipe = intel_crtc->pipe;
 
 	for (level = 0; level <= max_level; level++) {
-		skl_write_wm_level(dev_priv, PLANE_WM(pipe, plane, level),
+		skl_write_wm_level(dev_priv, PLANE_WM(pipe, plane_id, level),
 				   &wm->wm[level]);
 	}
-	skl_write_wm_level(dev_priv, PLANE_WM_TRANS(pipe, plane),
+	skl_write_wm_level(dev_priv, PLANE_WM_TRANS(pipe, plane_id),
 			   &wm->trans_wm);
 
-	skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane),
-			    &ddb->plane[pipe][plane]);
-	skl_ddb_entry_write(dev_priv, PLANE_NV12_BUF_CFG(pipe, plane),
-			    &ddb->y_plane[pipe][plane]);
+	skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane_id),
+			    &ddb->plane[pipe][plane_id]);
+	skl_ddb_entry_write(dev_priv, PLANE_NV12_BUF_CFG(pipe, plane_id),
+			    &ddb->y_plane[pipe][plane_id]);
 }
 
 void skl_write_cursor_wm(struct intel_crtc *intel_crtc,
@@ -3977,17 +3952,16 @@ skl_ddb_add_affected_planes(struct intel_crtc_state *cstate)
 	struct drm_plane_state *plane_state;
 	struct drm_plane *plane;
 	enum pipe pipe = intel_crtc->pipe;
-	int id;
 
 	WARN_ON(!drm_atomic_get_existing_crtc_state(state, crtc));
 
 	drm_for_each_plane_mask(plane, dev, cstate->base.plane_mask) {
-		id = skl_wm_plane_id(to_intel_plane(plane));
+		enum plane_id plane_id = to_intel_plane(plane)->id;
 
-		if (skl_ddb_entry_equal(&cur_ddb->plane[pipe][id],
-					&new_ddb->plane[pipe][id]) &&
-		    skl_ddb_entry_equal(&cur_ddb->y_plane[pipe][id],
-					&new_ddb->y_plane[pipe][id]))
+		if (skl_ddb_entry_equal(&cur_ddb->plane[pipe][plane_id],
+					&new_ddb->plane[pipe][plane_id]) &&
+		    skl_ddb_entry_equal(&cur_ddb->y_plane[pipe][plane_id],
+					&new_ddb->y_plane[pipe][plane_id]))
 			continue;
 
 		plane_state = drm_atomic_get_plane_state(state, plane);
@@ -4099,7 +4073,6 @@ skl_print_wm_changes(const struct drm_atomic_state *state)
 	const struct intel_plane *intel_plane;
 	const struct skl_ddb_allocation *old_ddb = &dev_priv->wm.skl_hw.ddb;
 	const struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb;
-	int id;
 	int i;
 
 	for_each_crtc_in_state(state, crtc, cstate, i) {
@@ -4107,11 +4080,11 @@ skl_print_wm_changes(const struct drm_atomic_state *state)
 		enum pipe pipe = intel_crtc->pipe;
 
 		for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
+			enum plane_id plane_id = intel_plane->id;
 			const struct skl_ddb_entry *old, *new;
 
-			id = skl_wm_plane_id(intel_plane);
-			old = &old_ddb->plane[pipe][id];
-			new = &new_ddb->plane[pipe][id];
+			old = &old_ddb->plane[pipe][plane_id];
+			new = &new_ddb->plane[pipe][plane_id];
 
 			if (skl_ddb_entry_equal(old, new))
 				continue;
@@ -4201,17 +4174,21 @@ static void skl_atomic_update_crtc_wm(struct intel_atomic_state *state,
 	struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal;
 	const struct skl_ddb_allocation *ddb = &state->wm_results.ddb;
 	enum pipe pipe = crtc->pipe;
-	int plane;
+	enum plane_id plane_id;
 
 	if (!(state->wm_results.dirty_pipes & drm_crtc_mask(&crtc->base)))
 		return;
 
 	I915_WRITE(PIPE_WM_LINETIME(pipe), pipe_wm->linetime);
 
-	for_each_universal_plane(dev_priv, pipe, plane)
-		skl_write_plane_wm(crtc, &pipe_wm->planes[plane], ddb, plane);
-
-	skl_write_cursor_wm(crtc, &pipe_wm->planes[PLANE_CURSOR], ddb);
+	for_each_plane_id_on_crtc(crtc, plane_id) {
+		if (plane_id != PLANE_CURSOR)
+			skl_write_plane_wm(crtc, &pipe_wm->planes[plane_id],
+					   ddb, plane_id);
+		else
+			skl_write_cursor_wm(crtc, &pipe_wm->planes[plane_id],
+					    ddb);
+	}
 }
 
 static void skl_initial_wm(struct intel_atomic_state *state,
@@ -4326,32 +4303,29 @@ static inline void skl_wm_level_from_reg_val(uint32_t val,
 void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc,
 			      struct skl_pipe_wm *out)
 {
-	struct drm_device *dev = crtc->dev;
-	struct drm_i915_private *dev_priv = to_i915(dev);
+	struct drm_i915_private *dev_priv = to_i915(crtc->dev);
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct intel_plane *intel_plane;
-	struct skl_plane_wm *wm;
 	enum pipe pipe = intel_crtc->pipe;
-	int level, id, max_level;
+	int level, max_level;
+	enum plane_id plane_id;
 	uint32_t val;
 
 	max_level = ilk_wm_max_level(dev_priv);
 
-	for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
-		id = skl_wm_plane_id(intel_plane);
-		wm = &out->planes[id];
+	for_each_plane_id_on_crtc(intel_crtc, plane_id) {
+		struct skl_plane_wm *wm = &out->planes[plane_id];
 
 		for (level = 0; level <= max_level; level++) {
-			if (id != PLANE_CURSOR)
-				val = I915_READ(PLANE_WM(pipe, id, level));
+			if (plane_id != PLANE_CURSOR)
+				val = I915_READ(PLANE_WM(pipe, plane_id, level));
 			else
 				val = I915_READ(CUR_WM(pipe, level));
 
 			skl_wm_level_from_reg_val(val, &wm->wm[level]);
 		}
 
-		if (id != PLANE_CURSOR)
-			val = I915_READ(PLANE_WM_TRANS(pipe, id));
+		if (plane_id != PLANE_CURSOR)
+			val = I915_READ(PLANE_WM_TRANS(pipe, plane_id));
 		else
 			val = I915_READ(CUR_WM_TRANS(pipe));
 
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 3/9
#4 lore raw

Re: [PATCH 3/9] drm/i915: Use enum plane_id in SKL wm code

Looks good to me

Quoted 518 lines · On Tue, 2016-11-22 at 18:01 +0200, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Nuke skl_wm_plane_id() and just use the new intel_plane->id.

v2: Convert skl_write_plane_wm() as well
v3: Convert skl_pipe_wm_get_hw_state() correctly
v4: Rebase due to changes in the wm code
    Drop the cursor FIXME from the total data rate calc (Paulo) Use the "[PLANE:%d:%s]" format in debug print (Paulo)

Cc Matt Roper <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Maarten Lankhorst <[email protected]>

---
 drivers/gpu/drm/i915/intel_pm.c | 180 +++++++++++++++++-------------
----------

 1 file changed, 77 insertions(+), 103 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index bbb1eaf1e6db..e6351445016d 100644
@@ -2867,28 +2867,6 @@ bool ilk_disable_lp_wm(struct drm_device *dev)
  #define SKL_SAGV_BLOCK_TIME	30 /* µs */


 /*
- * Return the index of a plane in the SKL DDB and wm result arrays.  Primary
- * plane is always in slot 0, cursor is always in slot I915_MAX_PLANES-1, and
- * other universal planes are in indices 1..n.  Note that this may leave unused
- * indices between the top "sprite" plane and the cursor.
- */

drivers/gpu/drm/i915/intel_pm.c +0 -17
-static int
-skl_wm_plane_id(const struct intel_plane *plane)
-{
-	switch (plane->base.type) {
-	case DRM_PLANE_TYPE_PRIMARY:
-		return 0;
-	case DRM_PLANE_TYPE_CURSOR:
-		return PLANE_CURSOR;
-	case DRM_PLANE_TYPE_OVERLAY:
-		return plane->plane + 1;
-	default:
-		MISSING_CASE(plane->base.type);
-		return plane->plane;
-	}
-}
-
-/*

  * FIXME: We still don't have the proper code detect if we need to apply the WA,
  * so assume we'll always need it in order to avoid underruns. */

drivers/gpu/drm/i915/intel_pm.c +0 -1
@@ -3026,7 +3004,6 @@ bool intel_can_enable_sagv(struct
 drm_atomic_state *state)
  	struct intel_crtc *crtc;
  	struct intel_plane *plane;
  	struct intel_crtc_state *cstate;
-	struct skl_plane_wm *wm;
  	enum pipe pipe;
  	int level, latency;

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -3053,7 +3030,8 @@ bool intel_can_enable_sagv(struct
 drm_atomic_state *state)
  		return false;


  for_each_intel_plane_on_crtc(dev, crtc, plane) {

drivers/gpu/drm/i915/intel_pm.c +0 -1
-		wm = &cstate-
Quoted 1 line

wm.skl.optimal.planes[skl_wm_plane_id(plane)];

drivers/gpu/drm/i915/intel_pm.c +2 -0
+		struct skl_plane_wm *wm =
+			&cstate->wm.skl.optimal.planes[plane->id];


  /* Skip this plane if it's not enabled */ if (!wm->wm[0].plane_en)

drivers/gpu/drm/i915/intel_pm.c +1 -3
@@ -3156,28 +3134,29 @@ static void skl_ddb_entry_init_from_hw(struct
 skl_ddb_entry *entry, u32 reg)
  void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  			  struct skl_ddb_allocation *ddb /* out */)
  {
-	enum pipe pipe;
-	int plane;
-	u32 val;
+	struct intel_crtc *crtc;


  memset(ddb, 0, sizeof(*ddb));

drivers/gpu/drm/i915/intel_pm.c +1 -1
-	for_each_pipe(dev_priv, pipe) {
+	for_each_intel_crtc(&dev_priv->drm, crtc) {

  enum intel_display_power_domain power_domain;

drivers/gpu/drm/i915/intel_pm.c +2 -0
+		enum plane_id plane_id;
+		enum pipe pipe = crtc->pipe;


  power_domain = POWER_DOMAIN_PIPE(pipe); if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
  continue;

drivers/gpu/drm/i915/intel_pm.c +0 -3
-		for_each_universal_plane(dev_priv, pipe, plane) {
-			val = I915_READ(PLANE_BUF_CFG(pipe, plane));
-			skl_ddb_entry_init_from_hw(&ddb-
Quoted 1 line

plane[pipe][plane],

drivers/gpu/drm/i915/intel_pm.c +5 -2
-						   val);
-		}
+		for_each_plane_id_on_crtc(crtc, plane_id) {
+			u32 val;
+
+			if (plane_id != PLANE_CURSOR)
+				val = I915_READ(PLANE_BUF_CFG(pipe,

plane_id));

drivers/gpu/drm/i915/intel_pm.c +2 -0
+			else
+				val = I915_READ(CUR_BUF_CFG(pipe));

drivers/gpu/drm/i915/intel_pm.c +0 -2
-		val = I915_READ(CUR_BUF_CFG(pipe));
-		skl_ddb_entry_init_from_hw(&ddb-
Quoted 1 line

plane[pipe][PLANE_CURSOR],

drivers/gpu/drm/i915/intel_pm.c +1 -1
-					   val);
+			skl_ddb_entry_init_from_hw(&ddb-
Quoted 1 line

plane[pipe][plane_id], val);

drivers/gpu/drm/i915/intel_pm.c +1 -0
+		}


  intel_display_power_put(dev_priv, power_domain); }

drivers/gpu/drm/i915/intel_pm.c +1 -3
@@ -3278,30 +3257,28 @@ skl_get_total_relative_data_rate(struct
 intel_crtc_state *intel_cstate,
  	struct drm_crtc_state *cstate = &intel_cstate->base;
  	struct drm_atomic_state *state = cstate->state;
  	struct drm_plane *plane;
-	const struct intel_plane *intel_plane;
  	const struct drm_plane_state *pstate;
-	unsigned int rate, total_data_rate = 0;
-	int id;
+	unsigned int total_data_rate = 0;


  if (WARN_ON(!state))
  return 0;

  /* Calculate and cache data rate for each plane */ drm_atomic_crtc_state_for_each_plane_state(plane, pstate, cstate) {

drivers/gpu/drm/i915/intel_pm.c +2 -2
-		id = skl_wm_plane_id(to_intel_plane(plane));
-		intel_plane = to_intel_plane(plane);
+		enum plane_id plane_id = to_intel_plane(plane)->id;
+		unsigned int rate;


  /* packed/uv */
  rate = skl_plane_relative_data_rate(intel_cstate, pstate, 0);

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		plane_data_rate[id] = rate;
+		plane_data_rate[plane_id] = rate;


  total_data_rate += rate;

  /* y-plane */
  rate = skl_plane_relative_data_rate(intel_cstate, pstate, 1);

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		plane_y_data_rate[id] = rate;
+		plane_y_data_rate[plane_id] = rate;


  total_data_rate += rate;
  }

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -3380,17 +3357,16 @@ skl_ddb_calc_min(const struct
 intel_crtc_state *cstate, int num_active,
  	struct drm_plane *plane;


  drm_atomic_crtc_state_for_each_plane_state(plane, pstate, &cstate->base) {

drivers/gpu/drm/i915/intel_pm.c +0 -1
-		struct intel_plane *intel_plane =

to_intel_plane(plane);

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		int id = skl_wm_plane_id(intel_plane);
+		enum plane_id plane_id = to_intel_plane(plane)->id;

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		if (id == PLANE_CURSOR)
+		if (plane_id == PLANE_CURSOR)

  continue;

  if (!pstate->visible)
  continue;

drivers/gpu/drm/i915/intel_pm.c +2 -2
-		minimum[id] = skl_ddb_min_alloc(pstate, 0);
-		y_minimum[id] = skl_ddb_min_alloc(pstate, 1);
+		minimum[plane_id] = skl_ddb_min_alloc(pstate, 0);
+		y_minimum[plane_id] = skl_ddb_min_alloc(pstate, 1);

  }

  minimum[PLANE_CURSOR] = skl_cursor_allocation(num_active);

drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -3410,8 +3386,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state
 *cstate,
  	uint16_t minimum[I915_MAX_PLANES] = {};
  	uint16_t y_minimum[I915_MAX_PLANES] = {};
  	unsigned int total_data_rate;
+	enum plane_id plane_id;
  	int num_active;
-	int id, i;
  	unsigned plane_data_rate[I915_MAX_PLANES] = {};
  	unsigned plane_y_data_rate[I915_MAX_PLANES] = {};

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -3442,9 +3418,9 @@ skl_allocate_pipe_ddb(struct intel_crtc_state
 *cstate,
  	 * proportional to the data rate.
  	 */

drivers/gpu/drm/i915/intel_pm.c +3 -3
-	for (i = 0; i < I915_MAX_PLANES; i++) {
-		alloc_size -= minimum[i];
-		alloc_size -= y_minimum[i];
+	for_each_plane_id_on_crtc(intel_crtc, plane_id) {
+		alloc_size -= minimum[plane_id];
+		alloc_size -= y_minimum[plane_id];

  }

  ddb->plane[pipe][PLANE_CURSOR].start = alloc->end - minimum[PLANE_CURSOR];

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -3463,28 +3439,28 @@ skl_allocate_pipe_ddb(struct intel_crtc_state
 *cstate,
  		return 0;


  start = alloc->start;

drivers/gpu/drm/i915/intel_pm.c +1 -1
-	for (id = 0; id < I915_MAX_PLANES; id++) {
+	for_each_plane_id_on_crtc(intel_crtc, plane_id) {

  unsigned int data_rate, y_data_rate; uint16_t plane_blocks, y_plane_blocks = 0;

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		if (id == PLANE_CURSOR)
+		if (plane_id == PLANE_CURSOR)

  continue;

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		data_rate = plane_data_rate[id];
+		data_rate = plane_data_rate[plane_id];


  /*
   * allocation for (packed formats) or (uv-plane part of planar format):
   * promote the expression to 64 bits to avoid overflowing, the
   * result is < available as data_rate / total_data_rate < 1
   */

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		plane_blocks = minimum[id];
+		plane_blocks = minimum[plane_id];

  plane_blocks += div_u64((uint64_t)alloc_size * data_rate,
  total_data_rate);
  /* Leave disabled planes at (0,0) */ if (data_rate) {

drivers/gpu/drm/i915/intel_pm.c +0 -2
-			ddb->plane[pipe][id].start = start;
-			ddb->plane[pipe][id].end = start +

plane_blocks;

drivers/gpu/drm/i915/intel_pm.c +2 -0
+			ddb->plane[pipe][plane_id].start = start;
+			ddb->plane[pipe][plane_id].end = start +

plane_blocks;
  }

  start += plane_blocks;

drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -3492,15 +3468,15 @@ skl_allocate_pipe_ddb(struct intel_crtc_state
 *cstate,
  		/*
  		 * allocation for y_plane part of planar format:
  		 */
-		y_data_rate = plane_y_data_rate[id];
+		y_data_rate = plane_y_data_rate[plane_id];

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		y_plane_blocks = y_minimum[id];
+		y_plane_blocks = y_minimum[plane_id];

  y_plane_blocks += div_u64((uint64_t)alloc_size * y_data_rate,
  total_data_rate);
  if (y_data_rate) {

drivers/gpu/drm/i915/intel_pm.c +0 -2
-			ddb->y_plane[pipe][id].start = start;
-			ddb->y_plane[pipe][id].end = start +

y_plane_blocks;

drivers/gpu/drm/i915/intel_pm.c +2 -0
+			ddb->y_plane[pipe][plane_id].start = start;
+			ddb->y_plane[pipe][plane_id].end = start +

y_plane_blocks;
  }

  start += y_plane_blocks;

drivers/gpu/drm/i915/intel_pm.c +2 -0
@@ -3692,12 +3668,12 @@ static int skl_compute_plane_wm(const struct
 drm_i915_private *dev_priv,
  		if (level) {
  			return 0;
  		} else {
+			struct drm_plane *plane = pstate->plane;
+

  DRM_DEBUG_KMS("Requested display configuration exceeds system watermark limitations\n");

drivers/gpu/drm/i915/intel_pm.c +0 -1
-			DRM_DEBUG_KMS("Plane %d.%d: blocks required

= %u/%u, lines required = %u/31\n",

drivers/gpu/drm/i915/intel_pm.c +0 -1
-				      to_intel_crtc(cstate-
Quoted 1 line

base.crtc)->pipe,

drivers/gpu/drm/i915/intel_pm.c +0 -1
-				      skl_wm_plane_id(to_intel_plane

(pstate->plane)),

drivers/gpu/drm/i915/intel_pm.c +1 -0
+			DRM_DEBUG_KMS("[PLANE:%d:%s] blocks required

= %u/%u, lines required = %u/31\n",

drivers/gpu/drm/i915/intel_pm.c +1 -0
+				      plane->base.id, plane->name,

        res_blocks, ddb_allocation, res_lines);
-
  return -EINVAL;
  }
  }

drivers/gpu/drm/i915/intel_pm.c +0 -1
@@ -3724,7 +3700,6 @@ skl_compute_wm_level(const struct
 drm_i915_private *dev_priv,
  	uint16_t ddb_blocks;
  	enum pipe pipe = intel_crtc->pipe;
  	int ret;
-	int i = skl_wm_plane_id(intel_plane);


  if (state)
  intel_pstate =

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -3747,7 +3722,7 @@ skl_compute_wm_level(const struct
 drm_i915_private *dev_priv,


  WARN_ON(!intel_pstate->base.fb);

drivers/gpu/drm/i915/intel_pm.c +1 -1
-	ddb_blocks = skl_ddb_entry_size(&ddb->plane[pipe][i]);
+	ddb_blocks = skl_ddb_entry_size(&ddb-
Quoted 1 line

plane[pipe][intel_plane->id]);


  ret = skl_compute_plane_wm(dev_priv,
     cstate,

drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -3810,7 +3785,7 @@ static int skl_build_pipe_wm(struct
 intel_crtc_state *cstate,
  	for_each_intel_plane_mask(&dev_priv->drm,
  				  intel_plane,
  				  cstate->base.plane_mask) {
-		wm = &pipe_wm->planes[skl_wm_plane_id(intel_plane)];
+		wm = &pipe_wm->planes[intel_plane->id];


  for (level = 0; level <= max_level; level++) { ret = skl_compute_wm_level(dev_priv, ddb, cstate,

drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -3854,7 +3829,7 @@ static void skl_write_wm_level(struct
 drm_i915_private *dev_priv,
  void skl_write_plane_wm(struct intel_crtc *intel_crtc,
  			const struct skl_plane_wm *wm,
  			const struct skl_ddb_allocation *ddb,
-			int plane)
+			enum plane_id plane_id)
  {
  	struct drm_crtc *crtc = &intel_crtc->base;

  struct drm_device *dev = crtc->dev;

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -3863,16 +3838,16 @@ void skl_write_plane_wm(struct intel_crtc
 *intel_crtc,
  	enum pipe pipe = intel_crtc->pipe;


  for (level = 0; level <= max_level; level++) {

drivers/gpu/drm/i915/intel_pm.c +0 -1
-		skl_write_wm_level(dev_priv, PLANE_WM(pipe, plane,

level),

drivers/gpu/drm/i915/intel_pm.c +1 -0
+		skl_write_wm_level(dev_priv, PLANE_WM(pipe,

plane_id, level),
     &wm->wm[level]); }

drivers/gpu/drm/i915/intel_pm.c +1 -1
-	skl_write_wm_level(dev_priv, PLANE_WM_TRANS(pipe, plane),
+	skl_write_wm_level(dev_priv, PLANE_WM_TRANS(pipe, plane_id),

     &wm->trans_wm);

drivers/gpu/drm/i915/intel_pm.c +0 -3
-	skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane),
-			    &ddb->plane[pipe][plane]);
-	skl_ddb_entry_write(dev_priv, PLANE_NV12_BUF_CFG(pipe,

plane),

drivers/gpu/drm/i915/intel_pm.c +3 -1
-			    &ddb->y_plane[pipe][plane]);
+	skl_ddb_entry_write(dev_priv, PLANE_BUF_CFG(pipe, plane_id),
+			    &ddb->plane[pipe][plane_id]);
+	skl_ddb_entry_write(dev_priv, PLANE_NV12_BUF_CFG(pipe,

plane_id),

drivers/gpu/drm/i915/intel_pm.c +1 -0
+			    &ddb->y_plane[pipe][plane_id]);

 }

 void skl_write_cursor_wm(struct intel_crtc *intel_crtc,

drivers/gpu/drm/i915/intel_pm.c +0 -1
@@ -3977,17 +3952,16 @@ skl_ddb_add_affected_planes(struct
 intel_crtc_state *cstate)
  	struct drm_plane_state *plane_state;
  	struct drm_plane *plane;
  	enum pipe pipe = intel_crtc->pipe;
-	int id;


  WARN_ON(!drm_atomic_get_existing_crtc_state(state, crtc));
  drm_for_each_plane_mask(plane, dev, cstate->base.plane_mask) {

drivers/gpu/drm/i915/intel_pm.c +1 -1
-		id = skl_wm_plane_id(to_intel_plane(plane));
+		enum plane_id plane_id = to_intel_plane(plane)->id;

drivers/gpu/drm/i915/intel_pm.c +0 -2
-		if (skl_ddb_entry_equal(&cur_ddb->plane[pipe][id],
-					&new_ddb->plane[pipe][id])

&&

drivers/gpu/drm/i915/intel_pm.c +0 -2
-		    skl_ddb_entry_equal(&cur_ddb->y_plane[pipe][id],
-					&new_ddb-
Quoted 1 line

y_plane[pipe][id]))

drivers/gpu/drm/i915/intel_pm.c +1 -0
+		if (skl_ddb_entry_equal(&cur_ddb-
Quoted 1 line

plane[pipe][plane_id],

drivers/gpu/drm/i915/intel_pm.c +1 -0
+					&new_ddb-
Quoted 1 line

plane[pipe][plane_id]) &&

drivers/gpu/drm/i915/intel_pm.c +1 -0
+		    skl_ddb_entry_equal(&cur_ddb-
Quoted 1 line

y_plane[pipe][plane_id],

drivers/gpu/drm/i915/intel_pm.c +1 -0
+					&new_ddb-
Quoted 1 line

y_plane[pipe][plane_id]))

  continue;

  plane_state = drm_atomic_get_plane_state(state, plane);

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4099,7 +4073,6 @@ skl_print_wm_changes(const struct
 drm_atomic_state *state)
  	const struct intel_plane *intel_plane;

  const struct skl_ddb_allocation *old_ddb = &dev_priv-

Quoted 1 line

wm.skl_hw.ddb;

  const struct skl_ddb_allocation *new_ddb = &intel_state-

Quoted 1 line

wm_results.ddb;

drivers/gpu/drm/i915/intel_pm.c +0 -1
-	int id;

  int i;

  for_each_crtc_in_state(state, crtc, cstate, i) {

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4107,11 +4080,11 @@ skl_print_wm_changes(const struct
 drm_atomic_state *state)
  		enum pipe pipe = intel_crtc->pipe;


  for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {

drivers/gpu/drm/i915/intel_pm.c +1 -0
+			enum plane_id plane_id = intel_plane->id;

  const struct skl_ddb_entry *old, *new;

drivers/gpu/drm/i915/intel_pm.c +2 -3
-			id = skl_wm_plane_id(intel_plane);
-			old = &old_ddb->plane[pipe][id];
-			new = &new_ddb->plane[pipe][id];
+			old = &old_ddb->plane[pipe][plane_id];
+			new = &new_ddb->plane[pipe][plane_id];


  if (skl_ddb_entry_equal(old, new)) continue;

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4201,17 +4174,21 @@ static void skl_atomic_update_crtc_wm(struct
 intel_atomic_state *state,
  	struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal;

  const struct skl_ddb_allocation *ddb = &state-

Quoted 1 line

wm_results.ddb;

  enum pipe pipe = crtc->pipe;

drivers/gpu/drm/i915/intel_pm.c +1 -1
-	int plane;
+	enum plane_id plane_id;


  if (!(state->wm_results.dirty_pipes & drm_crtc_mask(&crtc-

Quoted 1 line

base)))

  return;

  I915_WRITE(PIPE_WM_LINETIME(pipe), pipe_wm->linetime);

drivers/gpu/drm/i915/intel_pm.c +0 -2
-	for_each_universal_plane(dev_priv, pipe, plane)
-		skl_write_plane_wm(crtc, &pipe_wm->planes[plane],

ddb, plane);

drivers/gpu/drm/i915/intel_pm.c +0 -2
-
-	skl_write_cursor_wm(crtc, &pipe_wm->planes[PLANE_CURSOR],

ddb);

drivers/gpu/drm/i915/intel_pm.c +3 -0
+	for_each_plane_id_on_crtc(crtc, plane_id) {
+		if (plane_id != PLANE_CURSOR)
+			skl_write_plane_wm(crtc, &pipe_wm-
Quoted 1 line

planes[plane_id],

drivers/gpu/drm/i915/intel_pm.c +3 -0
+					   ddb, plane_id);
+		else
+			skl_write_cursor_wm(crtc, &pipe_wm-
Quoted 1 line

planes[plane_id],

drivers/gpu/drm/i915/intel_pm.c +2 -0
+					    ddb);
+	}

 }

 static void skl_initial_wm(struct intel_atomic_state *state,

drivers/gpu/drm/i915/intel_pm.c +3 -5
@@ -4326,32 +4303,29 @@ static inline void
 skl_wm_level_from_reg_val(uint32_t val,
  void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc,
  			      struct skl_pipe_wm *out)
  {
-	struct drm_device *dev = crtc->dev;
-	struct drm_i915_private *dev_priv = to_i915(dev);
+	struct drm_i915_private *dev_priv = to_i915(crtc->dev);
  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct intel_plane *intel_plane;
-	struct skl_plane_wm *wm;
  	enum pipe pipe = intel_crtc->pipe;
-	int level, id, max_level;
+	int level, max_level;
+	enum plane_id plane_id;
  	uint32_t val;


  max_level = ilk_wm_max_level(dev_priv);

drivers/gpu/drm/i915/intel_pm.c +2 -3
-	for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
-		id = skl_wm_plane_id(intel_plane);
-		wm = &out->planes[id];
+	for_each_plane_id_on_crtc(intel_crtc, plane_id) {
+		struct skl_plane_wm *wm = &out->planes[plane_id];


  for (level = 0; level <= max_level; level++) {

drivers/gpu/drm/i915/intel_pm.c +0 -2
-			if (id != PLANE_CURSOR)
-				val = I915_READ(PLANE_WM(pipe, id,

level));

drivers/gpu/drm/i915/intel_pm.c +2 -0
+			if (plane_id != PLANE_CURSOR)
+				val = I915_READ(PLANE_WM(pipe,

plane_id, level));
  else
  val = I915_READ(CUR_WM(pipe, level));

  skl_wm_level_from_reg_val(val, &wm-

Quoted 1 line

wm[level]);

  }

drivers/gpu/drm/i915/intel_pm.c +2 -2
-		if (id != PLANE_CURSOR)
-			val = I915_READ(PLANE_WM_TRANS(pipe, id));
+		if (plane_id != PLANE_CURSOR)
+			val = I915_READ(PLANE_WM_TRANS(pipe,

plane_id));
  else
  val = I915_READ(CUR_WM_TRANS(pipe));

Signature · 6 lines
Cheers,
	Lyude
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH v2 4/9 drm/i915: Use enum plane_id in SKL plane code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Replace the intel_plane->plane and hardcoded 0 usage in the SKL plane code with intel_plane->id.

This should make the SKL "primary" and "sprite" code virtually identical, so the next logical step would likely be dropping one of the copies.

---
 drivers/gpu/drm/i915/intel_display.c | 31 +++++++++++++-------------
 drivers/gpu/drm/i915/intel_sprite.c  | 42 ++++++++++++++++++------------------
 2 files changed, 37 insertions(+), 36 deletions(-)
drivers/gpu/drm/i915/intel_display.c +16 -15
index 6c3032f04d54..0a98989b8663 100644
@@ -3378,7 +3378,8 @@ static void skylake_update_primary_plane(struct drm_plane *plane,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc);
 	struct drm_framebuffer *fb = plane_state->base.fb;
-	int pipe = intel_crtc->pipe;
+	enum plane_id plane_id = to_intel_plane(plane)->id;
+	enum pipe pipe = to_intel_plane(plane)->pipe;
 	u32 plane_ctl;
 	unsigned int rotation = plane_state->base.rotation;
 	u32 stride = skl_plane_stride(fb, 0, rotation);
@@ -3413,30 +3414,30 @@ static void skylake_update_primary_plane(struct drm_plane *plane,
 	intel_crtc->adjusted_x = src_x;
 	intel_crtc->adjusted_y = src_y;
 
-	I915_WRITE(PLANE_CTL(pipe, 0), plane_ctl);
-	I915_WRITE(PLANE_OFFSET(pipe, 0), (src_y << 16) | src_x);
-	I915_WRITE(PLANE_STRIDE(pipe, 0), stride);
-	I915_WRITE(PLANE_SIZE(pipe, 0), (src_h << 16) | src_w);
+	I915_WRITE(PLANE_CTL(pipe, plane_id), plane_ctl);
+	I915_WRITE(PLANE_OFFSET(pipe, plane_id), (src_y << 16) | src_x);
+	I915_WRITE(PLANE_STRIDE(pipe, plane_id), stride);
+	I915_WRITE(PLANE_SIZE(pipe, plane_id), (src_h << 16) | src_w);
 
 	if (scaler_id >= 0) {
 		uint32_t ps_ctrl = 0;
 
 		WARN_ON(!dst_w || !dst_h);
-		ps_ctrl = PS_SCALER_EN | PS_PLANE_SEL(0) |
+		ps_ctrl = PS_SCALER_EN | PS_PLANE_SEL(plane_id) |
 			crtc_state->scaler_state.scalers[scaler_id].mode;
 		I915_WRITE(SKL_PS_CTRL(pipe, scaler_id), ps_ctrl);
 		I915_WRITE(SKL_PS_PWR_GATE(pipe, scaler_id), 0);
 		I915_WRITE(SKL_PS_WIN_POS(pipe, scaler_id), (dst_x << 16) | dst_y);
 		I915_WRITE(SKL_PS_WIN_SZ(pipe, scaler_id), (dst_w << 16) | dst_h);
-		I915_WRITE(PLANE_POS(pipe, 0), 0);
+		I915_WRITE(PLANE_POS(pipe, plane_id), 0);
 	} else {
-		I915_WRITE(PLANE_POS(pipe, 0), (dst_y << 16) | dst_x);
+		I915_WRITE(PLANE_POS(pipe, plane_id), (dst_y << 16) | dst_x);
 	}
 
-	I915_WRITE(PLANE_SURF(pipe, 0),
+	I915_WRITE(PLANE_SURF(pipe, plane_id),
 		   intel_fb_gtt_offset(fb, rotation) + surf_addr);
 
-	POSTING_READ(PLANE_SURF(pipe, 0));
+	POSTING_READ(PLANE_SURF(pipe, plane_id));
 }
 
 static void skylake_disable_primary_plane(struct drm_plane *primary,
@@ -3444,12 +3445,12 @@ static void skylake_disable_primary_plane(struct drm_plane *primary,
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	int pipe = intel_crtc->pipe;
+	enum plane_id plane_id = to_intel_plane(primary)->id;
+	enum pipe pipe = to_intel_plane(primary)->pipe;
 
-	I915_WRITE(PLANE_CTL(pipe, 0), 0);
-	I915_WRITE(PLANE_SURF(pipe, 0), 0);
-	POSTING_READ(PLANE_SURF(pipe, 0));
+	I915_WRITE(PLANE_CTL(pipe, plane_id), 0);
+	I915_WRITE(PLANE_SURF(pipe, plane_id), 0);
+	POSTING_READ(PLANE_SURF(pipe, plane_id));
 }
 
 /* Assume fb object is pinned & idle & fenced and just update base pointers */
drivers/gpu/drm/i915/intel_sprite.c +21 -21

87 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

PATCH v2 5/9 drm/i915: Use enum plane_id in VLV/CHV sprite code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Use intel_plane->id to derive the VLV/CHV sprite register offsets instead of abusing plane->plane which is really meant to for primary planes only.

v2: Convert assert_sprites_disabled() over as well
v3: Rename the reg macro parameter to 'plane_id' as well (Paulo)

---
 drivers/gpu/drm/i915/i915_reg.h      | 58 +++++++++++++++-------------
 drivers/gpu/drm/i915/intel_display.c |  2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 74 ++++++++++++++++++------------------
 3 files changed, 70 insertions(+), 64 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +32 -26
index c70c07a7b586..d03491089f9c 100644
@@ -5374,18 +5374,21 @@ enum {
 #define _SPBCONSTALPHA		(VLV_DISPLAY_BASE + 0x722a8)
 #define _SPBGAMC		(VLV_DISPLAY_BASE + 0x722f4)
 
-#define SPCNTR(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPACNTR, _SPBCNTR)
-#define SPLINOFF(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPALINOFF, _SPBLINOFF)
-#define SPSTRIDE(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPASTRIDE, _SPBSTRIDE)
-#define SPPOS(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPAPOS, _SPBPOS)
-#define SPSIZE(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPASIZE, _SPBSIZE)
-#define SPKEYMINVAL(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPAKEYMINVAL, _SPBKEYMINVAL)
-#define SPKEYMSK(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPAKEYMSK, _SPBKEYMSK)
-#define SPSURF(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPASURF, _SPBSURF)
-#define SPKEYMAXVAL(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPAKEYMAXVAL, _SPBKEYMAXVAL)
-#define SPTILEOFF(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPATILEOFF, _SPBTILEOFF)
-#define SPCONSTALPHA(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPACONSTALPHA, _SPBCONSTALPHA)
-#define SPGAMC(pipe, plane) _MMIO_PIPE((pipe) * 2 + (plane), _SPAGAMC, _SPBGAMC)
+#define _MMIO_VLV_SPR(pipe, plane_id, reg_a, reg_b) \
+	_MMIO_PIPE((pipe) * 2 + (plane_id) - PLANE_SPRITE0, (reg_a), (reg_b))
+
+#define SPCNTR(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPACNTR, _SPBCNTR)
+#define SPLINOFF(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPALINOFF, _SPBLINOFF)
+#define SPSTRIDE(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPASTRIDE, _SPBSTRIDE)
+#define SPPOS(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPAPOS, _SPBPOS)
+#define SPSIZE(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPASIZE, _SPBSIZE)
+#define SPKEYMINVAL(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMINVAL, _SPBKEYMINVAL)
+#define SPKEYMSK(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMSK, _SPBKEYMSK)
+#define SPSURF(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPASURF, _SPBSURF)
+#define SPKEYMAXVAL(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMAXVAL, _SPBKEYMAXVAL)
+#define SPTILEOFF(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPATILEOFF, _SPBTILEOFF)
+#define SPCONSTALPHA(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPACONSTALPHA, _SPBCONSTALPHA)
+#define SPGAMC(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPAGAMC, _SPBGAMC)
 
 /*
  * CHV pipe B sprite CSC
@@ -5394,29 +5397,32 @@ enum {
  * |yg| = |c3 c4 c5| x |yg + yg_ioff| + |yg_ooff|
  * |cb|   |c6 c7 c8|   |cb + cr_ioff|   |cb_ooff|
  */
-#define SPCSCYGOFF(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d900 + (sprite) * 0x1000)
-#define SPCSCCBOFF(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d904 + (sprite) * 0x1000)
-#define SPCSCCROFF(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d908 + (sprite) * 0x1000)
+#define _MMIO_CHV_SPCSC(plane_id, reg) \
+	_MMIO(VLV_DISPLAY_BASE + ((plane_id) - PLANE_SPRITE0) * 0x1000 + (reg))
+
+#define SPCSCYGOFF(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d900)
+#define SPCSCCBOFF(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d904)
+#define SPCSCCROFF(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d908)
 #define  SPCSC_OOFF(x)		(((x) & 0x7ff) << 16) /* s11 */
 #define  SPCSC_IOFF(x)		(((x) & 0x7ff) << 0) /* s11 */
 
-#define SPCSCC01(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d90c + (sprite) * 0x1000)
-#define SPCSCC23(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d910 + (sprite) * 0x1000)
-#define SPCSCC45(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d914 + (sprite) * 0x1000)
-#define SPCSCC67(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d918 + (sprite) * 0x1000)
-#define SPCSCC8(sprite)		_MMIO(VLV_DISPLAY_BASE + 0x6d91c + (sprite) * 0x1000)
+#define SPCSCC01(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d90c)
+#define SPCSCC23(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d910)
+#define SPCSCC45(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d914)
+#define SPCSCC67(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d918)
+#define SPCSCC8(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d91c)
 #define  SPCSC_C1(x)		(((x) & 0x7fff) << 16) /* s3.12 */
 #define  SPCSC_C0(x)		(((x) & 0x7fff) << 0) /* s3.12 */
 
-#define SPCSCYGICLAMP(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d920 + (sprite) * 0x1000)
-#define SPCSCCBICLAMP(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d924 + (sprite) * 0x1000)
-#define SPCSCCRICLAMP(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d928 + (sprite) * 0x1000)
+#define SPCSCYGICLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d920)
+#define SPCSCCBICLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d924)
+#define SPCSCCRICLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d928)
 #define  SPCSC_IMAX(x)		(((x) & 0x7ff) << 16) /* s11 */
 #define  SPCSC_IMIN(x)		(((x) & 0x7ff) << 0) /* s11 */
 
-#define SPCSCYGOCLAMP(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d92c + (sprite) * 0x1000)
-#define SPCSCCBOCLAMP(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d930 + (sprite) * 0x1000)
-#define SPCSCCROCLAMP(sprite)	_MMIO(VLV_DISPLAY_BASE + 0x6d934 + (sprite) * 0x1000)
+#define SPCSCYGOCLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d92c)
+#define SPCSCCBOCLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d930)
+#define SPCSCCROCLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d934)
 #define  SPCSC_OMAX(x)		((x) << 16) /* u10 */
 #define  SPCSC_OMIN(x)		((x) << 0) /* u10 */
 
drivers/gpu/drm/i915/intel_display.c +1 -1
index 0a98989b8663..b6d5d5e5cc99 100644
@@ -1327,7 +1327,7 @@ static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
 		}
 	} else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
 		for_each_sprite(dev_priv, pipe, sprite) {
-			u32 val = I915_READ(SPCNTR(pipe, sprite));
+			u32 val = I915_READ(SPCNTR(pipe, PLANE_SPRITE0 + sprite));
 			I915_STATE_WARN(val & SP_ENABLE,
 			     "sprite %c assertion failure, should be off on pipe %c but is still active\n",
 			     sprite_name(pipe, sprite), pipe_name(pipe));
drivers/gpu/drm/i915/intel_sprite.c +37 -37

118 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH v2 6/9 drm/i915: Use enum plane_id in VLV/CHV wm code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Let's try not to abuse plane->plane for sprites on VLV/CHV and instead use plane->id. Since out watermark structures aren't entirely plane type agnostic (for now) and start indexing sprites from 0 we'll add a small helper to convert between the two bases.

---
 drivers/gpu/drm/i915/intel_pm.c | 73 ++++++++++++++++++++---------------------
 1 file changed, 36 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +36 -37
index e6351445016d..2b4bdb3abb10 100644
@@ -370,12 +370,15 @@ static const int pessimal_latency_ns = 5000;
 #define VLV_FIFO_START(dsparb, dsparb2, lo_shift, hi_shift) \
 	((((dsparb) >> (lo_shift)) & 0xff) | ((((dsparb2) >> (hi_shift)) & 0x1) << 8))
 
-static int vlv_get_fifo_size(struct drm_i915_private *dev_priv,
-			      enum pipe pipe, int plane)
+static int vlv_get_fifo_size(struct intel_plane *plane)
 {
+	struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
 	int sprite0_start, sprite1_start, size;
 
-	switch (pipe) {
+	if (plane->id == PLANE_CURSOR)
+		return 63;
+
+	switch (plane->pipe) {
 		uint32_t dsparb, dsparb2, dsparb3;
 	case PIPE_A:
 		dsparb = I915_READ(DSPARB);
@@ -399,24 +402,21 @@ static int vlv_get_fifo_size(struct drm_i915_private *dev_priv,
 		return 0;
 	}
 
-	switch (plane) {
-	case 0:
+	switch (plane->id) {
+	case PLANE_PRIMARY:
 		size = sprite0_start;
 		break;
-	case 1:
+	case PLANE_SPRITE0:
 		size = sprite1_start - sprite0_start;
 		break;
-	case 2:
+	case PLANE_SPRITE1:
 		size = 512 - 1 - sprite1_start;
 		break;
 	default:
 		return 0;
 	}
 
-	DRM_DEBUG_KMS("Pipe %c %s %c FIFO size: %d\n",
-		      pipe_name(pipe), plane == 0 ? "primary" : "sprite",
-		      plane == 0 ? plane_name(pipe) : sprite_name(pipe, plane - 1),
-		      size);
+	DRM_DEBUG_KMS("%s FIFO size: %d\n", plane->base.name, size);
 
 	return size;
 }
@@ -1053,6 +1053,12 @@ static void vlv_compute_fifo(struct intel_crtc *crtc)
 	WARN_ON(fifo_left != 0);
 }
 
+/* FIXME kill me */
+static inline int vlv_sprite_id(enum plane_id plane_id)
+{
+	return plane_id - PLANE_SPRITE0;
+}
+
 static void vlv_invert_wms(struct intel_crtc *crtc)
 {
 	struct vlv_wm_state *wm_state = &crtc->wm_state;
@@ -1079,7 +1085,7 @@ static void vlv_invert_wms(struct intel_crtc *crtc)
 					wm_state->wm[level].primary;
 				break;
 			case DRM_PLANE_TYPE_OVERLAY:
-				sprite = plane->plane;
+				sprite = vlv_sprite_id(plane->id);
 				wm_state->wm[level].sprite[sprite] = plane->wm.fifo_size -
 					wm_state->wm[level].sprite[sprite];
 				break;
@@ -1144,7 +1150,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc)
 				wm_state->wm[level].primary = wm;
 				break;
 			case DRM_PLANE_TYPE_OVERLAY:
-				sprite = plane->plane;
+				sprite = vlv_sprite_id(plane->id);
 				wm_state->wm[level].sprite[sprite] = wm;
 				break;
 			}
@@ -1170,7 +1176,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc)
 					    wm_state->wm[level].primary);
 			break;
 		case DRM_PLANE_TYPE_OVERLAY:
-			sprite = plane->plane;
+			sprite = vlv_sprite_id(plane->id);
 			for (level = 0; level < wm_state->num_levels; level++)
 				wm_state->sr[level].plane =
 					min(wm_state->sr[level].plane,
@@ -1199,17 +1205,23 @@ static void vlv_pipe_set_fifo_size(struct intel_crtc *crtc)
 	int sprite0_start = 0, sprite1_start = 0, fifo_size = 0;
 
 	for_each_intel_plane_on_crtc(dev, crtc, plane) {
-		if (plane->base.type == DRM_PLANE_TYPE_CURSOR) {
-			WARN_ON(plane->wm.fifo_size != 63);
-			continue;
-		}
-
-		if (plane->base.type == DRM_PLANE_TYPE_PRIMARY)
+		switch (plane->id) {
+		case PLANE_PRIMARY:
 			sprite0_start = plane->wm.fifo_size;
-		else if (plane->plane == 0)
+			break;
+		case PLANE_SPRITE0:
 			sprite1_start = sprite0_start + plane->wm.fifo_size;
-		else
+			break;
+		case PLANE_SPRITE1:
 			fifo_size = sprite1_start + plane->wm.fifo_size;
+			break;
+		case PLANE_CURSOR:
+			WARN_ON(plane->wm.fifo_size != 63);
+			break;
+		default:
+			MISSING_CASE(plane->id);
+			break;
+		}
 	}
 
 	WARN_ON(fifo_size != 512 - 1);
@@ -4510,21 +4522,8 @@ void vlv_wm_get_hw_state(struct drm_device *dev)
 
 	vlv_read_wm_values(dev_priv, wm);
 
-	for_each_intel_plane(dev, plane) {
-		switch (plane->base.type) {
-			int sprite;
-		case DRM_PLANE_TYPE_CURSOR:
-			plane->wm.fifo_size = 63;
-			break;
-		case DRM_PLANE_TYPE_PRIMARY:
-			plane->wm.fifo_size = vlv_get_fifo_size(dev_priv, plane->pipe, 0);
-			break;
-		case DRM_PLANE_TYPE_OVERLAY:
-			sprite = plane->plane;
-			plane->wm.fifo_size = vlv_get_fifo_size(dev_priv, plane->pipe, sprite + 1);
-			break;
-		}
-	}
+	for_each_intel_plane(dev, plane)
+		plane->wm.fifo_size = vlv_get_fifo_size(plane);
 
 	wm->cxsr = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
 	wm->level = VLV_WM_LEVEL_PM2;
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH v2 7/9 drm/i915: s/plane/plane_id/ in skl+ plane register defines

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Rename the SKL plane register define 'plane' parameter to 'plane_id' to reflect the fact that you're supposed to pass in the enum plane_id rather than enum plane.

Do the same for the scaler plane selector bits.

---
 drivers/gpu/drm/i915/i915_reg.h | 46 ++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +23 -23
index d03491089f9c..8ceea23ba63b 100644
@@ -5502,8 +5502,8 @@ enum {
 #define _PLANE_CTL_1(pipe)	_PIPE(pipe, _PLANE_CTL_1_A, _PLANE_CTL_1_B)
 #define _PLANE_CTL_2(pipe)	_PIPE(pipe, _PLANE_CTL_2_A, _PLANE_CTL_2_B)
 #define _PLANE_CTL_3(pipe)	_PIPE(pipe, _PLANE_CTL_3_A, _PLANE_CTL_3_B)
-#define PLANE_CTL(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_CTL_1(pipe), _PLANE_CTL_2(pipe))
+#define PLANE_CTL(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_CTL_1(pipe), _PLANE_CTL_2(pipe))
 
 #define _PLANE_STRIDE_1_B			0x71188
 #define _PLANE_STRIDE_2_B			0x71288
@@ -5514,8 +5514,8 @@ enum {
 	_PIPE(pipe, _PLANE_STRIDE_2_A, _PLANE_STRIDE_2_B)
 #define _PLANE_STRIDE_3(pipe)	\
 	_PIPE(pipe, _PLANE_STRIDE_3_A, _PLANE_STRIDE_3_B)
-#define PLANE_STRIDE(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_STRIDE_1(pipe), _PLANE_STRIDE_2(pipe))
+#define PLANE_STRIDE(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_STRIDE_1(pipe), _PLANE_STRIDE_2(pipe))
 
 #define _PLANE_POS_1_B				0x7118c
 #define _PLANE_POS_2_B				0x7128c
@@ -5523,8 +5523,8 @@ enum {
 #define _PLANE_POS_1(pipe)	_PIPE(pipe, _PLANE_POS_1_A, _PLANE_POS_1_B)
 #define _PLANE_POS_2(pipe)	_PIPE(pipe, _PLANE_POS_2_A, _PLANE_POS_2_B)
 #define _PLANE_POS_3(pipe)	_PIPE(pipe, _PLANE_POS_3_A, _PLANE_POS_3_B)
-#define PLANE_POS(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_POS_1(pipe), _PLANE_POS_2(pipe))
+#define PLANE_POS(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_POS_1(pipe), _PLANE_POS_2(pipe))
 
 #define _PLANE_SIZE_1_B				0x71190
 #define _PLANE_SIZE_2_B				0x71290
@@ -5532,8 +5532,8 @@ enum {
 #define _PLANE_SIZE_1(pipe)	_PIPE(pipe, _PLANE_SIZE_1_A, _PLANE_SIZE_1_B)
 #define _PLANE_SIZE_2(pipe)	_PIPE(pipe, _PLANE_SIZE_2_A, _PLANE_SIZE_2_B)
 #define _PLANE_SIZE_3(pipe)	_PIPE(pipe, _PLANE_SIZE_3_A, _PLANE_SIZE_3_B)
-#define PLANE_SIZE(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_SIZE_1(pipe), _PLANE_SIZE_2(pipe))
+#define PLANE_SIZE(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_SIZE_1(pipe), _PLANE_SIZE_2(pipe))
 
 #define _PLANE_SURF_1_B				0x7119c
 #define _PLANE_SURF_2_B				0x7129c
@@ -5541,36 +5541,36 @@ enum {
 #define _PLANE_SURF_1(pipe)	_PIPE(pipe, _PLANE_SURF_1_A, _PLANE_SURF_1_B)
 #define _PLANE_SURF_2(pipe)	_PIPE(pipe, _PLANE_SURF_2_A, _PLANE_SURF_2_B)
 #define _PLANE_SURF_3(pipe)	_PIPE(pipe, _PLANE_SURF_3_A, _PLANE_SURF_3_B)
-#define PLANE_SURF(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_SURF_1(pipe), _PLANE_SURF_2(pipe))
+#define PLANE_SURF(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_SURF_1(pipe), _PLANE_SURF_2(pipe))
 
 #define _PLANE_OFFSET_1_B			0x711a4
 #define _PLANE_OFFSET_2_B			0x712a4
 #define _PLANE_OFFSET_1(pipe) _PIPE(pipe, _PLANE_OFFSET_1_A, _PLANE_OFFSET_1_B)
 #define _PLANE_OFFSET_2(pipe) _PIPE(pipe, _PLANE_OFFSET_2_A, _PLANE_OFFSET_2_B)
-#define PLANE_OFFSET(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_OFFSET_1(pipe), _PLANE_OFFSET_2(pipe))
+#define PLANE_OFFSET(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_OFFSET_1(pipe), _PLANE_OFFSET_2(pipe))
 
 #define _PLANE_KEYVAL_1_B			0x71194
 #define _PLANE_KEYVAL_2_B			0x71294
 #define _PLANE_KEYVAL_1(pipe) _PIPE(pipe, _PLANE_KEYVAL_1_A, _PLANE_KEYVAL_1_B)
 #define _PLANE_KEYVAL_2(pipe) _PIPE(pipe, _PLANE_KEYVAL_2_A, _PLANE_KEYVAL_2_B)
-#define PLANE_KEYVAL(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_KEYVAL_1(pipe), _PLANE_KEYVAL_2(pipe))
+#define PLANE_KEYVAL(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_KEYVAL_1(pipe), _PLANE_KEYVAL_2(pipe))
 
 #define _PLANE_KEYMSK_1_B			0x71198
 #define _PLANE_KEYMSK_2_B			0x71298
 #define _PLANE_KEYMSK_1(pipe) _PIPE(pipe, _PLANE_KEYMSK_1_A, _PLANE_KEYMSK_1_B)
 #define _PLANE_KEYMSK_2(pipe) _PIPE(pipe, _PLANE_KEYMSK_2_A, _PLANE_KEYMSK_2_B)
-#define PLANE_KEYMSK(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_KEYMSK_1(pipe), _PLANE_KEYMSK_2(pipe))
+#define PLANE_KEYMSK(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_KEYMSK_1(pipe), _PLANE_KEYMSK_2(pipe))
 
 #define _PLANE_KEYMAX_1_B			0x711a0
 #define _PLANE_KEYMAX_2_B			0x712a0
 #define _PLANE_KEYMAX_1(pipe) _PIPE(pipe, _PLANE_KEYMAX_1_A, _PLANE_KEYMAX_1_B)
 #define _PLANE_KEYMAX_2(pipe) _PIPE(pipe, _PLANE_KEYMAX_2_A, _PLANE_KEYMAX_2_B)
-#define PLANE_KEYMAX(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_KEYMAX_1(pipe), _PLANE_KEYMAX_2(pipe))
+#define PLANE_KEYMAX(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_KEYMAX_1(pipe), _PLANE_KEYMAX_2(pipe))
 
 #define _PLANE_BUF_CFG_1_B			0x7127c
 #define _PLANE_BUF_CFG_2_B			0x7137c
@@ -5578,8 +5578,8 @@ enum {
 	_PIPE(pipe, _PLANE_BUF_CFG_1_A, _PLANE_BUF_CFG_1_B)
 #define _PLANE_BUF_CFG_2(pipe)	\
 	_PIPE(pipe, _PLANE_BUF_CFG_2_A, _PLANE_BUF_CFG_2_B)
-#define PLANE_BUF_CFG(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_BUF_CFG_1(pipe), _PLANE_BUF_CFG_2(pipe))
+#define PLANE_BUF_CFG(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_BUF_CFG_1(pipe), _PLANE_BUF_CFG_2(pipe))
 
 #define _PLANE_NV12_BUF_CFG_1_B		0x71278
 #define _PLANE_NV12_BUF_CFG_2_B		0x71378
@@ -5587,8 +5587,8 @@ enum {
 	_PIPE(pipe, _PLANE_NV12_BUF_CFG_1_A, _PLANE_NV12_BUF_CFG_1_B)
 #define _PLANE_NV12_BUF_CFG_2(pipe)	\
 	_PIPE(pipe, _PLANE_NV12_BUF_CFG_2_A, _PLANE_NV12_BUF_CFG_2_B)
-#define PLANE_NV12_BUF_CFG(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_NV12_BUF_CFG_1(pipe), _PLANE_NV12_BUF_CFG_2(pipe))
+#define PLANE_NV12_BUF_CFG(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_NV12_BUF_CFG_1(pipe), _PLANE_NV12_BUF_CFG_2(pipe))
 
 /* SKL new cursor registers */
 #define _CUR_BUF_CFG_A				0x7017c
@@ -5737,7 +5737,7 @@ enum {
 #define PS_SCALER_MODE_DYN  (0 << 28)
 #define PS_SCALER_MODE_HQ  (1 << 28)
 #define PS_PLANE_SEL_MASK  (7 << 25)
-#define PS_PLANE_SEL(plane) (((plane) + 1) << 25)
+#define PS_PLANE_SEL(plane_id) (((plane_id) + 1) << 25)
 #define PS_FILTER_MASK         (3 << 23)
 #define PS_FILTER_MEDIUM       (0 << 23)
 #define PS_FILTER_EDGE_ENHANCE (2 << 23)
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 7/9
#9 lore raw

Re: [PATCH 7/9] drm/i915: s/plane/plane_id/ in skl+ plane register defines

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] escreveu:

Quoted 9 lines

From: Ville Syrjälä <[email protected]>

Rename the SKL plane register define 'plane' parameter to 'plane_id' to
reflect the fact that you're supposed to pass in the enum plane_id rather than enum plane.

Do the same for the scaler plane selector bits.

Quoted 167 lines

---
 drivers/gpu/drm/i915/i915_reg.h | 46 ++++++++++++++++++++-----------
----------

 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +2 -2
index d03491089f9c..8ceea23ba63b 100644
@@ -5502,8 +5502,8 @@ enum {
  #define _PLANE_CTL_1(pipe)	_PIPE(pipe, _PLANE_CTL_1_A,
 _PLANE_CTL_1_B)
  #define _PLANE_CTL_2(pipe)	_PIPE(pipe, _PLANE_CTL_2_A,
 _PLANE_CTL_2_B)
  #define _PLANE_CTL_3(pipe)	_PIPE(pipe, _PLANE_CTL_3_A,
 _PLANE_CTL_3_B)
-#define PLANE_CTL(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_CTL_1(pipe), _PLANE_CTL_2(pipe))
+#define PLANE_CTL(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_CTL_1(pipe),

_PLANE_CTL_2(pipe))

 #define _PLANE_STRIDE_1_B 0x71188
 #define _PLANE_STRIDE_2_B 0x71288

drivers/gpu/drm/i915/i915_reg.h +2 -2
@@ -5514,8 +5514,8 @@ enum {
  	_PIPE(pipe, _PLANE_STRIDE_2_A, _PLANE_STRIDE_2_B)
  #define _PLANE_STRIDE_3(pipe)	\
  	_PIPE(pipe, _PLANE_STRIDE_3_A, _PLANE_STRIDE_3_B)
-#define PLANE_STRIDE(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_STRIDE_1(pipe),
 _PLANE_STRIDE_2(pipe))
+#define PLANE_STRIDE(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_STRIDE_1(pipe),
 _PLANE_STRIDE_2(pipe))


 #define _PLANE_POS_1_B 0x7118c
 #define _PLANE_POS_2_B 0x7128c

drivers/gpu/drm/i915/i915_reg.h +2 -2
@@ -5523,8 +5523,8 @@ enum {
  #define _PLANE_POS_1(pipe)	_PIPE(pipe, _PLANE_POS_1_A,
 _PLANE_POS_1_B)
  #define _PLANE_POS_2(pipe)	_PIPE(pipe, _PLANE_POS_2_A,
 _PLANE_POS_2_B)
  #define _PLANE_POS_3(pipe)	_PIPE(pipe, _PLANE_POS_3_A,
 _PLANE_POS_3_B)
-#define PLANE_POS(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_POS_1(pipe), _PLANE_POS_2(pipe))
+#define PLANE_POS(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_POS_1(pipe),

_PLANE_POS_2(pipe))

 #define _PLANE_SIZE_1_B 0x71190
 #define _PLANE_SIZE_2_B 0x71290

drivers/gpu/drm/i915/i915_reg.h +2 -2
@@ -5532,8 +5532,8 @@ enum {
  #define _PLANE_SIZE_1(pipe)	_PIPE(pipe, _PLANE_SIZE_1_A,
 _PLANE_SIZE_1_B)
  #define _PLANE_SIZE_2(pipe)	_PIPE(pipe, _PLANE_SIZE_2_A,
 _PLANE_SIZE_2_B)
  #define _PLANE_SIZE_3(pipe)	_PIPE(pipe, _PLANE_SIZE_3_A,
 _PLANE_SIZE_3_B)
-#define PLANE_SIZE(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_SIZE_1(pipe), _PLANE_SIZE_2(pipe))
+#define PLANE_SIZE(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_SIZE_1(pipe),

_PLANE_SIZE_2(pipe))

 #define _PLANE_SURF_1_B 0x7119c
 #define _PLANE_SURF_2_B 0x7129c

drivers/gpu/drm/i915/i915_reg.h +2 -2
@@ -5541,36 +5541,36 @@ enum {
  #define _PLANE_SURF_1(pipe)	_PIPE(pipe, _PLANE_SURF_1_A,
 _PLANE_SURF_1_B)
  #define _PLANE_SURF_2(pipe)	_PIPE(pipe, _PLANE_SURF_2_A,
 _PLANE_SURF_2_B)
  #define _PLANE_SURF_3(pipe)	_PIPE(pipe, _PLANE_SURF_3_A,
 _PLANE_SURF_3_B)
-#define PLANE_SURF(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_SURF_1(pipe), _PLANE_SURF_2(pipe))
+#define PLANE_SURF(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_SURF_1(pipe),
 _PLANE_SURF_2(pipe))


 #define _PLANE_OFFSET_1_B 0x711a4
 #define _PLANE_OFFSET_2_B 0x712a4
 #define _PLANE_OFFSET_1(pipe) _PIPE(pipe, _PLANE_OFFSET_1_A, _PLANE_OFFSET_1_B)
 #define _PLANE_OFFSET_2(pipe) _PIPE(pipe, _PLANE_OFFSET_2_A, _PLANE_OFFSET_2_B)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define PLANE_OFFSET(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_OFFSET_1(pipe),

_PLANE_OFFSET_2(pipe))

drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define PLANE_OFFSET(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_OFFSET_1(pipe),

_PLANE_OFFSET_2(pipe))

 #define _PLANE_KEYVAL_1_B 0x71194
 #define _PLANE_KEYVAL_2_B 0x71294
 #define _PLANE_KEYVAL_1(pipe) _PIPE(pipe, _PLANE_KEYVAL_1_A, _PLANE_KEYVAL_1_B)
 #define _PLANE_KEYVAL_2(pipe) _PIPE(pipe, _PLANE_KEYVAL_2_A, _PLANE_KEYVAL_2_B)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define PLANE_KEYVAL(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_KEYVAL_1(pipe),

_PLANE_KEYVAL_2(pipe))

drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define PLANE_KEYVAL(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_KEYVAL_1(pipe),

_PLANE_KEYVAL_2(pipe))

 #define _PLANE_KEYMSK_1_B 0x71198
 #define _PLANE_KEYMSK_2_B 0x71298
 #define _PLANE_KEYMSK_1(pipe) _PIPE(pipe, _PLANE_KEYMSK_1_A, _PLANE_KEYMSK_1_B)
 #define _PLANE_KEYMSK_2(pipe) _PIPE(pipe, _PLANE_KEYMSK_2_A, _PLANE_KEYMSK_2_B)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define PLANE_KEYMSK(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_KEYMSK_1(pipe),

_PLANE_KEYMSK_2(pipe))

drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define PLANE_KEYMSK(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_KEYMSK_1(pipe),

_PLANE_KEYMSK_2(pipe))

 #define _PLANE_KEYMAX_1_B 0x711a0
 #define _PLANE_KEYMAX_2_B 0x712a0
 #define _PLANE_KEYMAX_1(pipe) _PIPE(pipe, _PLANE_KEYMAX_1_A, _PLANE_KEYMAX_1_B)
 #define _PLANE_KEYMAX_2(pipe) _PIPE(pipe, _PLANE_KEYMAX_2_A, _PLANE_KEYMAX_2_B)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define PLANE_KEYMAX(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_KEYMAX_1(pipe),

_PLANE_KEYMAX_2(pipe))

drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define PLANE_KEYMAX(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_KEYMAX_1(pipe),

_PLANE_KEYMAX_2(pipe))

 #define _PLANE_BUF_CFG_1_B 0x7127c
 #define _PLANE_BUF_CFG_2_B 0x7137c

drivers/gpu/drm/i915/i915_reg.h +2 -2
@@ -5578,8 +5578,8 @@ enum {
  	_PIPE(pipe, _PLANE_BUF_CFG_1_A, _PLANE_BUF_CFG_1_B)
  #define _PLANE_BUF_CFG_2(pipe)	\
  	_PIPE(pipe, _PLANE_BUF_CFG_2_A, _PLANE_BUF_CFG_2_B)
-#define PLANE_BUF_CFG(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_BUF_CFG_1(pipe),
 _PLANE_BUF_CFG_2(pipe))
+#define PLANE_BUF_CFG(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_BUF_CFG_1(pipe),
 _PLANE_BUF_CFG_2(pipe))


 #define _PLANE_NV12_BUF_CFG_1_B 0x71278
 #define _PLANE_NV12_BUF_CFG_2_B 0x71378

drivers/gpu/drm/i915/i915_reg.h +2 -2
@@ -5587,8 +5587,8 @@ enum {
  	_PIPE(pipe, _PLANE_NV12_BUF_CFG_1_A,
 _PLANE_NV12_BUF_CFG_1_B)
  #define _PLANE_NV12_BUF_CFG_2(pipe)	\
  	_PIPE(pipe, _PLANE_NV12_BUF_CFG_2_A,
 _PLANE_NV12_BUF_CFG_2_B)
-#define PLANE_NV12_BUF_CFG(pipe, plane)	\
-	_MMIO_PLANE(plane, _PLANE_NV12_BUF_CFG_1(pipe),
 _PLANE_NV12_BUF_CFG_2(pipe))
+#define PLANE_NV12_BUF_CFG(pipe, plane_id)	\
+	_MMIO_PLANE(plane_id, _PLANE_NV12_BUF_CFG_1(pipe),

_PLANE_NV12_BUF_CFG_2(pipe))

 /* SKL new cursor registers */
 #define _CUR_BUF_CFG_A 0x7017c

drivers/gpu/drm/i915/i915_reg.h enum { · line 5743

Quoted 8 lines
drivers/gpu/drm/i915/i915_reg.h +1 -1
@@ -5737,7 +5737,7 @@ enum {
  #define PS_SCALER_MODE_DYN  (0 << 28)
  #define PS_SCALER_MODE_HQ  (1 << 28)
  #define PS_PLANE_SEL_MASK  (7 << 25)
-#define PS_PLANE_SEL(plane) (((plane) + 1) << 25)
+#define PS_PLANE_SEL(plane_id) (((plane_id) + 1) << 25)
  #define PS_FILTER_MASK         (3 << 23)
  #define PS_FILTER_MEDIUM       (0 << 23)
  #define PS_FILTER_EDGE_ENHANCE (2 << 23)

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

PATCH v2 8/9 drm/i915: Don't populate plane->plane for cursors and sprites

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

With plane->plane now purely reserved for the primary planes, let's not even populate it for cursors and sprites. Let's switch the type to enum plane as well since it's no longer being abused for anything else.

---
 drivers/gpu/drm/i915/intel_display.c | 1 -
 drivers/gpu/drm/i915/intel_drv.h     | 2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 1 -
 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index b6d5d5e5cc99..f180f14fcf3a 100644
@@ -15188,7 +15188,6 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
 	cursor->can_scale = false;
 	cursor->max_downscale = 1;
 	cursor->pipe = pipe;
-	cursor->plane = pipe;
 	cursor->id = PLANE_CURSOR;
 	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);
 	cursor->check_plane = intel_check_cursor_plane;
drivers/gpu/drm/i915/intel_drv.h +1 -1
index c1b245853ba9..d14718e09911 100644
@@ -767,7 +767,7 @@ struct intel_plane_wm_parameters {
 
 struct intel_plane {
 	struct drm_plane base;
-	u8 plane;
+	enum plane plane;
 	enum plane_id id;
 	enum pipe pipe;
 	bool can_scale;
drivers/gpu/drm/i915/intel_sprite.c +0 -1
index 63154a5a9305..1044095d0084 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct drm_i915_private *dev_priv,
 	}
 
 	intel_plane->pipe = pipe;
-	intel_plane->plane = plane;
 	intel_plane->id = PLANE_SPRITE0 + plane;
 	intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane);
 	intel_plane->check_plane = intel_check_sprite_plane;
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

Re: [PATCH 8/9] drm/i915: Don't populate plane->plane for cursors and sprites

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] escreveu:

Quoted 6 lines

From: Ville Syrjälä <[email protected]>

With plane->plane now purely reserved for the primary planes, let's not even populate it for cursors and sprites. Let's switch the type to enum plane as well since it's no longer being abused for anything else.

Since it's a primary plane thing, I think it makes more sense to just leave it at struct intel_crtc instead of having a field that's unused and doesn't make sense in some cases. The crtc struct already includes some fields that are specific to primary planes, so I think it's a good place. Or we could create a new class: struct intel_primary_plane { struct intel_plane base; enum plane legacy_plane };

Following is a patch suggestion (probably impossible to apply due to my editor breaking long lines). Any arguments against it?

--8<----------------------------------------------------------

(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_display.c
index bc1af87..c54b1a7 100644

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15065,14 +15065,6 @@ intel_primary_plane_create(struct

drm_i915_private *dev_priv, enum pipe pipe) state->scaler_id = -1;
  }
  primary->pipe = pipe;
- /*
-  * On gen2/3 only plane A can do FBC, but the panel fitter and
LVDS
-  * port is hooked to pipe B. Hence we want plane A feeding
pipe B.
-  */
- if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
- primary->plane = (enum plane) !pipe;
- else
- primary->plane = (enum plane) pipe;
  primary->id = PLANE_PRIMARY; primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe); primary->check_plane = intel_check_primary_plane; @@ -15120,7 +15112,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
         0, &intel_plane_funcs, intel_primary_formats, num_formats,
         DRM_PLANE_TYPE_PRIMARY,
-        "plane %c",
plane_name(primary->plane));
+        "plane %c",
pipe_name(pipe)); /* FIXME */
  if (ret)
  goto fail;

@@ -15272,7 +15264,6 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe) cursor->can_scale = false;
  cursor->max_downscale = 1;
  cursor->pipe = pipe;
- cursor->plane = pipe;
  cursor->id = PLANE_CURSOR;
  cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe); cursor->check_plane = intel_check_cursor_plane;
@@ -15390,7 +15381,14 @@ static int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe)
  goto fail;

  intel_crtc->pipe = pipe;
- intel_crtc->plane = primary->plane;
+ /*
+  * On gen2/3 only plane A can do FBC, but the panel fitter and
LVDS
+  * port is hooked to pipe B. Hence we want plane A feeding
pipe B.
+  */
+ if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
+ intel_crtc->plane = (enum plane) !pipe;
+ else
+ intel_crtc->plane = (enum plane) pipe;

  intel_crtc->cursor_base = ~0; intel_crtc->cursor_cntl = ~0;
@@ -16866,11 +16864,11 @@ void i915_redisable_vga(struct drm_i915_private *dev_priv) intel_display_power_put(dev_priv, POWER_DOMAIN_VGA); }

-static bool primary_get_hw_state(struct intel_plane *plane) +static bool primary_get_hw_state(struct intel_crtc *crtc) {
- struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
+ struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);

- return I915_READ(DSPCNTR(plane->plane)) &
DISPLAY_PLANE_ENABLE;
+ return I915_READ(DSPCNTR(crtc->plane)) & DISPLAY_PLANE_ENABLE;
 }

 /* FIXME read out full plane state for all planes */
@@ -16880,8 +16878,7 @@ static void readout_plane_state(struct intel_crtc *crtc)
  struct intel_plane_state *plane_state = to_intel_plane_state(primary->state);

- plane_state->base.visible = crtc->active &&
- primary_get_hw_state(to_intel_plane(primary));
+ plane_state->base.visible = crtc->active &&
primary_get_hw_state(crtc);

  if (plane_state->base.visible) crtc->base.state->plane_mask |= 1 << drm_plane_index(primary);

(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_drv.h
index 362f698..b2bdd49 100644

drivers/gpu/drm/i915/intel_drv.h +0 -0
@@ -767,7 +767,6 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;
- u8 plane;
  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_sprite.c
index 63154a5..1044095 100644

drivers/gpu/drm/i915/intel_sprite.c +0 -0
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct drm_i915_private

*dev_priv,
  }

  intel_plane->pipe = pipe;
- intel_plane->plane = plane;
  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane);
  intel_plane->check_plane = intel_check_sprite_plane;

--8<----------------------------------------------------------

Quoted 47 lines

---
 drivers/gpu/drm/i915/intel_display.c | 1 -
 drivers/gpu/drm/i915/intel_drv.h     | 2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 1 -

 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index b6d5d5e5cc99..f180f14fcf3a 100644
@@ -15188,7 +15188,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;
  	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);

  cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_drv.h +0 -0
index c1b245853ba9..d14718e09911 100644
@@ -767,7 +767,7 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +1 -1
-	u8 plane;
+	enum plane plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5a9305..1044095d0084 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct
 drm_i915_private *dev_priv,
  	}


  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;
Quoted 4 lines

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane); intel_plane->check_plane = intel_check_sprite_plane;

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw

Re: [PATCH 8/9] drm/i915: Don't populate plane->plane for cursors and sprites

Quoted 4 lines · Paulo Zanoni

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] escreveu:

Quoted 2 lines

From: Ville Syrjälä <[email protected]>

Quoted 8 lines
Quoted 4 lines

With plane->plane now purely reserved for the primary planes, let's not even populate it for cursors and sprites. Let's switch the type to enum plane as well since it's no longer being abused for anything else.

Since it's a primary plane thing, I think it makes more sense to just leave it at struct intel_crtc instead of having a field that's unused and doesn't make sense in some cases.

Primary plane aren't really primary planes on old platforms though. That's just a software concept that has no bearing on the hardware.

Quoted 186 lines

The crtc struct already includes
some fields that are specific to primary planes, so I think it's a good place. Or we could create a new class: struct intel_primary_plane { struct intel_plane base; enum plane legacy_plane };

Following is a patch suggestion (probably impossible to apply due to my editor breaking long lines). Any arguments against it?

--8<----------------------------------------------------------

drivers/gpu/drm/i915/intel_display.c +0 -2
index bc1af87..c54b1a7 100644
@@ -15065,14 +15065,6 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		state->scaler_id = -1;
  	}
  	primary->pipe = pipe;
-	/*
-	 * On gen2/3 only plane A can do FBC, but the panel fitter and

LVDS

drivers/gpu/drm/i915/intel_display.c +0 -1
-	 * port is hooked to pipe B. Hence we want plane A feeding

pipe B.

drivers/gpu/drm/i915/intel_display.c +0 -5
-	 */
-	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
-		primary->plane = (enum plane) !pipe;
-	else
-		primary->plane = (enum plane) pipe;

  primary->id = PLANE_PRIMARY; primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe); primary->check_plane = intel_check_primary_plane;

drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -15120,7 +15112,7 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  					       0, &intel_plane_funcs,
  					       intel_primary_formats,
 num_formats,
  					       DRM_PLANE_TYPE_PRIMARY,
-					       "plane %c",
 plane_name(primary->plane));
+					       "plane %c",

pipe_name(pipe)); /* FIXME */
  if (ret)
  goto fail;

drivers/gpu/drm/i915/intel_display.c +0 -1
@@ -15272,7 +15264,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;
  	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);

  cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15390,7 +15381,14 @@ static int intel_crtc_init(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		goto fail;


  intel_crtc->pipe = pipe;

drivers/gpu/drm/i915/intel_display.c +2 -1
-	intel_crtc->plane = primary->plane;
+	/*
+	 * On gen2/3 only plane A can do FBC, but the panel fitter and

LVDS

drivers/gpu/drm/i915/intel_display.c +1 -0
+	 * port is hooked to pipe B. Hence we want plane A feeding

pipe B.

drivers/gpu/drm/i915/intel_display.c +5 -0
+	 */
+	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
+		intel_crtc->plane = (enum plane) !pipe;
+	else
+		intel_crtc->plane = (enum plane) pipe;


  intel_crtc->cursor_base = ~0;
  intel_crtc->cursor_cntl = ~0;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16866,11 +16864,11 @@ void i915_redisable_vga(struct
 drm_i915_private *dev_priv)
  	intel_display_power_put(dev_priv, POWER_DOMAIN_VGA);
  }

drivers/gpu/drm/i915/intel_display.c +1 -1
-static bool primary_get_hw_state(struct intel_plane *plane)
+static bool primary_get_hw_state(struct intel_crtc *crtc)

 {

drivers/gpu/drm/i915/intel_display.c +1 -1
-	struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
+	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);

drivers/gpu/drm/i915/intel_display.c +0 -1
-	return I915_READ(DSPCNTR(plane->plane)) &

DISPLAY_PLANE_ENABLE;

drivers/gpu/drm/i915/intel_display.c +1 -0
+	return I915_READ(DSPCNTR(crtc->plane)) & DISPLAY_PLANE_ENABLE;

 }

 /* FIXME read out full plane state for all planes */

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16880,8 +16878,7 @@ static void readout_plane_state(struct
 intel_crtc *crtc)

  struct intel_plane_state *plane_state = to_intel_plane_state(primary->state);

drivers/gpu/drm/i915/intel_display.c +1 -2
-	plane_state->base.visible = crtc->active &&
-		primary_get_hw_state(to_intel_plane(primary));
+	plane_state->base.visible = crtc->active &&

primary_get_hw_state(crtc);

  if (plane_state->base.visible) crtc->base.state->plane_mask |= 1 << drm_plane_index(primary);

drivers/gpu/drm/i915/intel_drv.h +0 -0
index 362f698..b2bdd49 100644
@@ -767,7 +767,6 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +0 -1
-	u8 plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5..1044095 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct drm_i915_private
 *dev_priv,
  	}


  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane);
  intel_plane->check_plane = intel_check_sprite_plane;

--8<----------------------------------------------------------

Quoted 51 lines

---
 drivers/gpu/drm/i915/intel_display.c | 1 -
 drivers/gpu/drm/i915/intel_drv.h     | 2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 1 -

 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index b6d5d5e5cc99..f180f14fcf3a 100644
@@ -15188,7 +15188,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;
  	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);

  cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_drv.h +0 -0
index c1b245853ba9..d14718e09911 100644
@@ -767,7 +767,7 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +1 -1
-	u8 plane;
+	enum plane plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5a9305..1044095d0084 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct
 drm_i915_private *dev_priv,
  	}


  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane); intel_plane->check_plane = intel_check_sprite_plane;

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

Re: [PATCH 8/9] drm/i915: Don't populate plane->plane for cursors and sprites

Em Qui, 2016-12-15 às 21:11 +0200, Ville Syrjälä escreveu:

Quoted 15 lines · Paulo Zanoni
Quoted 14 lines

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] escreveu:

Quoted 10 lines

From: Ville Syrjälä <[email protected]>

With plane->plane now purely reserved for the primary planes, let's
not even populate it for cursors and sprites. Let's switch the type
to enum plane as well since it's no longer being abused for anything
else.

Quoted 8 lines
Quoted 5 lines

Since it's a primary plane thing, I think it makes more sense to just
leave it at struct intel_crtc instead of having a field that's unused
and doesn't make sense in some cases.

Primary plane aren't really primary planes on old platforms though. That's just a software concept that has no bearing on the hardware.

Please explain more since that's not my understanding. I just opened the gen 2 and 3 spec docs and they do contain tons of "primary plane" references. I know that the hardware is a little more flexible there, but as far as I understand we don't even implement that. Besides, both our driver and our API do have the concept of a primary plane, so it makes sense for the code to be organized that way, IMHO. Besides, I think our code organizations should always better fit the new hardware, since otherwise we'll make i915.ko development even harder than it is for new contributors/employees.

(And when I see those specs and realize how different the HW was, then I remember that in order to explain to the new people why some things are the way they are in our code I have to explain how the HW was 10 years ago, I start thinking again that maybe we should just have i915- old.ko and i915-new.ko, since either we make our abstractions/design fit one thing or we make it fit another...)

Quoted 195 lines
Quoted 195 lines

The crtc struct already includes
some fields that are specific to primary planes, so I think it's a good
place. Or we could create a new class: struct intel_primary_plane { struct intel_plane base; enum plane legacy_plane };

Following is a patch suggestion (probably impossible to apply due to my
editor breaking long lines). Any arguments against it?

--8<----------------------------------------------------------

drivers/gpu/drm/i915/intel_display.c +0 -2
index bc1af87..c54b1a7 100644
@@ -15065,14 +15065,6 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		state->scaler_id = -1;
  	}
  	primary->pipe = pipe;
-	/*
-	 * On gen2/3 only plane A can do FBC, but the panel fitter

and
LVDS

drivers/gpu/drm/i915/intel_display.c +0 -1
-	 * port is hooked to pipe B. Hence we want plane A feeding

pipe B.

drivers/gpu/drm/i915/intel_display.c +0 -5
-	 */
-	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
-		primary->plane = (enum plane) !pipe;
-	else
-		primary->plane = (enum plane) pipe;

  primary->id = PLANE_PRIMARY; primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe); primary->check_plane = intel_check_primary_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15120,7 +15112,7 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  					       0,
 &intel_plane_funcs,

         intel_primary_forma ts,
num_formats,
         DRM_PLANE_TYPE_PRIM ARY,

drivers/gpu/drm/i915/intel_display.c +0 -1
-					       "plane %c",

plane_name(primary->plane));

drivers/gpu/drm/i915/intel_display.c +1 -0
+					       "plane %c",

pipe_name(pipe)); /* FIXME */
  if (ret)
  goto fail;

drivers/gpu/drm/i915/intel_display.c +0 -1
@@ -15272,7 +15264,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;
  	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);

  cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15390,7 +15381,14 @@ static int intel_crtc_init(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		goto fail;


  intel_crtc->pipe = pipe;

drivers/gpu/drm/i915/intel_display.c +2 -1
-	intel_crtc->plane = primary->plane;
+	/*
+	 * On gen2/3 only plane A can do FBC, but the panel fitter

and
LVDS

drivers/gpu/drm/i915/intel_display.c +1 -0
+	 * port is hooked to pipe B. Hence we want plane A feeding

pipe B.

drivers/gpu/drm/i915/intel_display.c +5 -0
+	 */
+	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
+		intel_crtc->plane = (enum plane) !pipe;
+	else
+		intel_crtc->plane = (enum plane) pipe;


  intel_crtc->cursor_base = ~0;
  intel_crtc->cursor_cntl = ~0;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16866,11 +16864,11 @@ void i915_redisable_vga(struct
 drm_i915_private *dev_priv)
  	intel_display_power_put(dev_priv, POWER_DOMAIN_VGA);
  }

drivers/gpu/drm/i915/intel_display.c +1 -1
-static bool primary_get_hw_state(struct intel_plane *plane)
+static bool primary_get_hw_state(struct intel_crtc *crtc)

 {

drivers/gpu/drm/i915/intel_display.c +0 -1
-	struct drm_i915_private *dev_priv = to_i915(plane-
Quoted 1 line

base.dev);

drivers/gpu/drm/i915/intel_display.c +1 -0
+	struct drm_i915_private *dev_priv = to_i915(crtc-
Quoted 1 line

base.dev);

drivers/gpu/drm/i915/intel_display.c +0 -1
-	return I915_READ(DSPCNTR(plane->plane)) &

DISPLAY_PLANE_ENABLE;

drivers/gpu/drm/i915/intel_display.c +1 -0
+	return I915_READ(DSPCNTR(crtc->plane)) &

DISPLAY_PLANE_ENABLE;
 }

 /* FIXME read out full plane state for all planes */

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16880,8 +16878,7 @@ static void readout_plane_state(struct
 intel_crtc *crtc)

  struct intel_plane_state *plane_state = to_intel_plane_state(primary->state);

drivers/gpu/drm/i915/intel_display.c +1 -2
-	plane_state->base.visible = crtc->active &&
-		primary_get_hw_state(to_intel_plane(primary));
+	plane_state->base.visible = crtc->active &&

primary_get_hw_state(crtc);

  if (plane_state->base.visible) crtc->base.state->plane_mask |= 1 << drm_plane_index(primary);

drivers/gpu/drm/i915/intel_drv.h +0 -0
index 362f698..b2bdd49 100644
@@ -767,7 +767,6 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +0 -1
-	u8 plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5..1044095 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct

drm_i915_private
*dev_priv,
  }

  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe,
plane);
  intel_plane->check_plane = intel_check_sprite_plane;

--8<----------------------------------------------------------

Quoted 45 lines

---
 drivers/gpu/drm/i915/intel_display.c | 1 -
 drivers/gpu/drm/i915/intel_drv.h     | 2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 1 -

 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index b6d5d5e5cc99..f180f14fcf3a 100644
@@ -15188,7 +15188,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;

  cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe); cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_drv.h +0 -0
index c1b245853ba9..d14718e09911 100644
@@ -767,7 +767,7 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +1 -1
-	u8 plane;
+	enum plane plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5a9305..1044095d0084 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct
 drm_i915_private *dev_priv,
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_sprite.c +0 -0
  	}


  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane); intel_plane->check_plane = intel_check_sprite_plane;

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw

Re: [PATCH 8/9] drm/i915: Don't populate plane->plane for cursors and sprites

Quoted 22 lines · Paulo Zanoni

Em Qui, 2016-12-15 às 21:11 +0200, Ville Syrjälä escreveu:

Quoted 21 lines · Paulo Zanoni
Quoted 19 lines

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] escreveu:

Quoted 10 lines

From: Ville Syrjälä <[email protected]>

With plane->plane now purely reserved for the primary planes, let's
not even populate it for cursors and sprites. Let's switch the type
to enum plane as well since it's no longer being abused for anything
else.

Since it's a primary plane thing, I think it makes more sense to just
leave it at struct intel_crtc instead of having a field that's unused
and doesn't make sense in some cases.

Quoted 6 lines
Quoted 2 lines

Primary plane aren't really primary planes on old platforms though. That's just a software concept that has no bearing on the hardware.

Please explain more since that's not my understanding. I just opened the gen 2 and 3 spec docs and they do contain tons of "primary plane" references. I know that the hardware is a little more flexible there,

Yep. Planes can be moved to any pipe in general.

Quoted 1 line

but as far as I understand we don't even implement that.

Not at the moment. But I have plans...

Quoted 3 lines

Besides, both
our driver and our API do have the concept of a primary plane, so it makes sense for the code to be organized that way, IMHO.

A plane is a plane, a pipe is a pipe. IMO you're trying to make it more confusing by mixing up the two.

Quoted 4 lines

Besides, I
think our code organizations should always better fit the new hardware, since otherwise we'll make i915.ko development even harder than it is for new contributors/employees.

If you don't mix planes and pipes there can't be any confusion.

Quoted 7 lines

(And when I see those specs and realize how different the HW was, then I remember that in order to explain to the new people why some things are the way they are in our code I have to explain how the HW was 10 years ago, I start thinking again that maybe we should just have i915- old.ko and i915-new.ko, since either we make our abstractions/design fit one thing or we make it fit another...)

From the register POV hw was almost identical up to BDW at least. It's just a few bits (the pipe selector) that vanished from the registers. SKL+ is a little more different but still the registers even live in the same address.

Also given what recent history has shown us, I wouldn't be at all surprised if we would go back to a flexible plane<->pipe assignment in the hardware at some point in the future. A lot of the other features that were present in old hardware has been making a comeback in recent years.

Quoted 205 lines
Quoted 205 lines
Quoted 204 lines

The crtc struct already includes
some fields that are specific to primary planes, so I think it's a good
place. Or we could create a new class: struct intel_primary_plane { struct intel_plane base; enum plane legacy_plane };

Following is a patch suggestion (probably impossible to apply due to my
editor breaking long lines). Any arguments against it?

--8<----------------------------------------------------------

drivers/gpu/drm/i915/intel_display.c +0 -2
index bc1af87..c54b1a7 100644
@@ -15065,14 +15065,6 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		state->scaler_id = -1;
  	}
  	primary->pipe = pipe;
-	/*
-	 * On gen2/3 only plane A can do FBC, but the panel fitter

and
LVDS

drivers/gpu/drm/i915/intel_display.c +0 -1
-	 * port is hooked to pipe B. Hence we want plane A feeding

pipe B.

drivers/gpu/drm/i915/intel_display.c +0 -5
-	 */
-	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
-		primary->plane = (enum plane) !pipe;
-	else
-		primary->plane = (enum plane) pipe;

  primary->id = PLANE_PRIMARY; primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe); primary->check_plane = intel_check_primary_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15120,7 +15112,7 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  					       0,
 &intel_plane_funcs,

         intel_primary_forma ts,
num_formats,
         DRM_PLANE_TYPE_PRIM ARY,

drivers/gpu/drm/i915/intel_display.c +0 -1
-					       "plane %c",

plane_name(primary->plane));

drivers/gpu/drm/i915/intel_display.c +1 -0
+					       "plane %c",

pipe_name(pipe)); /* FIXME */
  if (ret)
  goto fail;

drivers/gpu/drm/i915/intel_display.c +0 -1
@@ -15272,7 +15264,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;
  	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);

  cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15390,7 +15381,14 @@ static int intel_crtc_init(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		goto fail;


  intel_crtc->pipe = pipe;

drivers/gpu/drm/i915/intel_display.c +2 -1
-	intel_crtc->plane = primary->plane;
+	/*
+	 * On gen2/3 only plane A can do FBC, but the panel fitter

and
LVDS

drivers/gpu/drm/i915/intel_display.c +1 -0
+	 * port is hooked to pipe B. Hence we want plane A feeding

pipe B.

drivers/gpu/drm/i915/intel_display.c +5 -0
+	 */
+	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
+		intel_crtc->plane = (enum plane) !pipe;
+	else
+		intel_crtc->plane = (enum plane) pipe;


  intel_crtc->cursor_base = ~0;
  intel_crtc->cursor_cntl = ~0;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16866,11 +16864,11 @@ void i915_redisable_vga(struct
 drm_i915_private *dev_priv)
  	intel_display_power_put(dev_priv, POWER_DOMAIN_VGA);
  }

drivers/gpu/drm/i915/intel_display.c +1 -1
-static bool primary_get_hw_state(struct intel_plane *plane)
+static bool primary_get_hw_state(struct intel_crtc *crtc)

 {

drivers/gpu/drm/i915/intel_display.c +0 -1
-	struct drm_i915_private *dev_priv = to_i915(plane-
Quoted 1 line

base.dev);

drivers/gpu/drm/i915/intel_display.c +1 -0
+	struct drm_i915_private *dev_priv = to_i915(crtc-
Quoted 1 line

base.dev);

drivers/gpu/drm/i915/intel_display.c +0 -1
-	return I915_READ(DSPCNTR(plane->plane)) &

DISPLAY_PLANE_ENABLE;

drivers/gpu/drm/i915/intel_display.c +1 -0
+	return I915_READ(DSPCNTR(crtc->plane)) &

DISPLAY_PLANE_ENABLE;
 }

 /* FIXME read out full plane state for all planes */

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16880,8 +16878,7 @@ static void readout_plane_state(struct
 intel_crtc *crtc)

  struct intel_plane_state *plane_state = to_intel_plane_state(primary->state);

drivers/gpu/drm/i915/intel_display.c +1 -2
-	plane_state->base.visible = crtc->active &&
-		primary_get_hw_state(to_intel_plane(primary));
+	plane_state->base.visible = crtc->active &&

primary_get_hw_state(crtc);

  if (plane_state->base.visible) crtc->base.state->plane_mask |= 1 << drm_plane_index(primary);

drivers/gpu/drm/i915/intel_drv.h +0 -0
index 362f698..b2bdd49 100644
@@ -767,7 +767,6 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +0 -1
-	u8 plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5..1044095 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct

drm_i915_private
*dev_priv,
  }

  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe,
plane);
  intel_plane->check_plane = intel_check_sprite_plane;

--8<----------------------------------------------------------

Quoted 53 lines

---
 drivers/gpu/drm/i915/intel_display.c | 1 -
 drivers/gpu/drm/i915/intel_drv.h     | 2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 1 -

 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index b6d5d5e5cc99..f180f14fcf3a 100644
@@ -15188,7 +15188,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;

  cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe); cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_drv.h +0 -0
index c1b245853ba9..d14718e09911 100644
@@ -767,7 +767,7 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +1 -1
-	u8 plane;
+	enum plane plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5a9305..1044095d0084 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct
 drm_i915_private *dev_priv,
  	}


  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane); intel_plane->check_plane = intel_check_sprite_plane;

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

Re: [PATCH 8/9] drm/i915: Don't populate plane->plane for cursors and sprites

Em Qui, 2016-12-15 às 21:59 +0200, Ville Syrjälä escreveu:

Quoted 50 lines · Paulo Zanoni
Quoted 34 lines

Em Qui, 2016-12-15 às 21:11 +0200, Ville Syrjälä escreveu:

Quoted 27 lines · Paulo Zanoni
Quoted 18 lines

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] m
escreveu:

Quoted 4 lines

From: Ville Syrjälä <[email protected]>

Quoted 8 lines

With plane->plane now purely reserved for the primary planes, let's
not even populate it for cursors and sprites. Let's switch the
type
to enum plane as well since it's no longer being abused for anything
else.

Quoted 6 lines

Since it's a primary plane thing, I think it makes more sense to
just
leave it at struct intel_crtc instead of having a field that's unused
and doesn't make sense in some cases.

Quoted 4 lines

Primary plane aren't really primary planes on old platforms though.
That's just a software concept that has no bearing on the hardware.

Quoted 6 lines

Please explain more since that's not my understanding. I just opened
the gen 2 and 3 spec docs and they do contain tons of "primary plane"
references. I know that the hardware is a little more flexible there,

Yep. Planes can be moved to any pipe in general.

Quoted 2 lines

but as far as I understand we don't even implement that.

Not at the moment. But I have plans...

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

Besides, both
our driver and our API do have the concept of a primary plane, so it
makes sense for the code to be organized that way, IMHO.

A plane is a plane, a pipe is a pipe. IMO you're trying to make it more confusing by mixing up the two.

I think that goes against your original argument to remove the plane-

Quoted 1 line

plane assignment for everything except for primary planes.

Anyway, your argumentation is very short and dismissive, it's hard to understand what exactly you are thinking and try to move the discussion forward.

I suppose we'll just have to agree to disagree here. In one solution we create an inconsistency where the plane struct has a field that's only applicable and can only be used to some specific planes (even though "every plane is a plane"). In the other solution we create the inconsistency where the crtc<->plane connection is assigned in the way not chosen by the hardware and this may be a problem if we ever get to implement the plane assignment flexibility that's allowed by the hardware. Maybe having a 3rd opinion here would help.

Quoted 32 lines
Quoted 8 lines

Besides, I
think our code organizations should always better fit the new hardware,
since otherwise we'll make i915.ko development even harder than it is
for new contributors/employees.

If you don't mix planes and pipes there can't be any confusion.

Quoted 13 lines

(And when I see those specs and realize how different the HW was, then
I remember that in order to explain to the new people why some things
are the way they are in our code I have to explain how the HW was 10
years ago, I start thinking again that maybe we should just have i915-
old.ko and i915-new.ko, since either we make our abstractions/design
fit one thing or we make it fit another...)

From the register POV hw was almost identical up to BDW at least. It's
just a few bits (the pipe selector) that vanished from the registers. SKL+ is a little more different but still the registers even live in the
same address.

Quoted 228 lines

Also given what recent history has shown us, I wouldn't be at all surprised if we would go back to a flexible plane<->pipe assignment in the hardware at some point in the future. A lot of the other features that were present in old hardware has been making a comeback in recent years.

Quoted 221 lines
Quoted 221 lines
Quoted 220 lines

The crtc struct already includes
some fields that are specific to primary planes, so I think it's a
good
place. Or we could create a new class: struct intel_primary_plane {
struct intel_plane base; enum plane legacy_plane };

Following is a patch suggestion (probably impossible to apply due
to my
editor breaking long lines). Any arguments against it?

--8<----------------------------------------------------------

drivers/gpu/drm/i915/intel_display.c +0 -2
index bc1af87..c54b1a7 100644
@@ -15065,14 +15065,6 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		state->scaler_id = -1;
  	}
  	primary->pipe = pipe;
-	/*
-	 * On gen2/3 only plane A can do FBC, but the panel

fitter
and
LVDS

drivers/gpu/drm/i915/intel_display.c +0 -1
-	 * port is hooked to pipe B. Hence we want plane A

feeding
pipe B.

drivers/gpu/drm/i915/intel_display.c +0 -5
-	 */
-	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
-		primary->plane = (enum plane) !pipe;
-	else
-		primary->plane = (enum plane) pipe;

  primary->id = PLANE_PRIMARY; primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe); primary->check_plane = intel_check_primary_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15120,7 +15112,7 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  					       0,
 &intel_plane_funcs,

         intel_primary_f orma
ts,
num_formats,
         DRM_PLANE_TYPE_ PRIM
ARY,

drivers/gpu/drm/i915/intel_display.c +0 -1
-					       "plane %c",

plane_name(primary->plane));

drivers/gpu/drm/i915/intel_display.c +1 -0
+					       "plane %c",

pipe_name(pipe)); /* FIXME */
  if (ret)
  goto fail;

drivers/gpu/drm/i915/intel_display.c +0 -1
@@ -15272,7 +15264,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;

  cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe); cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15390,7 +15381,14 @@ static int intel_crtc_init(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		goto fail;


  intel_crtc->pipe = pipe;

drivers/gpu/drm/i915/intel_display.c +2 -1
-	intel_crtc->plane = primary->plane;
+	/*
+	 * On gen2/3 only plane A can do FBC, but the panel

fitter
and
LVDS

drivers/gpu/drm/i915/intel_display.c +1 -0
+	 * port is hooked to pipe B. Hence we want plane A

feeding
pipe B.

drivers/gpu/drm/i915/intel_display.c +5 -0
+	 */
+	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
+		intel_crtc->plane = (enum plane) !pipe;
+	else
+		intel_crtc->plane = (enum plane) pipe;


  intel_crtc->cursor_base = ~0;
  intel_crtc->cursor_cntl = ~0;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16866,11 +16864,11 @@ void i915_redisable_vga(struct
 drm_i915_private *dev_priv)
  	intel_display_power_put(dev_priv, POWER_DOMAIN_VGA);
  }

drivers/gpu/drm/i915/intel_display.c +1 -1
-static bool primary_get_hw_state(struct intel_plane *plane)
+static bool primary_get_hw_state(struct intel_crtc *crtc)

 {

drivers/gpu/drm/i915/intel_display.c +0 -1
-	struct drm_i915_private *dev_priv = to_i915(plane-
Quoted 2 lines

base.dev);

drivers/gpu/drm/i915/intel_display.c +1 -0
+	struct drm_i915_private *dev_priv = to_i915(crtc-
Quoted 2 lines

base.dev);

drivers/gpu/drm/i915/intel_display.c +0 -1
-	return I915_READ(DSPCNTR(plane->plane)) &

DISPLAY_PLANE_ENABLE;

drivers/gpu/drm/i915/intel_display.c +1 -0
+	return I915_READ(DSPCNTR(crtc->plane)) &

DISPLAY_PLANE_ENABLE;
 }

 /* FIXME read out full plane state for all planes */

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16880,8 +16878,7 @@ static void readout_plane_state(struct
 intel_crtc *crtc)

  struct intel_plane_state *plane_state = to_intel_plane_state(primary->state);

drivers/gpu/drm/i915/intel_display.c +1 -2
-	plane_state->base.visible = crtc->active &&
-		primary_get_hw_state(to_intel_plane(primary));
+	plane_state->base.visible = crtc->active &&

primary_get_hw_state(crtc);

  if (plane_state->base.visible) crtc->base.state->plane_mask |= 1 << drm_plane_index(primary);

drivers/gpu/drm/i915/intel_drv.h +0 -0
index 362f698..b2bdd49 100644
@@ -767,7 +767,6 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +0 -1
-	u8 plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5..1044095 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct

drm_i915_private
*dev_priv,
  }

  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe,
plane);
  intel_plane->check_plane = intel_check_sprite_plane;

--8<----------------------------------------------------------

Quoted 54 lines

---
 drivers/gpu/drm/i915/intel_display.c | 1 -
 drivers/gpu/drm/i915/intel_drv.h     | 2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 1 -

 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index b6d5d5e5cc99..f180f14fcf3a 100644
@@ -15188,7 +15188,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;

  cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe); cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_drv.h +0 -0
index c1b245853ba9..d14718e09911 100644
@@ -767,7 +767,7 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +1 -1
-	u8 plane;
+	enum plane plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5a9305..1044095d0084 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct
 drm_i915_private *dev_priv,
  	}


  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane); intel_plane->check_plane = intel_check_sprite_plane;

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#16 lore raw

Re: [PATCH 8/9] drm/i915: Don't populate plane->plane for cursors and sprites

Quoted 66 lines · Paulo Zanoni

Em Qui, 2016-12-15 às 21:59 +0200, Ville Syrjälä escreveu:

Quoted 52 lines · Paulo Zanoni
Quoted 35 lines

Em Qui, 2016-12-15 às 21:11 +0200, Ville Syrjälä escreveu:

Quoted 28 lines · Paulo Zanoni
Quoted 19 lines

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] m
escreveu:

Quoted 5 lines

From: Ville Syrjälä <[email protected]>

Quoted 8 lines

With plane->plane now purely reserved for the primary planes, let's
not even populate it for cursors and sprites. Let's switch the
type
to enum plane as well since it's no longer being abused for anything
else.

Quoted 6 lines

Since it's a primary plane thing, I think it makes more sense to
just
leave it at struct intel_crtc instead of having a field that's unused
and doesn't make sense in some cases.

Quoted 4 lines

Primary plane aren't really primary planes on old platforms though.
That's just a software concept that has no bearing on the hardware.

Quoted 6 lines

Please explain more since that's not my understanding. I just opened
the gen 2 and 3 spec docs and they do contain tons of "primary plane"
references. I know that the hardware is a little more flexible there,

Yep. Planes can be moved to any pipe in general.

Quoted 3 lines

but as far as I understand we don't even implement that.

Not at the moment. But I have plans...

Quoted 2 lines
Quoted 6 lines
Quoted 4 lines

Besides, both
our driver and our API do have the concept of a primary plane, so it
makes sense for the code to be organized that way, IMHO.

A plane is a plane, a pipe is a pipe. IMO you're trying to make it more confusing by mixing up the two.

I think that goes against your original argument to remove the plane-

Quoted 2 lines

plane assignment for everything except for primary planes.

Anyway, your argumentation is very short and dismissive, it's hard to understand what exactly you are thinking and try to move the discussion forward.

Quoted 8 lines

I suppose we'll just have to agree to disagree here. In one solution we create an inconsistency where the plane struct has a field that's only applicable and can only be used to some specific planes (even though "every plane is a plane"). In the other solution we create the inconsistency where the crtc<->plane connection is assigned in the way not chosen by the hardware and this may be a problem if we ever get to implement the plane assignment flexibility that's allowed by the hardware. Maybe having a 3rd opinion here would help.

I find the two plane fields in struct intel_plane a bit confusing, but I don't think the right solution is to leave that in intel_crtc. If I understand correctly, we have a problem of uniquely identifying a plane, since that takes different forms in different platforms. Neither of the generically named enums, enum plane and enum plane_id, is sufficiently generic.

Would it make sense to turn things up-side down? Now we are trying to make a crtc be able to find the proper registers for a plane. Instead we could just not do it and define everything in terms of functions that take planes. Then we could hide the details of mapping some bit of information in intel_plane to the appropriate registers in platform-dependent vfuncs. And perhaps give those enums a platform-dependent name, i.e., enum i8xx_plane_id, enum skl_plane_id, etc.

Anyway, I haven't looked much into it, so just ignore me if I'm way off.

Ander

Quoted 261 lines
Quoted 261 lines
Quoted 10 lines

Besides, I
think our code organizations should always better fit the new hardware,
since otherwise we'll make i915.ko development even harder than it is
for new contributors/employees.

If you don't mix planes and pipes there can't be any confusion.

Quoted 14 lines

(And when I see those specs and realize how different the HW was, then
I remember that in order to explain to the new people why some things
are the way they are in our code I have to explain how the HW was 10
years ago, I start thinking again that maybe we should just have i915-
old.ko and i915-new.ko, since either we make our abstractions/design
fit one thing or we make it fit another...)

From the register POV hw was almost identical up to BDW at least. It's
just a few bits (the pipe selector) that vanished from the registers. SKL+ is a little more different but still the registers even live in the
same address.

Also given what recent history has shown us, I wouldn't be at all surprised if we would go back to a flexible plane<->pipe assignment in the hardware at some point in the future. A lot of the other features that were present in old hardware has been making a comeback in recent years.

Quoted 222 lines
Quoted 222 lines
Quoted 222 lines

The crtc struct already includes
some fields that are specific to primary planes, so I think it's a
good
place. Or we could create a new class: struct intel_primary_plane {
struct intel_plane base; enum plane legacy_plane };

Following is a patch suggestion (probably impossible to apply due
to my
editor breaking long lines). Any arguments against it?

--8<----------------------------------------------------------

drivers/gpu/drm/i915/intel_display.c +0 -2
index bc1af87..c54b1a7 100644
@@ -15065,14 +15065,6 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		state->scaler_id = -1;
  	}
  	primary->pipe = pipe;
-	/*
-	 * On gen2/3 only plane A can do FBC, but the panel

fitter
and
LVDS

drivers/gpu/drm/i915/intel_display.c +0 -1
-	 * port is hooked to pipe B. Hence we want plane A

feeding
pipe B.

drivers/gpu/drm/i915/intel_display.c +0 -5
-	 */
-	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
-		primary->plane = (enum plane) !pipe;
-	else
-		primary->plane = (enum plane) pipe;

  primary->id = PLANE_PRIMARY; primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe); primary->check_plane = intel_check_primary_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15120,7 +15112,7 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  					       0,
 &intel_plane_funcs,

         intel_primary_f orma
ts,
num_formats,
         DRM_PLANE_TYPE_ PRIM
ARY,

drivers/gpu/drm/i915/intel_display.c +0 -1
-					       "plane %c",

plane_name(primary->plane));

drivers/gpu/drm/i915/intel_display.c +1 -0
+					       "plane %c",

pipe_name(pipe)); /* FIXME */
  if (ret)
  goto fail;

drivers/gpu/drm/i915/intel_display.c +0 -1
@@ -15272,7 +15264,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;

  cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe); cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15390,7 +15381,14 @@ static int intel_crtc_init(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		goto fail;


  intel_crtc->pipe = pipe;

drivers/gpu/drm/i915/intel_display.c +2 -1
-	intel_crtc->plane = primary->plane;
+	/*
+	 * On gen2/3 only plane A can do FBC, but the panel

fitter
and
LVDS

drivers/gpu/drm/i915/intel_display.c +1 -0
+	 * port is hooked to pipe B. Hence we want plane A

feeding
pipe B.

drivers/gpu/drm/i915/intel_display.c +5 -0
+	 */
+	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
+		intel_crtc->plane = (enum plane) !pipe;
+	else
+		intel_crtc->plane = (enum plane) pipe;


  intel_crtc->cursor_base = ~0;
  intel_crtc->cursor_cntl = ~0;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16866,11 +16864,11 @@ void i915_redisable_vga(struct
 drm_i915_private *dev_priv)
  	intel_display_power_put(dev_priv, POWER_DOMAIN_VGA);
  }

drivers/gpu/drm/i915/intel_display.c +1 -1
-static bool primary_get_hw_state(struct intel_plane *plane)
+static bool primary_get_hw_state(struct intel_crtc *crtc)

 {

drivers/gpu/drm/i915/intel_display.c +0 -1
-	struct drm_i915_private *dev_priv = to_i915(plane-
Quoted 3 lines

base.dev);

drivers/gpu/drm/i915/intel_display.c +1 -0
+	struct drm_i915_private *dev_priv = to_i915(crtc-
Quoted 3 lines

base.dev);

drivers/gpu/drm/i915/intel_display.c +0 -1
-	return I915_READ(DSPCNTR(plane->plane)) &

DISPLAY_PLANE_ENABLE;

drivers/gpu/drm/i915/intel_display.c +1 -0
+	return I915_READ(DSPCNTR(crtc->plane)) &

DISPLAY_PLANE_ENABLE;
 }

 /* FIXME read out full plane state for all planes */

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16880,8 +16878,7 @@ static void readout_plane_state(struct
 intel_crtc *crtc)

  struct intel_plane_state *plane_state = to_intel_plane_state(primary->state);

drivers/gpu/drm/i915/intel_display.c +1 -2
-	plane_state->base.visible = crtc->active &&
-		primary_get_hw_state(to_intel_plane(primary));
+	plane_state->base.visible = crtc->active &&

primary_get_hw_state(crtc);

  if (plane_state->base.visible) crtc->base.state->plane_mask |= 1 << drm_plane_index(primary);

drivers/gpu/drm/i915/intel_drv.h +0 -0
index 362f698..b2bdd49 100644
@@ -767,7 +767,6 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +0 -1
-	u8 plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5..1044095 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct

drm_i915_private
*dev_priv,
  }

  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe,
plane);
  intel_plane->check_plane = intel_check_sprite_plane;

--8<----------------------------------------------------------

Quoted 51 lines

---
 drivers/gpu/drm/i915/intel_display.c | 1 -
 drivers/gpu/drm/i915/intel_drv.h     | 2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 1 -

 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index b6d5d5e5cc99..f180f14fcf3a 100644
@@ -15188,7 +15188,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;

  cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe); cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_drv.h +0 -0
index c1b245853ba9..d14718e09911 100644
@@ -767,7 +767,7 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +1 -1
-	u8 plane;
+	enum plane plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5a9305..1044095d0084 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct
 drm_i915_private *dev_priv,
  	}


  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane); intel_plane->check_plane = intel_check_sprite_plane;

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#17 lore raw

Re: [PATCH 8/9] drm/i915: Don't populate plane->plane for cursors and sprites

In reply to Ville Syrjälä
Quoted 30 lines · Ville Syrjälä
Quoted 22 lines · Paulo Zanoni

Em Qui, 2016-12-15 às 21:11 +0200, Ville Syrjälä escreveu:

Quoted 21 lines · Paulo Zanoni
Quoted 19 lines

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] escreveu:

Quoted 10 lines

From: Ville Syrjälä <[email protected]>

With plane->plane now purely reserved for the primary planes, let's
not even populate it for cursors and sprites. Let's switch the type
to enum plane as well since it's no longer being abused for anything
else.

Since it's a primary plane thing, I think it makes more sense to just
leave it at struct intel_crtc instead of having a field that's unused
and doesn't make sense in some cases.

Quoted 6 lines
Quoted 2 lines

Primary plane aren't really primary planes on old platforms though. That's just a software concept that has no bearing on the hardware.

Please explain more since that's not my understanding. I just opened the gen 2 and 3 spec docs and they do contain tons of "primary plane" references. I know that the hardware is a little more flexible there,

Quoted 5 lines

Yep. Planes can be moved to any pipe in general.

Quoted 1 line

but as far as I understand we don't even implement that.

Not at the moment. But I have plans...

I'm not even sure where to find bspecs for the really old platforms...how flexible were those primary planes? Can we drive both "primary" planes at the same time on a single CRTC if we're not using the second pipe? If not, is there some other benefit we get from not enforcing a fixed pipe-plane association?

Matt

Quoted 247 lines
Quoted 4 lines

Besides, both
our driver and our API do have the concept of a primary plane, so it makes sense for the code to be organized that way, IMHO.

A plane is a plane, a pipe is a pipe. IMO you're trying to make it more confusing by mixing up the two.

Quoted 4 lines

Besides, I
think our code organizations should always better fit the new hardware, since otherwise we'll make i915.ko development even harder than it is for new contributors/employees.

If you don't mix planes and pipes there can't be any confusion.

Quoted 7 lines

(And when I see those specs and realize how different the HW was, then I remember that in order to explain to the new people why some things are the way they are in our code I have to explain how the HW was 10 years ago, I start thinking again that maybe we should just have i915- old.ko and i915-new.ko, since either we make our abstractions/design fit one thing or we make it fit another...)

From the register POV hw was almost identical up to BDW at least. It's just a few bits (the pipe selector) that vanished from the registers. SKL+ is a little more different but still the registers even live in the same address.

Also given what recent history has shown us, I wouldn't be at all surprised if we would go back to a flexible plane<->pipe assignment in the hardware at some point in the future. A lot of the other features that were present in old hardware has been making a comeback in recent years.

Quoted 205 lines
Quoted 205 lines
Quoted 204 lines

The crtc struct already includes
some fields that are specific to primary planes, so I think it's a good
place. Or we could create a new class: struct intel_primary_plane { struct intel_plane base; enum plane legacy_plane };

Following is a patch suggestion (probably impossible to apply due to my
editor breaking long lines). Any arguments against it?

--8<----------------------------------------------------------

drivers/gpu/drm/i915/intel_display.c +0 -2
index bc1af87..c54b1a7 100644
@@ -15065,14 +15065,6 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		state->scaler_id = -1;
  	}
  	primary->pipe = pipe;
-	/*
-	 * On gen2/3 only plane A can do FBC, but the panel fitter

and
LVDS

drivers/gpu/drm/i915/intel_display.c +0 -1
-	 * port is hooked to pipe B. Hence we want plane A feeding

pipe B.

drivers/gpu/drm/i915/intel_display.c +0 -5
-	 */
-	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
-		primary->plane = (enum plane) !pipe;
-	else
-		primary->plane = (enum plane) pipe;

  primary->id = PLANE_PRIMARY; primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe); primary->check_plane = intel_check_primary_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15120,7 +15112,7 @@ intel_primary_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  					       0,
 &intel_plane_funcs,

         intel_primary_forma ts,
num_formats,
         DRM_PLANE_TYPE_PRIM ARY,

drivers/gpu/drm/i915/intel_display.c +0 -1
-					       "plane %c",

plane_name(primary->plane));

drivers/gpu/drm/i915/intel_display.c +1 -0
+					       "plane %c",

pipe_name(pipe)); /* FIXME */
  if (ret)
  goto fail;

drivers/gpu/drm/i915/intel_display.c +0 -1
@@ -15272,7 +15264,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;
  	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);

  cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -15390,7 +15381,14 @@ static int intel_crtc_init(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  		goto fail;


  intel_crtc->pipe = pipe;

drivers/gpu/drm/i915/intel_display.c +2 -1
-	intel_crtc->plane = primary->plane;
+	/*
+	 * On gen2/3 only plane A can do FBC, but the panel fitter

and
LVDS

drivers/gpu/drm/i915/intel_display.c +1 -0
+	 * port is hooked to pipe B. Hence we want plane A feeding

pipe B.

drivers/gpu/drm/i915/intel_display.c +5 -0
+	 */
+	if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) < 4)
+		intel_crtc->plane = (enum plane) !pipe;
+	else
+		intel_crtc->plane = (enum plane) pipe;


  intel_crtc->cursor_base = ~0;
  intel_crtc->cursor_cntl = ~0;

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16866,11 +16864,11 @@ void i915_redisable_vga(struct
 drm_i915_private *dev_priv)
  	intel_display_power_put(dev_priv, POWER_DOMAIN_VGA);
  }

drivers/gpu/drm/i915/intel_display.c +1 -1
-static bool primary_get_hw_state(struct intel_plane *plane)
+static bool primary_get_hw_state(struct intel_crtc *crtc)

 {

drivers/gpu/drm/i915/intel_display.c +0 -1
-	struct drm_i915_private *dev_priv = to_i915(plane-
Quoted 1 line

base.dev);

drivers/gpu/drm/i915/intel_display.c +1 -0
+	struct drm_i915_private *dev_priv = to_i915(crtc-
Quoted 1 line

base.dev);

drivers/gpu/drm/i915/intel_display.c +0 -1
-	return I915_READ(DSPCNTR(plane->plane)) &

DISPLAY_PLANE_ENABLE;

drivers/gpu/drm/i915/intel_display.c +1 -0
+	return I915_READ(DSPCNTR(crtc->plane)) &

DISPLAY_PLANE_ENABLE;
 }

 /* FIXME read out full plane state for all planes */

drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -16880,8 +16878,7 @@ static void readout_plane_state(struct
 intel_crtc *crtc)

  struct intel_plane_state *plane_state = to_intel_plane_state(primary->state);

drivers/gpu/drm/i915/intel_display.c +1 -2
-	plane_state->base.visible = crtc->active &&
-		primary_get_hw_state(to_intel_plane(primary));
+	plane_state->base.visible = crtc->active &&

primary_get_hw_state(crtc);

  if (plane_state->base.visible) crtc->base.state->plane_mask |= 1 << drm_plane_index(primary);

drivers/gpu/drm/i915/intel_drv.h +0 -0
index 362f698..b2bdd49 100644
@@ -767,7 +767,6 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +0 -1
-	u8 plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5..1044095 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct

drm_i915_private
*dev_priv,
  }

  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe,
plane);
  intel_plane->check_plane = intel_check_sprite_plane;

--8<----------------------------------------------------------

Quoted 53 lines

---
 drivers/gpu/drm/i915/intel_display.c | 1 -
 drivers/gpu/drm/i915/intel_drv.h     | 2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 1 -

 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index b6d5d5e5cc99..f180f14fcf3a 100644
@@ -15188,7 +15188,6 @@ intel_cursor_plane_create(struct
 drm_i915_private *dev_priv, enum pipe pipe)
  	cursor->can_scale = false;
  	cursor->max_downscale = 1;
  	cursor->pipe = pipe;
-	cursor->plane = pipe;
  	cursor->id = PLANE_CURSOR;

  cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe); cursor->check_plane = intel_check_cursor_plane;

drivers/gpu/drm/i915/intel_drv.h +0 -0
index c1b245853ba9..d14718e09911 100644
@@ -767,7 +767,7 @@ struct intel_plane_wm_parameters {


 struct intel_plane {
  struct drm_plane base;

drivers/gpu/drm/i915/intel_drv.h +1 -1
-	u8 plane;
+	enum plane plane;

  enum plane_id id;
  enum pipe pipe;
  bool can_scale;

drivers/gpu/drm/i915/intel_sprite.c +0 -0
index 63154a5a9305..1044095d0084 100644
@@ -1111,7 +1111,6 @@ intel_sprite_plane_create(struct
 drm_i915_private *dev_priv,
  	}


  intel_plane->pipe = pipe;

drivers/gpu/drm/i915/intel_sprite.c +0 -1
-	intel_plane->plane = plane;

  intel_plane->id = PLANE_SPRITE0 + plane; intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane); intel_plane->check_plane = intel_check_sprite_plane;

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 9 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#18 lore raw

Re: [PATCH 8/9] drm/i915: Don't populate plane->plane for cursors and sprites

Quoted 33 lines · Matt Roper
Quoted 32 lines · Ville Syrjälä
Quoted 22 lines · Paulo Zanoni

Em Qui, 2016-12-15 às 21:11 +0200, Ville Syrjälä escreveu:

Quoted 21 lines · Paulo Zanoni
Quoted 19 lines

Em Ter, 2016-11-22 às 18:02 +0200, [email protected] escreveu:

Quoted 10 lines

From: Ville Syrjälä <[email protected]>

With plane->plane now purely reserved for the primary planes, let's
not even populate it for cursors and sprites. Let's switch the type
to enum plane as well since it's no longer being abused for anything
else.

Since it's a primary plane thing, I think it makes more sense to just
leave it at struct intel_crtc instead of having a field that's unused
and doesn't make sense in some cases.

Quoted 6 lines
Quoted 2 lines

Primary plane aren't really primary planes on old platforms though. That's just a software concept that has no bearing on the hardware.

Please explain more since that's not my understanding. I just opened the gen 2 and 3 spec docs and they do contain tons of "primary plane" references. I know that the hardware is a little more flexible there,

Yep. Planes can be moved to any pipe in general.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

but as far as I understand we don't even implement that.

Not at the moment. But I have plans...

I'm not even sure where to find bspecs for the really old platforms...how flexible were those primary planes? Can we drive both "primary" planes at the same time on a single CRTC if we're not using the second pipe?

There are three "primary" planes, two cursors, and one video overlay. Any one can be assigned to either pipe more or less freely (some restrctions do apply). The planes aren't uniform (not even the "primary" planes) and instead have different capabilities between them.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

PATCH v2 9/9 drm/i915: Rename the local 'plane' variable to 'plane_id' in primary plane code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Now we've rename the local plane id variable as 'plane_id' everywhere except the pre-SKL primary plane code. Let's do the rename there as well so that we'll free up the name 'plane' for use with struct intel_plane*.

---
 drivers/gpu/drm/i915/intel_display.c | 57 +++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 30 deletions(-)
drivers/gpu/drm/i915/intel_display.c +27 -30
index f180f14fcf3a..a9b88749e897 100644
@@ -3001,10 +3001,9 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
 	struct drm_i915_private *dev_priv = to_i915(primary->dev);
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc);
 	struct drm_framebuffer *fb = plane_state->base.fb;
-	int plane = intel_crtc->plane;
+	enum plane plane_id = to_intel_plane(primary)->plane;
 	u32 linear_offset;
 	u32 dspcntr;
-	i915_reg_t reg = DSPCNTR(plane);
 	unsigned int rotation = plane_state->base.rotation;
 	int x = plane_state->base.src.x1 >> 16;
 	int y = plane_state->base.src.y1 >> 16;
@@ -3020,16 +3019,16 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
 		/* pipesrc and dspsize control the size that is scaled from,
 		 * which should always be the user's requested size.
 		 */
-		I915_WRITE(DSPSIZE(plane),
+		I915_WRITE(DSPSIZE(plane_id),
 			   ((crtc_state->pipe_src_h - 1) << 16) |
 			   (crtc_state->pipe_src_w - 1));
-		I915_WRITE(DSPPOS(plane), 0);
-	} else if (IS_CHERRYVIEW(dev_priv) && plane == PLANE_B) {
-		I915_WRITE(PRIMSIZE(plane),
+		I915_WRITE(DSPPOS(plane_id), 0);
+	} else if (IS_CHERRYVIEW(dev_priv) && plane_id == PLANE_B) {
+		I915_WRITE(PRIMSIZE(plane_id),
 			   ((crtc_state->pipe_src_h - 1) << 16) |
 			   (crtc_state->pipe_src_w - 1));
-		I915_WRITE(PRIMPOS(plane), 0);
-		I915_WRITE(PRIMCNSTALPHA(plane), 0);
+		I915_WRITE(PRIMPOS(plane_id), 0);
+		I915_WRITE(PRIMCNSTALPHA(plane_id), 0);
 	}
 
 	switch (fb->pixel_format) {
@@ -3092,21 +3091,21 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
 	intel_crtc->adjusted_x = x;
 	intel_crtc->adjusted_y = y;
 
-	I915_WRITE(reg, dspcntr);
+	I915_WRITE(DSPCNTR(plane_id), dspcntr);
 
-	I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
+	I915_WRITE(DSPSTRIDE(plane_id), fb->pitches[0]);
 	if (INTEL_GEN(dev_priv) >= 4) {
-		I915_WRITE(DSPSURF(plane),
+		I915_WRITE(DSPSURF(plane_id),
 			   intel_fb_gtt_offset(fb, rotation) +
 			   intel_crtc->dspaddr_offset);
-		I915_WRITE(DSPTILEOFF(plane), (y << 16) | x);
-		I915_WRITE(DSPLINOFF(plane), linear_offset);
+		I915_WRITE(DSPTILEOFF(plane_id), (y << 16) | x);
+		I915_WRITE(DSPLINOFF(plane_id), linear_offset);
 	} else {
-		I915_WRITE(DSPADDR(plane),
+		I915_WRITE(DSPADDR(plane_id),
 			   intel_fb_gtt_offset(fb, rotation) +
 			   intel_crtc->dspaddr_offset);
 	}
-	POSTING_READ(reg);
+	POSTING_READ(DSPCNTR(plane_id));
 }
 
 static void i9xx_disable_primary_plane(struct drm_plane *primary,
@@ -3114,15 +3113,14 @@ static void i9xx_disable_primary_plane(struct drm_plane *primary,
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	int plane = intel_crtc->plane;
+	enum plane plane_id = to_intel_plane(primary)->plane;
 
-	I915_WRITE(DSPCNTR(plane), 0);
+	I915_WRITE(DSPCNTR(plane_id), 0);
 	if (INTEL_INFO(dev_priv)->gen >= 4)
-		I915_WRITE(DSPSURF(plane), 0);
+		I915_WRITE(DSPSURF(plane_id), 0);
 	else
-		I915_WRITE(DSPADDR(plane), 0);
-	POSTING_READ(DSPCNTR(plane));
+		I915_WRITE(DSPADDR(plane_id), 0);
+	POSTING_READ(DSPCNTR(plane_id));
 }
 
 static void ironlake_update_primary_plane(struct drm_plane *primary,
@@ -3133,10 +3131,9 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc);
 	struct drm_framebuffer *fb = plane_state->base.fb;
-	int plane = intel_crtc->plane;
+	enum plane plane_id = to_intel_plane(primary)->plane;
 	u32 linear_offset;
 	u32 dspcntr;
-	i915_reg_t reg = DSPCNTR(plane);
 	unsigned int rotation = plane_state->base.rotation;
 	int x = plane_state->base.src.x1 >> 16;
 	int y = plane_state->base.src.y1 >> 16;
@@ -3196,19 +3193,19 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
 	intel_crtc->adjusted_x = x;
 	intel_crtc->adjusted_y = y;
 
-	I915_WRITE(reg, dspcntr);
+	I915_WRITE(DSPCNTR(plane_id), dspcntr);
 
-	I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
-	I915_WRITE(DSPSURF(plane),
+	I915_WRITE(DSPSTRIDE(plane_id), fb->pitches[0]);
+	I915_WRITE(DSPSURF(plane_id),
 		   intel_fb_gtt_offset(fb, rotation) +
 		   intel_crtc->dspaddr_offset);
 	if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
-		I915_WRITE(DSPOFFSET(plane), (y << 16) | x);
+		I915_WRITE(DSPOFFSET(plane_id), (y << 16) | x);
 	} else {
-		I915_WRITE(DSPTILEOFF(plane), (y << 16) | x);
-		I915_WRITE(DSPLINOFF(plane), linear_offset);
+		I915_WRITE(DSPTILEOFF(plane_id), (y << 16) | x);
+		I915_WRITE(DSPLINOFF(plane_id), linear_offset);
 	}
-	POSTING_READ(reg);
+	POSTING_READ(DSPCNTR(plane_id));
 }
 
 u32 intel_fb_stride_alignment(const struct drm_i915_private *dev_priv,
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#20 lore raw

✓ Fi.CI.BAT: success for drm/i915: Add a per-pipe plane identifier enum (rev5)

In reply to [email protected]
== Series Details ==

== Series Details ==

Series: drm/i915: Add a per-pipe plane identifier enum (rev5)
URL : https://patchwork.freedesktop.org/series/14978/
State : success

== Summary ==

Series 14978v5 drm/i915: Add a per-pipe plane identifier enum
https://patchwork.freedesktop.org/api/1.0/series/14978/revisions/5/mbox/

Test drv_module_reload_basic:

                dmesg-warn -> PASS       (fi-skl-6770hq)
fi-bdw-5557u     total:244  pass:229  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:244  pass:204  dwarn:0   dfail:0   fail:0   skip:40 
fi-bxt-t5700     total:244  pass:216  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-j1900     total:244  pass:216  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-n2820     total:244  pass:212  dwarn:0   dfail:0   fail:0   skip:32 
fi-hsw-4770      total:244  pass:224  dwarn:0   dfail:0   fail:0   skip:20 
fi-hsw-4770r     total:244  pass:224  dwarn:0   dfail:0   fail:0   skip:20 
fi-ilk-650       total:244  pass:191  dwarn:0   dfail:0   fail:0   skip:53 
fi-ivb-3520m     total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-ivb-3770      total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-kbl-7200u     total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-skl-6260u     total:244  pass:230  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:244  pass:223  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6700k     total:244  pass:222  dwarn:1   dfail:0   fail:0   skip:21 
fi-skl-6770hq    total:244  pass:230  dwarn:0   dfail:0   fail:0   skip:14 
fi-snb-2520m     total:244  pass:212  dwarn:0   dfail:0   fail:0   skip:32 
fi-snb-2600      total:244  pass:211  dwarn:0   dfail:0   fail:0   skip:33 

eeec5e7742b23082dd20523c8baa08fe495175e4 drm-intel-nightly: 2016y-11m-21d-18h-22m-22s UTC integration manifest dc45b91 drm/i915: Rename the local 'plane' variable to 'plane_id' in primary plane code 3e642c7 drm/i915: Don't populate plane->plane for cursors and sprites
fa55355 drm/i915: s/plane/plane_id/ in skl+ plane register defines
87d3a43 drm/i915: Use enum plane_id in VLV/CHV wm code
1e0e553 drm/i915: Use enum plane_id in VLV/CHV sprite code
b861dac drm/i915: Use enum plane_id in SKL plane code
2b8c0dd drm/i915: Use enum plane_id in SKL wm code
baf65ea drm/i915: Add crtc->plane_ids_mask
0d733576 drm/i915: Add per-pipe plane identifier

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3082/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#21 lore raw
In reply to [email protected]
Quoted 12 lines · On Tue, Nov 22, 2016 at 06:01:55PM +0200, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

I ended up tweaking quite a few of the patches (and even adding a new one) based on Paulo's review, so figured I'd repost the entire thing.

I didn't do the _ID_ rename thing, at least not yet. I'll have to think about it more if I could come up with some nice way to deal with the per-pipe id vs. the A/B/C plane id.

Anyways, enough of these got r-bs so that I can at least move forward with VLV/CHV watermark rewrite #4 now.

Quoted 7 lines

Ville Syrjälä (9):
drm/i915: Add per-pipe plane identifier drm/i915: Add crtc->plane_ids_mask drm/i915: Use enum plane_id in SKL wm code drm/i915: Use enum plane_id in SKL plane code drm/i915: Use enum plane_id in VLV/CHV sprite code drm/i915: Use enum plane_id in VLV/CHV wm code

Pushed upto here. Thanks for the reviews.

Quoted 15 lines

drm/i915: s/plane/plane_id/ in skl+ plane register defines drm/i915: Don't populate plane->plane for cursors and sprites drm/i915: Rename the local 'plane' variable to 'plane_id' in primary
plane code

 drivers/gpu/drm/i915/i915_drv.h      |  30 ++++-
 drivers/gpu/drm/i915/i915_reg.h      | 104 +++++++-------
 drivers/gpu/drm/i915/intel_display.c |  96 ++++++-------
 drivers/gpu/drm/i915/intel_drv.h     |   6 +-
 drivers/gpu/drm/i915/intel_pm.c      | 253 ++++++++++++++++-------------------
 drivers/gpu/drm/i915/intel_sprite.c  | 118 ++++++++--------
 6 files changed, 304 insertions(+), 303 deletions(-)
Signature · 1 line
2.7.4
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx