[Intel-gfx] [PATCH i-g-t 1/2] lib: Check format of framebuffer before SetPlane
Tomeu Vizoso
tomeu.vizoso at collabora.com
Wed Nov 23 13:04:45 UTC 2016
Avoid setting a framebuffer in a format that the plane doesn't support,
so we have better debug output in IGT and we don't have to dig into
dmesg files to find out what's going on.
I found this issue when kms_plane_scaling tried to use a cursor plane as
a regular one in a Skylake machine with just one overlay.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
---
lib/igt_kms.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 989704e14803..3234fa1bbdc4 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1670,6 +1670,14 @@ static uint32_t igt_plane_get_fb_id(igt_plane_t *plane)
return 0;
}
+static uint32_t igt_plane_get_fb_format(igt_plane_t *plane)
+{
+ if (plane->fb)
+ return plane->fb->drm_format;
+ else
+ return 0;
+}
+
static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t *plane)
{
if (plane->fb)
@@ -1678,6 +1686,28 @@ static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t *plane)
return 0;
}
+static bool igt_plane_supports_format(igt_plane_t *plane, uint32_t format)
+{
+ int i;
+
+ for (i = 0; i < plane->drm_plane->count_formats; i++) {
+ if (format == plane->drm_plane->formats[i])
+ return true;
+ }
+
+ igt_debug("Plane %d in pipe %s doesn't support format %s.\n",
+ plane->index,
+ kmstest_pipe_name(plane->pipe->pipe),
+ igt_format_str(format));
+
+ igt_debug("Formats supported are:");
+ for (i = 0; i < plane->drm_plane->count_formats; i++)
+ igt_debug(" %s", igt_format_str(plane->drm_plane->formats[i]));
+ igt_debug(".\n");
+
+ return false;
+}
+
#define CHECK_RETURN(r, fail) { \
if (r && !fail) \
return r; \
@@ -1772,6 +1802,7 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
int32_t crtc_y;
uint32_t crtc_w;
uint32_t crtc_h;
+ uint32_t format;
igt_assert(plane->drm_plane);
@@ -1821,6 +1852,10 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
src_x >> 16, src_y >> 16, src_w >> 16, src_h >> 16,
crtc_x, crtc_y, crtc_w, crtc_h);
+ /* it's an error to try an unsupported format */
+ format = igt_plane_get_fb_format(plane);
+ igt_assert(igt_plane_supports_format(plane, format));
+
ret = drmModeSetPlane(display->drm_fd,
plane->drm_plane->plane_id,
crtc_id,
--
2.7.4
More information about the Intel-gfx
mailing list