All of lore.kernel.org
 help / color / mirror / Atom feed
From: ville.syrjala@linux.intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>,
	dri-devel@lists.freedesktop.org,
	Daniel Stone <daniels@collabora.com>
Subject: [PATCH 11/12] drm: Check that the plane supports the request format+modifier combo
Date: Thu, 24 Aug 2017 22:10:59 +0300	[thread overview]
Message-ID: <20170824191100.10949-12-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20170824191100.10949-1-ville.syrjala@linux.intel.com>

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

Currently we only check that the plane supports the pixel format of the
fb we're about to feed to it. Extend it to check also the modifier, and
more specifically that the combination of the format and modifier is
supported.

Cc: dri-devel@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: Jason Ekstrand <jason@jlekstrand.net>
Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic.c        |  8 +++++---
 drivers/gpu/drm/drm_crtc.c          |  8 +++++---
 drivers/gpu/drm/drm_crtc_internal.h |  4 ++--
 drivers/gpu/drm/drm_plane.c         | 31 +++++++++++++++++++++++++------
 4 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 2fd383d7253a..51cd05a7360b 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -884,12 +884,14 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 	}
 
 	/* Check whether this plane supports the fb pixel format. */
-	ret = drm_plane_check_pixel_format(plane, state->fb->format->format);
+	ret = drm_plane_check_pixel_format(plane, state->fb->format->format,
+					   state->fb->modifier);
 	if (ret) {
 		struct drm_format_name_buf format_name;
-		DRM_DEBUG_ATOMIC("Invalid pixel format %s\n",
+		DRM_DEBUG_ATOMIC("Invalid pixel format %s, modifier 0x%llx\n",
 		                 drm_get_format_name(state->fb->format->format,
-		                                     &format_name));
+		                                     &format_name),
+				 state->fb->modifier);
 		return ret;
 	}
 
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 5af25ce5bf7c..dd54deb75c0d 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -625,12 +625,14 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
 		 */
 		if (!crtc->primary->format_default) {
 			ret = drm_plane_check_pixel_format(crtc->primary,
-							   fb->format->format);
+							   fb->format->format,
+							   fb->modifier);
 			if (ret) {
 				struct drm_format_name_buf format_name;
-				DRM_DEBUG_KMS("Invalid pixel format %s\n",
+				DRM_DEBUG_KMS("Invalid pixel format %s, modifier 0x%llx\n",
 				              drm_get_format_name(fb->format->format,
-				                                  &format_name));
+				                                  &format_name),
+					      fb->modifier);
 				goto out;
 			}
 		}
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index a43582076b20..81865841b656 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -194,8 +194,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 /* drm_plane.c */
 int drm_plane_register_all(struct drm_device *dev);
 void drm_plane_unregister_all(struct drm_device *dev);
-int drm_plane_check_pixel_format(const struct drm_plane *plane,
-				 u32 format);
+int drm_plane_check_pixel_format(struct drm_plane *plane,
+				 u32 format, u64 modifier);
 
 /* drm_bridge.c */
 void drm_bridge_detach(struct drm_bridge *bridge);
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 7a00351d5b5d..c63a81e32e23 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -555,16 +555,33 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
 	return 0;
 }
 
-int drm_plane_check_pixel_format(const struct drm_plane *plane, u32 format)
+int drm_plane_check_pixel_format(struct drm_plane *plane,
+				 u32 format, u64 modifier)
 {
 	unsigned int i;
 
 	for (i = 0; i < plane->format_count; i++) {
 		if (format == plane->format_types[i])
-			return 0;
+			break;
+	}
+	if (i == plane->format_count)
+		return -EINVAL;
+
+	if (!plane->modifier_count)
+		return 0;
+
+	for (i = 0; i < plane->modifier_count; i++) {
+		if (modifier == plane->modifiers[i])
+			break;
 	}
+	if (i == plane->modifier_count)
+		return -EINVAL;
 
-	return -EINVAL;
+	if (plane->funcs->format_mod_supported &&
+	    !plane->funcs->format_mod_supported(plane, format, modifier))
+		return -EINVAL;
+
+	return 0;
 }
 
 /*
@@ -609,12 +626,14 @@ static int __setplane_internal(struct drm_plane *plane,
 	}
 
 	/* Check whether this plane supports the fb pixel format. */
-	ret = drm_plane_check_pixel_format(plane, fb->format->format);
+	ret = drm_plane_check_pixel_format(plane, fb->format->format,
+					   fb->modifier);
 	if (ret) {
 		struct drm_format_name_buf format_name;
-		DRM_DEBUG_KMS("Invalid pixel format %s\n",
+		DRM_DEBUG_KMS("Invalid pixel format %s, modifier 0x%llx\n",
 		              drm_get_format_name(fb->format->format,
-		                                  &format_name));
+		                                  &format_name),
+			      fb->modifier);
 		goto out;
 	}
 
-- 
2.13.0

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

  parent reply	other threads:[~2017-08-24 19:10 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 19:10 [PATCH 00/12] drm/i915: Fix up the CCS code ville.syrjala
2017-08-24 19:10 ` [PATCH 01/12] drm/i915: Treat fb->offsets[] as a raw byte offset instead of a linear offset ville.syrjala
2017-08-24 19:10 ` [PATCH 02/12] drm/i915: Skip fence alignemnt check for the CCS plane ville.syrjala
2017-08-25  4:56   ` Ben Widawsky
2017-08-24 19:10 ` [PATCH 03/12] drm/i915: Switch over to the LLC/eLLC hotspot avoidance hash mode for CCS ville.syrjala
2017-08-25  4:55   ` Ben Widawsky
2017-08-25 11:40     ` Ville Syrjälä
2017-09-13 23:29   ` Ben Widawsky
2017-09-14 12:09     ` Ville Syrjälä
2017-08-24 19:10 ` [PATCH 04/12] drm/i915: Add a comment exlaining CCS hsub/vsub ville.syrjala
2017-08-24 19:10 ` [PATCH 05/12] drm/i915: Nuke a pointless unreachable() ville.syrjala
2017-08-25  4:40   ` Ben Widawsky
2017-08-25 15:36     ` Emil Velikov
2017-08-24 19:10 ` [PATCH 06/12] drm/i915: Add the missing Y/Yf modifiers for SKL+ sprites ville.syrjala
2017-08-25  9:40   ` Daniel Stone
2017-08-25 11:34     ` Ville Syrjälä
2017-08-25 13:58       ` Daniel Stone
2017-08-24 19:10 ` [PATCH 07/12] drm/i915: Clean up the sprite modifier checks ville.syrjala
2017-08-24 19:10 ` [PATCH 08/12] drm/i915: Add CCS capability for sprites ville.syrjala
2017-12-11 11:11   ` Mika Kahola
2017-12-11 12:00     ` Daniel Stone
2017-12-11 12:08       ` Mika Kahola
2017-12-11 12:33         ` Daniel Stone
2017-12-11 13:35           ` Ville Syrjälä
2017-08-24 19:10 ` [PATCH 09/12] drm/i915: Allow up to 32KB stride on SKL+ "sprites" ville.syrjala
2017-08-24 19:10 ` [PATCH 10/12] drm: Fix modifiers_property kernel doc ville.syrjala
2017-08-25 13:44   ` Daniel Vetter
2017-08-24 19:10 ` ville.syrjala [this message]
2017-08-25 13:47   ` [Intel-gfx] [PATCH 11/12] drm: Check that the plane supports the request format+modifier combo Daniel Vetter
2017-08-24 19:11 ` [PATCH 12/12] drm/i915: Remove the pipe/plane ID checks from skl_check_ccs_aux_surface() ville.syrjala
2017-08-24 19:41 ` ✓ Fi.CI.BAT: success for drm/i915: Fix up the CCS code Patchwork
2017-08-24 21:05 ` ✓ Fi.CI.IGT: " Patchwork
2017-08-25 17:17 ` [PATCH 00/12] " Daniel Vetter
2017-08-28 13:35   ` Daniel Stone
2017-08-28 14:47     ` Ville Syrjälä
2017-08-30  8:31       ` Jani Nikula
2017-08-30 17:09         ` Ville Syrjälä
2017-09-01  0:05           ` Rodrigo Vivi
2017-09-01 13:46             ` Ville Syrjälä
2017-10-16 22:21               ` Kristian Høgsberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170824191100.10949-12-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=ben@bwidawsk.net \
    --cc=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.