Skip to contentSkip to conversation

drm/i915: Adding NV12 for skylake display

PATCH New Chandra Konduru 1 participant 17 messages Sep 1, 2015

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

cover drm/i915: Adding NV12 for skylake display

This patch series is adding initial NV12 support for Skylake display after rebasing on latest drm-intel-nightly. Earlier I had two patch series one for 0/180 and another for 90/270. Some of the patches were already merged. This is combined series to support 0/90/180/270 and removing the ones that are already merged.

Feature is tested with igt/kms_nv12 testcases.
Feature is unit tested for linear/X/Y formats in 0, 90, 180, 270 orientations with combinations of 1 or 2 planes enabled along with scaling. Also negatively tested for enabling NV12 on unsupported plane.

The last patch in this series depends on Tvrtko's GEM remapping for NV12 format patch series.

First two patches fixing couple things in dbuf logic to allocate correct min number of dbuf blocks and use correct source width and height in 90/270 rotation cases.

Update from last rev:
Resolved Daniel's review feedback
- Did one WA per commit
- Moved get stepping functions better place
- Added comments

Chandra Konduru (16):
drm/i915: Allocate min dbuf blocks per bspec drm/i915: In DBUF/WM calcs for 90/270, swap w & h drm/i915: Add register definitions for NV12 support drm/i915: Set scaler mode for NV12
drm/i915: Stage scaler request for NV12 as src format drm/i915: Update format_is_yuv() to include NV12 drm/i915: Upscale scaler max scale for NV12. drm/i915: Add NV12 as supported format for primary plane drm/i915: Add NV12 as supported format for sprite plane drm/i915: Add NV12 support to intel_framebuffer_init drm/i915: Add NV12 to primary plane programming. drm/i915: Add NV12 to sprite plane programming. drm/i915: Set initial phase & trip for NV12 scaler drm/i915: skl nv12 wa - disable streamer fix drm/i915: skl nv12 wa - NV12 to RGB switch drm/i915: Add 90/270 rotation for NV12 format.

 drivers/gpu/drm/i915/i915_reg.h      |   47 +++++++
 drivers/gpu/drm/i915/intel_atomic.c  |    5 +-
 drivers/gpu/drm/i915/intel_csr.c     |   29 -----
 drivers/gpu/drm/i915/intel_display.c |  226 ++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/i915/intel_drv.h     |    6 +-
 drivers/gpu/drm/i915/intel_pm.c      |   71 ++++++++++-
 drivers/gpu/drm/i915/intel_sprite.c  |  125 +++++++++++++++----
 7 files changed, 439 insertions(+), 70 deletions(-)
Signature · 6 lines
1.7.9.5

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

PATCH 1/16 drm/i915: Allocate min dbuf blocks per bspec

Properly allocate min blocks per hw requirements.

---
 drivers/gpu/drm/i915/intel_pm.c |   39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +37 -2
index fff0c22..da3046f 100644
@@ -2959,6 +2959,41 @@ skl_get_total_relative_data_rate(struct intel_crtc *intel_crtc,
 	return total_data_rate;
 }
 
+static uint16_t
+skl_dbuf_min_alloc(const struct intel_plane_wm_parameters *p, int y_plane)
+{
+	uint16_t min_alloc;
+
+	/* For packed formats, no y-plane, return 0 */
+	if (y_plane && !p->y_bytes_per_pixel)
+		return 0;
+
+
+	if (p->tiling == I915_FORMAT_MOD_Y_TILED ||
+	    p->tiling == I915_FORMAT_MOD_Yf_TILED) {
+		uint32_t min_scanlines = 8;
+		uint8_t bytes_per_pixel =
+			y_plane ? p->y_bytes_per_pixel : p->bytes_per_pixel;
+
+		switch (bytes_per_pixel) {
+		case 1:
+			min_scanlines = 32;
+			break;
+		case 2:
+			min_scanlines = 16;
+			break;
+		case 8:
+			WARN(1, "Unsupported pixel depth for rotation");
+		}
+		min_alloc = DIV_ROUND_UP((4 * p->horiz_pixels/(y_plane ? 1 : 2) *
+			bytes_per_pixel), 512) * min_scanlines/4 + 3;
+	} else {
+		min_alloc = 8;
+	}
+
+	return min_alloc;
+}
+
 static void
 skl_allocate_pipe_ddb(struct drm_crtc *crtc,
 		      const struct intel_wm_config *config,
@@ -2999,9 +3034,9 @@ skl_allocate_pipe_ddb(struct drm_crtc *crtc,
 		if (!p->enabled)
 			continue;
 
-		minimum[plane] = 8;
+		minimum[plane] = skl_dbuf_min_alloc(p, 0);    /* uv-plane/packed */
 		alloc_size -= minimum[plane];
-		y_minimum[plane] = p->y_bytes_per_pixel ? 8 : 0;
+		y_minimum[plane] = skl_dbuf_min_alloc(p, 1);  /* y-plane */
 		alloc_size -= y_minimum[plane];
 	}
 
Signature · 6 lines
1.7.9.5

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

PATCH 2/16 drm/i915: In DBUF/WM calcs for 90/270, swap w & h

In reply to Chandra Konduru

This patch swaps src width and height for dbuf/wm calculations when rotation is 90/270 as per hw requirements.

---
 drivers/gpu/drm/i915/intel_pm.c |   32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +28 -4
index da3046f..c455946 100644
@@ -3193,6 +3193,8 @@ static void skl_compute_wm_pipe_parameters(struct drm_crtc *crtc,
 	enum pipe pipe = intel_crtc->pipe;
 	struct drm_plane *plane;
 	struct drm_framebuffer *fb;
+	struct intel_plane_state *plane_state;
+	int src_w, src_h;
 	int i = 1; /* Index for sprite planes start */
 
 	p->active = intel_crtc->active;
@@ -3201,6 +3203,7 @@ static void skl_compute_wm_pipe_parameters(struct drm_crtc *crtc,
 		p->pixel_rate = skl_pipe_pixel_rate(intel_crtc->config);
 
 		fb = crtc->primary->state->fb;
+		plane_state = to_intel_plane_state(crtc->primary->state);
 		/* For planar: Bpp is for uv plane, y_Bpp is for y plane */
 		if (fb) {
 			p->plane[0].enabled = true;
@@ -3215,8 +3218,22 @@ static void skl_compute_wm_pipe_parameters(struct drm_crtc *crtc,
 			p->plane[0].y_bytes_per_pixel = 0;
 			p->plane[0].tiling = DRM_FORMAT_MOD_NONE;
 		}
-		p->plane[0].horiz_pixels = intel_crtc->config->pipe_src_w;
-		p->plane[0].vert_pixels = intel_crtc->config->pipe_src_h;
+
+		if (drm_rect_width(&plane_state->src)) {
+			src_w = drm_rect_width(&plane_state->src) >> 16;
+			src_h = drm_rect_height(&plane_state->src) >> 16;
+		} else {
+			src_w = intel_crtc->config->pipe_src_w;
+			src_h = intel_crtc->config->pipe_src_h;
+		}
+
+		if (intel_rotation_90_or_270(crtc->primary->state->rotation)) {
+			p->plane[0].horiz_pixels = src_h;
+			p->plane[0].vert_pixels = src_w;
+		} else {
+			p->plane[0].horiz_pixels = src_w;
+			p->plane[0].vert_pixels = src_h;
+		}
 		p->plane[0].rotation = crtc->primary->state->rotation;
 
 		fb = crtc->cursor->state->fb;
@@ -3750,8 +3767,15 @@ skl_update_sprite_wm(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	intel_plane->wm.enabled = enabled;
 	intel_plane->wm.scaled = scaled;
-	intel_plane->wm.horiz_pixels = sprite_width;
-	intel_plane->wm.vert_pixels = sprite_height;
+
+	if (intel_rotation_90_or_270(plane->state->rotation)) {
+		intel_plane->wm.horiz_pixels = sprite_height;
+		intel_plane->wm.vert_pixels = sprite_width;
+	} else {
+		intel_plane->wm.horiz_pixels = sprite_width;
+		intel_plane->wm.vert_pixels = sprite_height;
+	}
+
 	intel_plane->wm.tiling = DRM_FORMAT_MOD_NONE;
 
 	/* For planar: Bpp is for UV plane, y_Bpp is for Y plane */
Signature · 6 lines
1.7.9.5

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

PATCH 3/16 drm/i915: Add register definitions for NV12 support

In reply to Chandra Konduru

This patch adds register definitions for skylake
display NV12 support.

---
 drivers/gpu/drm/i915/i915_reg.h |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +27 -0
index 1fa0554..c4d732f 100644
@@ -5498,6 +5498,7 @@ enum skl_disp_power_wells {
 #define PS_SCALER_MODE_MASK (3 << 28)
 #define PS_SCALER_MODE_DYN  (0 << 28)
 #define PS_SCALER_MODE_HQ  (1 << 28)
+#define PS_SCALER_MODE_NV12 (2 << 28)
 #define PS_PLANE_SEL_MASK  (7 << 25)
 #define PS_PLANE_SEL(plane) ((plane + 1) << 25)
 #define PS_FILTER_MASK         (3 << 23)
@@ -5601,6 +5602,32 @@ enum skl_disp_power_wells {
 			_ID(id, _PS_ECC_STAT_1A, _PS_ECC_STAT_2A),   \
 			_ID(id, _PS_ECC_STAT_1B, _PS_ECC_STAT_2B)
 
+
+/*
+ * Skylake  NV12 Register
+ */
+#define PLANE_AUX_DIST_1_A		0x701c0
+#define PLANE_AUX_DIST_2_A		0x702c0
+#define PLANE_AUX_DIST_1_B		0x711c0
+#define PLANE_AUX_DIST_2_B		0x712c0
+#define _PLANE_AUX_DIST_1(pipe)	\
+   _PIPE(pipe, PLANE_AUX_DIST_1_A, PLANE_AUX_DIST_1_B)
+#define _PLANE_AUX_DIST_2(pipe)	\
+   _PIPE(pipe, PLANE_AUX_DIST_2_A, PLANE_AUX_DIST_2_B)
+#define PLANE_AUX_DIST(pipe, plane)	\
+	_PLANE(plane, _PLANE_AUX_DIST_1(pipe), _PLANE_AUX_DIST_2(pipe))
+
+#define PLANE_AUX_OFFSET_1_A		0x701c4
+#define PLANE_AUX_OFFSET_2_A		0x702c4
+#define PLANE_AUX_OFFSET_1_B		0x711c4
+#define PLANE_AUX_OFFSET_2_B		0x712c4
+#define _PLANE_AUX_OFFSET_1(pipe)	\
+   _PIPE(pipe, PLANE_AUX_OFFSET_1_A, PLANE_AUX_OFFSET_1_B)
+#define _PLANE_AUX_OFFSET_2(pipe)	\
+   _PIPE(pipe, PLANE_AUX_OFFSET_2_A, PLANE_AUX_OFFSET_2_B)
+#define PLANE_AUX_OFFSET(pipe, plane)	\
+	_PLANE(plane, _PLANE_AUX_OFFSET_1(pipe), _PLANE_AUX_OFFSET_2(pipe))
+
 /* legacy palette */
 #define _LGC_PALETTE_A           0x4a000
 #define _LGC_PALETTE_B           0x4a800
Signature · 6 lines
1.7.9.5

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

PATCH 4/16 drm/i915: Set scaler mode for NV12

In reply to Chandra Konduru

This patch sets appropriate scaler mode for NV12 format. In this mode, skylake scaler does either chroma-upsampling or chroma-upsampling and resolution scaling.

---
 drivers/gpu/drm/i915/intel_atomic.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_atomic.c +4 -1
index 9336e80..fd3972c 100644
@@ -247,7 +247,10 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
 		}
 
 		/* set scaler mode */
-		if (num_scalers_need == 1 && intel_crtc->pipe != PIPE_C) {
+		if (plane_state && plane_state->base.fb &&
+			plane_state->base.fb->pixel_format == DRM_FORMAT_NV12) {
+			scaler_state->scalers[*scaler_id].mode = PS_SCALER_MODE_NV12;
+		} else if (num_scalers_need == 1 && intel_crtc->pipe != PIPE_C) {
 			/*
 			 * when only 1 scaler is in use on either pipe A or B,
 			 * scaler 0 operates in high quality (HQ) mode.
Signature · 6 lines
1.7.9.5

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

PATCH 5/16 drm/i915: Stage scaler request for NV12 as src format

In reply to Chandra Konduru

This patch stages a scaler request when input format is NV12. The same scaler does both chroma-upsampling and resolution scaling as needed.

v2:
-Added helper function for need_scaling (Ville)

v3:
-Rebased to current kernel version 4.2.0.rc4 (me)

---
 drivers/gpu/drm/i915/intel_display.c |   30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +24 -6
index 3ee1c17..411b211 100644
@@ -4341,10 +4341,27 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
 	}
 }
 
+static int skl_need_scaling(int src_w, int dst_w, int src_h, int dst_h,
+	int rotation, uint32_t pixel_format)
+{
+	/* scaling is required when src dst sizes doesn't match or format is NV12 */
+	if (src_w != dst_w || src_h != dst_h)
+		return 1;
+
+	if (intel_rotation_90_or_270(rotation) &&
+			(src_h != dst_w || src_w != dst_h))
+		return 1;
+
+	if (pixel_format == DRM_FORMAT_NV12)
+		return 1;
+
+	return 0;
+}
+
 static int
 skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
 		  unsigned scaler_user, int *scaler_id, unsigned int rotation,
-		  int src_w, int src_h, int dst_w, int dst_h)
+		  int src_w, int src_h, int dst_w, int dst_h, uint32_t pixel_format)
 {
 	struct intel_crtc_scaler_state *scaler_state =
 		&crtc_state->scaler_state;
@@ -4352,9 +4369,8 @@ skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
 		to_intel_crtc(crtc_state->base.crtc);
 	int need_scaling;
 
-	need_scaling = intel_rotation_90_or_270(rotation) ?
-		(src_h != dst_w || src_w != dst_h):
-		(src_w != dst_w || src_h != dst_h);
+	need_scaling = skl_need_scaling(src_w, dst_w, src_h, dst_h, rotation,
+		pixel_format);
 
 	/*
 	 * if plane is being disabled or scaler is no more required or force detach
@@ -4423,7 +4439,7 @@ int skl_update_scaler_crtc(struct intel_crtc_state *state)
 	return skl_update_scaler(state, !state->base.active, SKL_CRTC_INDEX,
 		&state->scaler_state.scaler_id, DRM_ROTATE_0,
 		state->pipe_src_w, state->pipe_src_h,
-		adjusted_mode->hdisplay, adjusted_mode->vdisplay);
+		adjusted_mode->hdisplay, adjusted_mode->vdisplay, 0);
 }
 
 /**
@@ -4459,7 +4475,8 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
 				drm_rect_width(&plane_state->src) >> 16,
 				drm_rect_height(&plane_state->src) >> 16,
 				drm_rect_width(&plane_state->dst),
-				drm_rect_height(&plane_state->dst));
+				drm_rect_height(&plane_state->dst),
+				fb ? fb->pixel_format : 0);
 
 	if (ret || plane_state->scaler_id < 0)
 		return ret;
@@ -4484,6 +4501,7 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_VYUY:
+	case DRM_FORMAT_NV12:
 		break;
 	default:
 		DRM_DEBUG_KMS("[PLANE:%d] FB:%d unsupported scaling format 0x%x\n",
Signature · 6 lines
1.7.9.5

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

PATCH 6/16 drm/i915: Update format_is_yuv() to include NV12

In reply to Chandra Konduru

This patch adds NV12 to format_is_yuv() function
and made it available for both primary and sprite
planes.

v2:
-Use intel_ prefix for format_is_yuv (Ville)

---
 drivers/gpu/drm/i915/intel_drv.h    |    1 +
 drivers/gpu/drm/i915/intel_sprite.c |    9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index f44941b..18632a4 100644
@@ -1394,6 +1394,7 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
 void intel_pipe_update_start(struct intel_crtc *crtc,
 			     uint32_t *start_vbl_count);
 void intel_pipe_update_end(struct intel_crtc *crtc, u32 start_vbl_count);
+bool intel_format_is_yuv(uint32_t format);
 
 /* intel_tv.c */
 void intel_tv_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_sprite.c +5 -4
index c13c529..8b73bb8 100644
@@ -39,14 +39,15 @@
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
 
-static bool
-format_is_yuv(uint32_t format)
+bool
+intel_format_is_yuv(uint32_t format)
 {
 	switch (format) {
 	case DRM_FORMAT_YUYV:
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_VYUY:
 	case DRM_FORMAT_YVYU:
+	case DRM_FORMAT_NV12:
 		return true;
 	default:
 		return false;
@@ -293,7 +294,7 @@ chv_update_csc(struct intel_plane *intel_plane, uint32_t format)
 	int plane = intel_plane->plane;
 
 	/* Seems RGB data bypasses the CSC always */
-	if (!format_is_yuv(format))
+	if (!intel_format_is_yuv(format))
 		return;
 
 	/*
@@ -857,7 +858,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
 		src_y = src->y1 >> 16;
 		src_h = drm_rect_height(src) >> 16;
 
-		if (format_is_yuv(fb->pixel_format)) {
+		if (intel_format_is_yuv(fb->pixel_format)) {
 			src_x &= ~1;
 			src_w &= ~1;
 
Signature · 6 lines
1.7.9.5

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

PATCH 7/16 drm/i915: Upscale scaler max scale for NV12.

In reply to Chandra Konduru

This patch updates max supported scaler limits for NV12.

v2:
-Rebased to current kernel version 4.2.0.rc4 (me)

---
 drivers/gpu/drm/i915/intel_display.c |   13 +++++++++----
 drivers/gpu/drm/i915/intel_drv.h     |    3 ++-
 drivers/gpu/drm/i915/intel_sprite.c  |    2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +9 -4
index 411b211..b1d9edf 100644
@@ -13421,7 +13421,9 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 }
 
 int
-skl_max_scale(struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state)
+skl_max_scale(struct intel_crtc *intel_crtc,
+	struct intel_crtc_state *crtc_state,
+	uint32_t pixel_format)
 {
 	int max_scale;
 	struct drm_device *dev;
@@ -13441,11 +13443,13 @@ skl_max_scale(struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state
 
 	/*
 	 * skl max scale is lower of:
-	 *    close to 3 but not 3, -1 is for that purpose
+	 *    close to 2 or 3 (NV12: 2, other formats: 3) but not equal,
+	 *          -1 is for that purpose
 	 *            or
 	 *    cdclk/crtc_clock
 	 */
-	max_scale = min((1 << 16) * 3 - 1, (1 << 8) * ((cdclk << 8) / crtc_clock));
+	max_scale = min((1 << 16) * (pixel_format == DRM_FORMAT_NV12 ? 2 : 3) - 1,
+		(1 << 8) * ((cdclk << 8) / crtc_clock));
 
 	return max_scale;
 }
@@ -13465,7 +13469,8 @@ intel_check_primary_plane(struct drm_plane *plane,
 	if (INTEL_INFO(plane->dev)->gen >= 9 &&
 	    state->ckey.flags == I915_SET_COLORKEY_NONE) {
 		min_scale = 1;
-		max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state);
+		max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state,
+				fb ? fb->pixel_format : 0);
 		can_position = true;
 	}
 
drivers/gpu/drm/i915/intel_drv.h +2 -1
index 18632a4..d50b8cb 100644
@@ -1140,7 +1140,8 @@ void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
 void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
 
 int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
-int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
+int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state,
+	uint32_t pixel_format);
 
 unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
 				     struct drm_i915_gem_object *obj,
drivers/gpu/drm/i915/intel_sprite.c +1 -1
index 8b73bb8..66d60ae 100644
@@ -780,7 +780,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
 		if (state->ckey.flags == I915_SET_COLORKEY_NONE) {
 			can_scale = 1;
 			min_scale = 1;
-			max_scale = skl_max_scale(intel_crtc, crtc_state);
+			max_scale = skl_max_scale(intel_crtc, crtc_state, fb->pixel_format);
 		} else {
 			can_scale = 0;
 			min_scale = DRM_PLANE_HELPER_NO_SCALING;
Signature · 6 lines
1.7.9.5

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

PATCH 8/16 drm/i915: Add NV12 as supported format for primary plane

In reply to Chandra Konduru

This patch adds NV12 to list of supported formats for primary plane.

v2:
-Rebased (me)

Testcase: igt/kms_nv12

---
 drivers/gpu/drm/i915/intel_display.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +20 -2
index b1d9edf..e4a6a91 100644
@@ -74,6 +74,19 @@ static const uint32_t skl_primary_formats[] = {
 	DRM_FORMAT_XBGR2101010,
 };
 
+/* Primary plane formats for gen >= 9 with NV12 */
+static const uint32_t skl_primary_formats_with_nv12[] = {
+	DRM_FORMAT_C8,
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_XBGR8888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ABGR8888,
+	DRM_FORMAT_XRGB2101010,
+	DRM_FORMAT_XBGR2101010,
+	DRM_FORMAT_NV12,
+};
+
 /* Cursor formats */
 static const uint32_t intel_cursor_formats[] = {
 	DRM_FORMAT_ARGB8888,
@@ -13606,8 +13619,13 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 		primary->plane = !pipe;
 
 	if (INTEL_INFO(dev)->gen >= 9) {
-		intel_primary_formats = skl_primary_formats;
-		num_formats = ARRAY_SIZE(skl_primary_formats);
+		if (pipe == PIPE_A || pipe == PIPE_B) {
+			intel_primary_formats = skl_primary_formats_with_nv12;
+			num_formats = ARRAY_SIZE(skl_primary_formats_with_nv12);
+		} else {
+			intel_primary_formats = skl_primary_formats;
+			num_formats = ARRAY_SIZE(skl_primary_formats);
+		}
 	} else if (INTEL_INFO(dev)->gen >= 4) {
 		intel_primary_formats = i965_primary_formats;
 		num_formats = ARRAY_SIZE(i965_primary_formats);
Signature · 6 lines
1.7.9.5

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

PATCH 9/16 drm/i915: Add NV12 as supported format for sprite plane

In reply to Chandra Konduru

This patch adds NV12 to list of supported formats for sprite plane.

Testcase: igt/kms_nv12

---
 drivers/gpu/drm/i915/intel_sprite.c |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_sprite.c +21 -2
index 66d60ae..4e8c020 100644
@@ -1041,6 +1041,19 @@ static uint32_t skl_plane_formats[] = {
 	DRM_FORMAT_VYUY,
 };
 
+static uint32_t skl_plane_formats_with_nv12[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_ABGR8888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_XBGR8888,
+	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_YUYV,
+	DRM_FORMAT_YVYU,
+	DRM_FORMAT_UYVY,
+	DRM_FORMAT_VYUY,
+	DRM_FORMAT_NV12,
+};
+
 int
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 {
@@ -1112,8 +1125,14 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 		intel_plane->disable_plane = skl_disable_plane;
 		state->scaler_id = -1;
 
-		plane_formats = skl_plane_formats;
-		num_plane_formats = ARRAY_SIZE(skl_plane_formats);
+		if ((pipe == PIPE_A || pipe == PIPE_B) && (plane == 0)) {
+			plane_formats = skl_plane_formats_with_nv12;
+			num_plane_formats = ARRAY_SIZE(skl_plane_formats_with_nv12);
+		} else {
+			plane_formats = skl_plane_formats;
+			num_plane_formats = ARRAY_SIZE(skl_plane_formats) - 1;
+		}
+
 		break;
 	default:
 		kfree(intel_plane);
Signature · 6 lines
1.7.9.5

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

PATCH 10/16 drm/i915: Add NV12 support to intel_framebuffer_init

In reply to Chandra Konduru

This patch adds NV12 as supported format to intel_framebuffer_init and performs various checks.

v2:
-Fix an issue in checks added (me)

Testcase: igt/kms_nv12

---
 drivers/gpu/drm/i915/intel_display.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/gpu/drm/i915/intel_display.c +28 -0
index e4a6a91..4df4d77 100644
@@ -14343,6 +14343,34 @@ static int intel_framebuffer_init(struct drm_device *dev,
 			return -EINVAL;
 		}
 		break;
+	case DRM_FORMAT_NV12:
+		if (INTEL_INFO(dev)->gen < 9) {
+			DRM_DEBUG("unsupported pixel format: %s\n",
+				  drm_get_format_name(mode_cmd->pixel_format));
+			return -EINVAL;
+		}
+		if (!mode_cmd->offsets[1]) {
+			DRM_DEBUG("uv start offset not set\n");
+			return -EINVAL;
+		}
+		if (mode_cmd->pitches[0] != mode_cmd->pitches[1] ||
+			mode_cmd->handles[0] != mode_cmd->handles[1]) {
+			DRM_DEBUG("y and uv subplanes have different parameters\n");
+			return -EINVAL;
+		}
+		if (mode_cmd->modifier[1] == I915_FORMAT_MOD_Yf_TILED &&
+			(mode_cmd->offsets[1] & 0xFFF)) {
+			DRM_DEBUG("tile-Yf uv offset 0x%x isn't starting on new tile-row\n",
+				mode_cmd->offsets[1]);
+			return -EINVAL;
+		}
+		if (mode_cmd->modifier[1] == I915_FORMAT_MOD_Y_TILED &&
+			((mode_cmd->offsets[1] / mode_cmd->pitches[1]) % 4)) {
+			DRM_DEBUG("tile-Y uv offset 0x%x isn't 4-line aligned\n",
+				mode_cmd->offsets[1]);
+			return -EINVAL;
+		}
+		break;
 	default:
 		DRM_DEBUG("unsupported pixel format: %s\n",
 			  drm_get_format_name(mode_cmd->pixel_format));
Signature · 6 lines
1.7.9.5

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

PATCH 11/16 drm/i915: Add NV12 to primary plane programming.

In reply to Chandra Konduru

This patch is adding NV12 support to skylake primary plane programming. It is covering linear/X/Y/Yf tiling formats for 0 and 180 rotations.

For 90/270 rotation, Y and UV subplanes should be treated as separate surfaces and GTT remapping for rotation should be done separately for each subplane. Once GEM adds support for seperate remappings for two subplanes, 90/270 support to be added to plane programming.

v2:
-Use regular int instead of 16.16 in aux_offset calculations (me)

v3:
-Allow 90/270 for NV12 as its remapping is now supported (me)

v4:
-Rebased to current kernel version 4.2.0.rc4 (me)

Testcase: igt/kms_nv12

---
 drivers/gpu/drm/i915/intel_display.c |   37 ++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
drivers/gpu/drm/i915/intel_display.c +37 -0
index 4df4d77..329651e 100644
@@ -3026,6 +3026,8 @@ u32 skl_plane_ctl_format(uint32_t pixel_format)
 		return PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_UYVY;
 	case DRM_FORMAT_VYUY:
 		return PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_VYUY;
+	case DRM_FORMAT_NV12:
+		return PLANE_CTL_FORMAT_NV12;
 	default:
 		MISSING_CASE(pixel_format);
 	}
@@ -3094,6 +3096,8 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 	int src_x = 0, src_y = 0, src_w = 0, src_h = 0;
 	int dst_x = 0, dst_y = 0, dst_w = 0, dst_h = 0;
 	int scaler_id = -1;
+	u32 aux_dist = 0, aux_x_offset = 0, aux_y_offset = 0, aux_stride = 0;
+	u32 tile_row_adjustment = 0;
 
 	plane_state = to_intel_plane_state(plane->state);
 
@@ -3150,11 +3154,34 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 		x_offset = stride * tile_height - y - src_h;
 		y_offset = x;
 		plane_size = (src_w - 1) << 16 | (src_h - 1);
+		/*
+		 * TBD: For NV12 90/270 rotation, Y and UV subplanes should
+		 * be treated as separate surfaces and GTT remapping for
+		 * rotation should be done separately for each subplane.
+		 * Enable support once seperate remappings are available.
+		 */
 	} else {
 		stride = fb->pitches[0] / stride_div;
 		x_offset = x;
 		y_offset = y;
 		plane_size = (src_h - 1) << 16 | (src_w - 1);
+		tile_height = PAGE_SIZE / stride_div;
+
+		if (fb->pixel_format == DRM_FORMAT_NV12) {
+			int height_in_mem = (fb->offsets[1]/fb->pitches[0]);
+			/*
+			 * If UV starts from middle of a page, then UV start should
+			 * be programmed to beginning of that page. And offset into that
+			 * page to be programmed into y-offset
+			 */
+			tile_row_adjustment = height_in_mem % tile_height;
+			aux_dist = fb->pitches[0] * (height_in_mem - tile_row_adjustment);
+			aux_x_offset = DIV_ROUND_UP(x, 2);
+			aux_y_offset = DIV_ROUND_UP(y, 2) + tile_row_adjustment;
+			/* For tile-Yf, uv-subplane tile width is 2x of Y-subplane */
+			aux_stride = fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED ?
+				stride / 2 : stride;
+		}
 	}
 	plane_offset = y_offset << 16 | x_offset;
 
@@ -3162,11 +3189,14 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 	I915_WRITE(PLANE_OFFSET(pipe, 0), plane_offset);
 	I915_WRITE(PLANE_SIZE(pipe, 0), plane_size);
 	I915_WRITE(PLANE_STRIDE(pipe, 0), stride);
+	I915_WRITE(PLANE_AUX_DIST(pipe, 0), aux_dist | aux_stride);
+	I915_WRITE(PLANE_AUX_OFFSET(pipe, 0), aux_y_offset << 16 | aux_x_offset);
 
 	if (scaler_id >= 0) {
 		uint32_t ps_ctrl = 0;
 
 		WARN_ON(!dst_w || !dst_h);
+
 		ps_ctrl = PS_SCALER_EN | PS_PLANE_SEL(0) |
 			crtc_state->scaler_state.scalers[scaler_id].mode;
 		I915_WRITE(SKL_PS_CTRL(pipe, scaler_id), ps_ctrl);
@@ -3175,6 +3205,7 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 		I915_WRITE(SKL_PS_WIN_SZ(pipe, scaler_id), (dst_w << 16) | dst_h);
 		I915_WRITE(PLANE_POS(pipe, 0), 0);
 	} else {
+		WARN_ON(fb->pixel_format == DRM_FORMAT_NV12);
 		I915_WRITE(PLANE_POS(pipe, 0), (dst_y << 16) | dst_x);
 	}
 
@@ -11626,6 +11657,12 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
 	bool turn_off, turn_on, visible, was_visible;
 	struct drm_framebuffer *fb = plane_state->fb;
 
+	/* Adjust (macro)pixel boundary */
+	if (fb && intel_format_is_yuv(fb->pixel_format)) {
+		to_intel_plane_state(plane_state)->src.x1 &= ~0x10000;
+		to_intel_plane_state(plane_state)->src.x2 &= ~0x10000;
+	}
+
 	if (crtc_state && INTEL_INFO(dev)->gen >= 9 &&
 	    plane->type != DRM_PLANE_TYPE_CURSOR) {
 		ret = skl_update_scaler_plane(
Signature · 6 lines
1.7.9.5

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

PATCH 12/16 drm/i915: Add NV12 to sprite plane programming.

In reply to Chandra Konduru

This patch is adding NV12 support to skylake sprite plane programming. It is covering linear/X/Y/Yf tiling formats for 0 and 180 rotations.

For 90/270 rotation, Y and UV subplanes should be treated as separate surfaces and GTT remapping for rotation should be done separately for each subplane. Once GEM adds support for seperate remappings for two subplanes, 90/270 support to be added to plane programming.

Testcase: igt/kms_nv12

---
 drivers/gpu/drm/i915/intel_sprite.c |   31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_sprite.c +29 -2
index 4e8c020..a1384a7 100644
@@ -188,6 +188,8 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 	int x_offset, y_offset;
 	struct intel_crtc_state *crtc_state = to_intel_crtc(crtc)->config;
 	int scaler_id;
+	u32 aux_dist = 0, aux_x_offset = 0, aux_y_offset = 0, aux_stride = 0;
+	u32 tile_row_adjustment = 0;
 
 	plane_ctl = PLANE_CTL_ENABLE |
 		PLANE_CTL_PIPE_CSC_ENABLE;
@@ -234,24 +236,48 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 		plane_size = (src_w << 16) | src_h;
 		x_offset = stride * tile_height - y - (src_h + 1);
 		y_offset = x;
+
+		/*
+		 * TBD: For NV12 90/270 rotation, Y and UV subplanes should
+		 * be treated as separate surfaces and GTT remapping for
+		 * rotation should be done separately for each subplane.
+		 * Enable support once seperate remappings are available.
+		 */
 	} else {
 		stride = fb->pitches[0] / stride_div;
 		plane_size = (src_h << 16) | src_w;
 		x_offset = x;
 		y_offset = y;
+		tile_height = PAGE_SIZE / stride_div;
+
+		if (fb->pixel_format == DRM_FORMAT_NV12) {
+			int height_in_mem = (fb->offsets[1]/fb->pitches[0]);
+			/*
+			 * If UV starts from middle of a page, then UV start should
+			 * be programmed to beginning of that page. And offset into that
+			 * page to be programmed into y-offset
+			 */
+			tile_row_adjustment = height_in_mem % tile_height;
+			aux_dist = fb->pitches[0] * (height_in_mem - tile_row_adjustment);
+			aux_x_offset = DIV_ROUND_UP(x, 2);
+			aux_y_offset = DIV_ROUND_UP(y, 2) + tile_row_adjustment;
+			/* For tile-Yf, uv-subplane tile width is 2x of Y-subplane */
+			aux_stride = fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED ?
+				stride / 2 : stride;
+		}
 	}
 	plane_offset = y_offset << 16 | x_offset;
 
 	I915_WRITE(PLANE_OFFSET(pipe, plane), plane_offset);
 	I915_WRITE(PLANE_STRIDE(pipe, plane), stride);
 	I915_WRITE(PLANE_SIZE(pipe, plane), plane_size);
+	I915_WRITE(PLANE_AUX_DIST(pipe, plane), aux_dist | aux_stride);
+	I915_WRITE(PLANE_AUX_OFFSET(pipe, plane), aux_y_offset<<16 | aux_x_offset);
 
 	/* program plane scaler */
 	if (scaler_id >= 0) {
 		uint32_t ps_ctrl = 0;
 
-		DRM_DEBUG_KMS("plane = %d PS_PLANE_SEL(plane) = 0x%x\n", plane,
-			PS_PLANE_SEL(plane));
 		ps_ctrl = PS_SCALER_EN | PS_PLANE_SEL(plane) |
 			crtc_state->scaler_state.scalers[scaler_id].mode;
 		I915_WRITE(SKL_PS_CTRL(pipe, scaler_id), ps_ctrl);
@@ -262,6 +288,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 
 		I915_WRITE(PLANE_POS(pipe, plane), 0);
 	} else {
+		WARN_ON(fb->pixel_format == DRM_FORMAT_NV12);
 		I915_WRITE(PLANE_POS(pipe, plane), (crtc_y << 16) | crtc_x);
 	}
 
Signature · 6 lines
1.7.9.5

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

PATCH 13/16 drm/i915: Set initial phase & trip for NV12 scaler

In reply to Chandra Konduru

This patch sets default initial phase and trip to scale NV12 content. In future, if needed these can be set via properties or other means depending on incoming stream request. Until then defaults are fine.

---
 drivers/gpu/drm/i915/intel_display.c |    7 +++++++
 drivers/gpu/drm/i915/intel_sprite.c  |    7 +++++++
 2 files changed, 14 insertions(+)
drivers/gpu/drm/i915/intel_display.c +7 -0
index 329651e..419660d 100644
@@ -3098,6 +3098,7 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 	int scaler_id = -1;
 	u32 aux_dist = 0, aux_x_offset = 0, aux_y_offset = 0, aux_stride = 0;
 	u32 tile_row_adjustment = 0;
+	u32 hphase = 0, vphase = 0;
 
 	plane_state = to_intel_plane_state(plane->state);
 
@@ -3181,6 +3182,9 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 			/* For tile-Yf, uv-subplane tile width is 2x of Y-subplane */
 			aux_stride = fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED ?
 				stride / 2 : stride;
+
+			hphase = 0x00010001;  /* use trip for both Y and UV */
+			vphase = 0x00012000;  /* use trip for Y and phase 0.5 for UV */
 		}
 	}
 	plane_offset = y_offset << 16 | x_offset;
@@ -3209,6 +3213,9 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 		I915_WRITE(PLANE_POS(pipe, 0), (dst_y << 16) | dst_x);
 	}
 
+	I915_WRITE(SKL_PS_HPHASE(pipe, scaler_id), hphase);
+	I915_WRITE(SKL_PS_VPHASE(pipe, scaler_id), vphase);
+
 	I915_WRITE(PLANE_SURF(pipe, 0), surf_addr);
 
 	POSTING_READ(PLANE_SURF(pipe, 0));
drivers/gpu/drm/i915/intel_sprite.c +7 -0
index a1384a7..0ea9273 100644
@@ -190,6 +190,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 	int scaler_id;
 	u32 aux_dist = 0, aux_x_offset = 0, aux_y_offset = 0, aux_stride = 0;
 	u32 tile_row_adjustment = 0;
+	u32 hphase = 0, vphase = 0;
 
 	plane_ctl = PLANE_CTL_ENABLE |
 		PLANE_CTL_PIPE_CSC_ENABLE;
@@ -264,6 +265,9 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 			/* For tile-Yf, uv-subplane tile width is 2x of Y-subplane */
 			aux_stride = fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED ?
 				stride / 2 : stride;
+
+			hphase = 0x00010001;  /* use trip for both Y and UV */
+			vphase = 0x00012000;  /* use trip for Y and phase 0.5 for UV */
 		}
 	}
 	plane_offset = y_offset << 16 | x_offset;
@@ -292,6 +296,9 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 		I915_WRITE(PLANE_POS(pipe, plane), (crtc_y << 16) | crtc_x);
 	}
 
+	I915_WRITE(SKL_PS_HPHASE(pipe, scaler_id), hphase);
+	I915_WRITE(SKL_PS_VPHASE(pipe, scaler_id), vphase);
+
 	I915_WRITE(PLANE_CTL(pipe, plane), plane_ctl);
 	I915_WRITE(PLANE_SURF(pipe, plane), surf_addr);
 	POSTING_READ(PLANE_SURF(pipe, plane));
Signature · 6 lines
1.7.9.5

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

PATCH 14/16 drm/i915: skl nv12 wa - disable streamer fix

In reply to Chandra Konduru

When the plane source pixel format is NV12, the CHICKEN_PIPESL register bit 22 must be set to 1

v2:
-one wa per commit with comments, and function headers (Daniel)

---
 drivers/gpu/drm/i915/i915_reg.h      |   12 ++++++++
 drivers/gpu/drm/i915/intel_csr.c     |   29 ------------------
 drivers/gpu/drm/i915/intel_display.c |   54 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |    2 ++
 drivers/gpu/drm/i915/intel_sprite.c  |   11 +++++++
 5 files changed, 79 insertions(+), 29 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +12 -0
index c4d732f..84c5db6 100644
@@ -5354,6 +5354,18 @@ enum skl_disp_power_wells {
 #define PLANE_NV12_BUF_CFG(pipe, plane)	\
 	_PLANE(plane, _PLANE_NV12_BUF_CFG_1(pipe), _PLANE_NV12_BUF_CFG_2(pipe))
 
+/*
+ * Skylake Chicken registers
+ */
+#define _CHICKEN_PIPESL_A          0x420B0
+#define _CHICKEN_PIPESL_B          0x420B4
+#define _CHICKEN_PIPESL_C          0x420B8
+#define  DISABLE_STREAMER_FIX      (1 << 22)
+#define CHICKEN_PIPESL(pipe) _PIPE(pipe, _CHICKEN_PIPESL_A, _CHICKEN_PIPESL_B)
+
+#define CHICKEN_DCPR_1             0x46430
+#define IDLE_WAKEMEM_MASK          (1 << 13)
+
 /* SKL new cursor registers */
 #define _CUR_BUF_CFG_A				0x7017c
 #define _CUR_BUF_CFG_B				0x7117c
drivers/gpu/drm/i915/intel_csr.c +0 -29
index ba1ae03..9577727 100644
@@ -170,35 +170,6 @@ struct intel_dmc_header {
 	uint32_t reserved1[2];
 } __packed;
 
-struct stepping_info {
-	char stepping;
-	char substepping;
-};
-
-static const struct stepping_info skl_stepping_info[] = {
-		{'A', '0'}, {'B', '0'}, {'C', '0'},
-		{'D', '0'}, {'E', '0'}, {'F', '0'},
-		{'G', '0'}, {'H', '0'}, {'I', '0'}
-};
-
-static char intel_get_stepping(struct drm_device *dev)
-{
-	if (IS_SKYLAKE(dev) && (dev->pdev->revision <
-			ARRAY_SIZE(skl_stepping_info)))
-		return skl_stepping_info[dev->pdev->revision].stepping;
-	else
-		return -ENODATA;
-}
-
-static char intel_get_substepping(struct drm_device *dev)
-{
-	if (IS_SKYLAKE(dev) && (dev->pdev->revision <
-			ARRAY_SIZE(skl_stepping_info)))
-		return skl_stepping_info[dev->pdev->revision].substepping;
-	else
-		return -ENODATA;
-}
-
 /**
  * intel_csr_load_status_get() - to get firmware loading status.
  * @dev_priv: i915 device.
drivers/gpu/drm/i915/intel_display.c +54 -0

72 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +2 -0
index d50b8cb..59549245 100644
@@ -992,6 +992,8 @@ void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
 /* intel_display.c */
 extern const struct drm_plane_funcs intel_plane_funcs;
 bool intel_has_pending_fb_unpin(struct drm_device *dev);
+char intel_get_stepping(struct drm_device *dev);
+char intel_get_substepping(struct drm_device *dev);
 int intel_pch_rawclk(struct drm_device *dev);
 void intel_mark_busy(struct drm_device *dev);
 void intel_mark_idle(struct drm_device *dev);
drivers/gpu/drm/i915/intel_sprite.c +11 -0
index 0ea9273..b2346b0 100644
@@ -278,6 +278,17 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 	I915_WRITE(PLANE_AUX_DIST(pipe, plane), aux_dist | aux_stride);
 	I915_WRITE(PLANE_AUX_OFFSET(pipe, plane), aux_y_offset<<16 | aux_x_offset);
 
+	/*
+	 * Per bspec, for SKL C and BXT A steppings, when the plane source pixel
+	 * format is NV12, the CHICKEN_PIPESL register bit 22 must be set to 1
+	 */
+	if (((IS_SKYLAKE(dev) && intel_get_stepping(dev) == 'C') ||
+		(IS_BROXTON(dev) && intel_get_stepping(dev) == 'A')) &&
+		fb->pixel_format == DRM_FORMAT_NV12) {
+			I915_WRITE(CHICKEN_PIPESL(pipe),
+				I915_READ(CHICKEN_PIPESL(pipe)) | DISABLE_STREAMER_FIX);
+	}
+
 	/* program plane scaler */
 	if (scaler_id >= 0) {
 		uint32_t ps_ctrl = 0;
Signature · 6 lines
1.7.9.5

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

PATCH 15/16 drm/i915: skl nv12 wa - NV12 to RGB switch

In reply to Chandra Konduru

Switching format from NV12 to RGB can result in display underrun and corruption. This workaround sets bits 15 & 19 to 1 in CLKGATE_DIS_PSL register to address transition underrun.

---
 drivers/gpu/drm/i915/i915_reg.h      |    8 ++++++++
 drivers/gpu/drm/i915/intel_display.c |   25 +++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +8 -0
index 84c5db6..3192837 100644
@@ -5366,6 +5366,14 @@ enum skl_disp_power_wells {
 #define CHICKEN_DCPR_1             0x46430
 #define IDLE_WAKEMEM_MASK          (1 << 13)
 
+#define CLKGATE_DIS_PSL_A        0x46520
+#define CLKGATE_DIS_PSL_B        0x46524
+#define CLKGATE_DIS_PSL_C        0x46528
+#define DUPS1_GATING_DIS         (1 << 15)
+#define DUPS2_GATING_DIS         (1 << 19)
+#define DUPS3_GATING_DIS         (1 << 23)
+#define CLKGATE_DIS_PSL(pipe)  _PIPE(pipe, CLKGATE_DIS_PSL_A, CLKGATE_DIS_PSL_B)
+
 /* SKL new cursor registers */
 #define _CUR_BUF_CFG_A				0x7017c
 #define _CUR_BUF_CFG_B				0x7117c
drivers/gpu/drm/i915/intel_display.c +25 -0
index 35e9f89..e8fb15b 100644
@@ -5058,6 +5058,25 @@ static bool hsw_crtc_supports_ips(struct intel_crtc *crtc)
 	return HAS_IPS(crtc->base.dev) && crtc->pipe == PIPE_A;
 }
 
+/*
+ * Switching format from NV12 to RGB can result in display underrun
+ * and corruption. Workaround is to set bits 15 & 19 to 1 in
+ * CLKGATE_DIS_PSL register.
+ */
+static void skl_wa_clkgate(struct drm_i915_private *dev_priv,
+	int pipe, int enable)
+{
+	if (pipe == PIPE_A || pipe == PIPE_B) {
+		if (enable)
+			I915_WRITE(CLKGATE_DIS_PSL(pipe),
+				DUPS1_GATING_DIS | DUPS2_GATING_DIS);
+		else
+			I915_WRITE(CLKGATE_DIS_PSL(pipe),
+				I915_READ(CLKGATE_DIS_PSL(pipe) &
+				~(DUPS1_GATING_DIS|DUPS2_GATING_DIS)));
+	}
+}
+
 static void haswell_crtc_enable(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -5148,6 +5167,9 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 		intel_wait_for_vblank(dev, hsw_workaround_pipe);
 		intel_wait_for_vblank(dev, hsw_workaround_pipe);
 	}
+
+	/* workaround for NV12 */
+	skl_wa_clkgate(dev_priv, pipe, 1);
 }
 
 static void ironlake_pfit_disable(struct intel_crtc *crtc)
@@ -5265,6 +5287,9 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 
 	intel_crtc->active = false;
 	intel_update_watermarks(crtc);
+
+	/* workaround for NV12 */
+	skl_wa_clkgate(dev_priv, intel_crtc->pipe, 0);
 }
 
 static void i9xx_pfit_enable(struct intel_crtc *crtc)
Signature · 6 lines
1.7.9.5

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

PATCH 16/16 drm/i915: Add 90/270 rotation for NV12 format.

In reply to Chandra Konduru

Adding NV12 90/270 rotation support for primary and sprite planes.

v2:
-For 90/270 adjust pixel boundary only in Y-direction (bspec)

v3:
-Rebased (me)

Testcase: igt/kms_nv12

---
 drivers/gpu/drm/i915/intel_display.c |   28 +++++++++++------
 drivers/gpu/drm/i915/intel_sprite.c  |   56 ++++++++++++++++++++++------------
 2 files changed, 56 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/intel_display.c +19 -9
index e8fb15b..8602432 100644
@@ -3139,7 +3139,8 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 	int src_x = 0, src_y = 0, src_w = 0, src_h = 0;
 	int dst_x = 0, dst_y = 0, dst_w = 0, dst_h = 0;
 	int scaler_id = -1;
-	u32 aux_dist = 0, aux_x_offset = 0, aux_y_offset = 0, aux_stride = 0;
+	unsigned long aux_dist = 0;
+	u32 aux_x_offset = 0, aux_y_offset = 0, aux_stride = 0;
 	u32 tile_row_adjustment = 0;
 	u32 hphase = 0, vphase = 0;
 
@@ -3198,12 +3199,16 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
 		x_offset = stride * tile_height - y - src_h;
 		y_offset = x;
 		plane_size = (src_w - 1) << 16 | (src_h - 1);
-		/*
-		 * TBD: For NV12 90/270 rotation, Y and UV subplanes should
-		 * be treated as separate surfaces and GTT remapping for
-		 * rotation should be done separately for each subplane.
-		 * Enable support once seperate remappings are available.
-		 */
+
+		if (fb->pixel_format == DRM_FORMAT_NV12) {
+			u32 uv_tile_height = intel_tile_height(dev, fb->pixel_format,
+						fb->modifier[0], 1);
+			aux_stride = DIV_ROUND_UP(fb->height / 2, uv_tile_height);
+			aux_dist = intel_plane_obj_offset(to_intel_plane(plane), obj, 1) -
+				surf_addr;
+			aux_x_offset = aux_stride * uv_tile_height - y / 2 - fb->height / 2;
+			aux_y_offset = x / 2;
+		}
 	} else {
 		stride = fb->pitches[0] / stride_div;
 		x_offset = x;
@@ -11745,8 +11750,13 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
 
 	/* Adjust (macro)pixel boundary */
 	if (fb && intel_format_is_yuv(fb->pixel_format)) {
-		to_intel_plane_state(plane_state)->src.x1 &= ~0x10000;
-		to_intel_plane_state(plane_state)->src.x2 &= ~0x10000;
+		if (intel_rotation_90_or_270(plane_state->rotation)) {
+			to_intel_plane_state(plane_state)->src.y1 &= ~0x10000;
+			to_intel_plane_state(plane_state)->src.y2 &= ~0x10000;
+		} else {
+			to_intel_plane_state(plane_state)->src.x1 &= ~0x10000;
+			to_intel_plane_state(plane_state)->src.x2 &= ~0x10000;
+		}
 	}
 
 	if (crtc_state && INTEL_INFO(dev)->gen >= 9 &&
drivers/gpu/drm/i915/intel_sprite.c +37 -19

74 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

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