Skip to contentSkip to conversation

tests/kms_plane_lowres: Plane visibility after atomic modesets

PATCH Superseded Mika Kahola 2 participants 3 messages Nov 23, 2016 – Dec 9, 2016 Library code

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tests/kms_plane_lowres: Plane visibility after atomic modesets

Testcase for plane visibility after atomic modesets. The idea of the test is the following:

- draw a blue screen with high resolution
- enable a yellow plane, visible, in lower-left corner
- set a new lower resolution mode (1024x768) that makes plane invisible
- check from debugfs 'i915_display_info' that the plane is invisible
- switch back to higher resolution mode
- check from debugfs 'i915_display_info' that the plane is visible again
- repeat number of iterations, default 64

v2: allow test to be run on non-Intel drivers (Daniel)
moved test for plane visibility to as helper function (Daniel) moved get_vblank() function to be part of helper functions (Daniel) rename 'tiling' parameter as 'modifier' (Daniel)
select a mode from a list so that the plane should be invisible. use default 1024x768 mode only as a fallback if decent mode has not been found (Daniel)
add tiling MODE_NONE (Daniel)

---
 lib/igt_kms.c            |  93 +++++++++++
 lib/igt_kms.h            |   9 ++
 tests/Makefile.sources   |   1 +
 tests/kms_plane_lowres.c | 394 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 497 insertions(+)
 create mode 100644 tests/kms_plane_lowres.c
lib/igt_kms.c +93 -0
index 989704e..098b29b 100644
@@ -1176,6 +1176,99 @@ int kmstest_get_crtc_idx(drmModeRes *res, uint32_t crtc_id)
 	igt_assert(false);
 }
 
+static inline uint32_t pipe_select(int pipe)
+{
+	if (pipe > 1)
+		return pipe << DRM_VBLANK_HIGH_CRTC_SHIFT;
+	else if (pipe > 0)
+		return DRM_VBLANK_SECONDARY;
+	else
+		return 0;
+}
+
+unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags)
+{
+	union drm_wait_vblank vbl;
+
+	memset(&vbl, 0, sizeof(vbl));
+	vbl.request.type = DRM_VBLANK_RELATIVE | pipe_select(pipe) | flags;
+	if (drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl))
+		return 0;
+
+	return vbl.reply.sequence;
+}
+
+static int parse_resolution(struct kmstest_resolution *resolution, char *info)
+{
+	char size[32];
+	int ret;
+
+	ret = sscanf(info + 4, "%d%*c %*s %*s %*s %s%*c",
+		     &resolution->id, size);
+
+	if (ret != 2)
+		return -1;
+
+	ret = sscanf(size + 6, "%d%*c%d%*c",
+		     &resolution->width, &resolution->height);
+
+	if (ret != 2)
+		return -1;
+
+	return ret + 1;
+}
+
+static bool get_visibility(FILE *fid, struct kmstest_resolution *resolution)
+{
+	char tmp[256];
+	struct kmstest_resolution plane;
+	int ret;
+
+	while (fgets(tmp, 256, fid) != NULL) {
+		if (strstr(tmp, "type=OVL") != NULL) {
+			ret = sscanf(tmp + 12, "%d%*c %*s %*s %d%*c%d%*c",
+				     &plane.id, &plane.width, &plane.height);
+
+			igt_assert_eq(ret, 3);
+
+			if (plane.width > resolution->width)
+				return false;
+			else if (plane.height > resolution->height)
+				return false;
+			else
+				return true;
+		}
+	}
+
+	return false;
+}
+
+bool kmstest_plane_visible(void)
+{
+	char tmp[256];
+	FILE *fid;
+	bool visible = false;
+	struct kmstest_resolution resolution;
+	const char *mode = "r";
+	int ret;
+
+	fid = igt_debugfs_fopen("i915_display_info", mode);
+
+	igt_assert(fid != NULL);
+
+	while (fgets(tmp, 256, fid) != NULL) {
+		if (strstr(tmp, "active=yes") != NULL) {
+			ret = parse_resolution(&resolution, tmp);
+			igt_assert_eq(ret, 3);
+			visible = get_visibility(fid, &resolution);
+		}
+	}
+
+	fclose(fid);
+
+	return visible;
+}
+
 /*
  * A small modeset API
  */
lib/igt_kms.h +9 -0
index 6422adc..4193354 100644
@@ -132,6 +132,13 @@ struct kmstest_connector_config {
 	unsigned valid_crtc_idx_mask;
 };
 
+struct kmstest_resolution {
+	int id;
+	int width;
+	int height;
+};
+
+
 /**
  * kmstest_force_connector_state:
  * @FORCE_CONNECTOR_UNSPECIFIED: Unspecified
@@ -177,6 +184,8 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
 
 void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
 			      unsigned prot);
+unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
+bool kmstest_plane_visible(void);
 
 /*
  * A small modeset API
tests/Makefile.sources +1 -0
index 65e0792..c593e49 100644
@@ -108,6 +108,7 @@ TESTS_progs_M = \
 	kms_pipe_color \
 	kms_pipe_crc_basic \
 	kms_plane \
+	kms_plane_lowres \
 	kms_properties \
 	kms_psr_sink_crc \
 	kms_render \
tests/kms_plane_lowres.c new file +394 -0

394 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
#1 lore raw

Hi Mika,
Thanks for respinning!

lib/igt_kms.c int kmstest_get_crtc_idx(drmModeRes *res, uint32_t crtc_id) · line 1257

Quoted 12 lines · Mika Kahola
lib/igt_kms.c +12 -0
+bool kmstest_plane_visible(void)
+{
+       char tmp[256];
+       FILE *fid;
+       bool visible = false;
+       struct kmstest_resolution resolution;
+       const char *mode = "r";
+       int ret;
+
+       fid = igt_debugfs_fopen("i915_display_info", mode);
+
+       igt_assert(fid != NULL);

This, however, breaks non-Intel drivers: we declare DRIVER_ANY, but later assert that we can open this file. Maybe what would be better would be to have:
void igt_assert_plane_visible(plane_id, should_be_visible) which would then internally do an igt_assert() on the result, or igt_skip() if that file is not present.

Also, it seems kind of fragile, as it only looks for the first plane marked 'OVL'. What happens if we have multiple overlay planes?

Regardless, I think it's very close, and am happy to test a v3 on non-i915. Thanks a lot for the rework!

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

#2 lore raw

Hi,

Thanks for review comments!

Quoted 22 lines

-----Original Message-----
From: Daniel Stone [mailto:[email protected]]
Sent: Wednesday, December 7, 2016 5:02 PM
To: Kahola, Mika <[email protected]>
Cc: intel-gfx <[email protected]>
Subject: Re: [PATCH i-g-t v2] tests/kms_plane_lowres: Plane visibility after atomic modesets

Hi Mika,
Thanks for respinning!

Quoted 10 lines · Mika Kahola
lib/igt_kms.c +10 -0
+bool kmstest_plane_visible(void)
+{
+       char tmp[256];
+       FILE *fid;
+       bool visible = false;
+       struct kmstest_resolution resolution;
+       const char *mode = "r";
+       int ret;
+
+       fid = igt_debugfs_fopen("i915_display_info", mode);
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+       igt_assert(fid != NULL);

This, however, breaks non-Intel drivers: we declare DRIVER_ANY, but later assert that we can open this file. Maybe what would be better would be to have:
void igt_assert_plane_visible(plane_id, should_be_visible) which would then internally do an igt_assert() on the result, or
igt_skip() if that file is not present.

That's a good point. For non-Intel drivers 'i915_display_info' file doesn't exist. The test could skip if we cannot find the file but then the test would skip all non-Intel drivers. For non-Intel drivers, is there any way to check (debugfs files?) if the resolution change has succeeded and check the plane visibility?

Quoted 3 lines

Also, it seems kind of fragile, as it only looks for the first plane marked 'OVL'. What happens if we have multiple overlay planes?

I had an idea of testing with one plane only but it wouldn't be a major change to use as many OVL planes as we have available.

Quoted 3 lines

Regardless, I think it's very close, and am happy to test a v3 on non-i915. Thanks a lot for the rework!

I'll respin another round!

Cheers,
Mika

Quoted 3 lines

Cheers,
Daniel

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