intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] drm: Make sure at least one plane supports the fb format
@ 2018-03-05 14:49 Ville Syrjala
  2018-03-05 14:49 ` [PATCH 2/3] drm/i915: Eliminate the horrendous format check code Ville Syrjala
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: Ville Syrjala @ 2018-03-05 14:49 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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

To make life easier for drivers, let's have the core check that the
requested pixel format is supported by at least one plane when creating
a new framebuffer.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_framebuffer.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index c0530a1af5e3..155b21e579c4 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -152,6 +152,23 @@ static int fb_plane_height(int height,
 	return DIV_ROUND_UP(height, format->vsub);
 }
 
+static bool planes_have_format(struct drm_device *dev, u32 format)
+{
+	struct drm_plane *plane;
+
+	/* TODO: maybe maintain a device level format list? */
+	drm_for_each_plane(plane, dev) {
+		int i;
+
+		for (i = 0; i < plane->format_count; i++) {
+			if (plane->format_types[i] == format)
+				return true;
+		}
+	}
+
+	return false;
+}
+
 static int framebuffer_check(struct drm_device *dev,
 			     const struct drm_mode_fb_cmd2 *r)
 {
@@ -168,6 +185,15 @@ static int framebuffer_check(struct drm_device *dev,
 		return -EINVAL;
 	}
 
+	if (!planes_have_format(dev, r->pixel_format)) {
+		struct drm_format_name_buf format_name;
+
+		DRM_DEBUG_KMS("unsupported framebuffer format %s\n",
+			      drm_get_format_name(r->pixel_format,
+						  &format_name));
+		return -EINVAL;
+	}
+
 	/* now let the driver pick its own format info */
 	info = drm_get_format_info(dev, r);
 
-- 
2.16.1

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2018-03-06 16:12 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-05 14:49 [PATCH 1/3] drm: Make sure at least one plane supports the fb format Ville Syrjala
2018-03-05 14:49 ` [PATCH 2/3] drm/i915: Eliminate the horrendous format check code Ville Syrjala
2018-03-05 21:41   ` [PATCH v2 " Ville Syrjala
2018-03-05 14:49 ` [PATCH 3/3] drm: Fix some coding style issues Ville Syrjala
2018-03-06 10:31   ` Daniel Vetter
2018-03-05 15:37 ` ✓ Fi.CI.BAT: success for series starting with [1/3] drm: Make sure at least one plane supports the fb format Patchwork
2018-03-05 19:31 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-03-05 20:59 ` [Intel-gfx] [PATCH 1/3] " Eric Anholt
2018-03-05 21:15   ` Ville Syrjälä
2018-03-05 21:33     ` Alex Deucher
2018-03-05 22:44       ` [Intel-gfx] " Harry Wentland
2018-03-06 10:09         ` Ville Syrjälä
2018-03-06 10:35         ` [Intel-gfx] " Daniel Vetter
2018-03-06 16:12           ` Harry Wentland
2018-03-05 22:56     ` Eric Anholt
2018-03-05 21:41 ` [PATCH v2 " Ville Syrjala
2018-03-06 11:57   ` [Intel-gfx] " Ville Syrjälä
2018-03-06 12:54     ` Ville Syrjälä
2018-03-05 22:10 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/3] drm: Make sure at least one plane supports the fb format (rev3) Patchwork
2018-03-06  6:46 ` ✗ Fi.CI.IGT: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).