[PATCH] tools/intel_framebuffer_dump : dump FB attached to all enabled planes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Ap, Kamal <kamal.ap@xxxxxxxxx>
---
 tools/intel_framebuffer_dump.c | 45 +++++++++++++++++++++++++++++-------------
 1 file changed, 31 insertions(+), 14 deletions(-)

diff --git a/tools/intel_framebuffer_dump.c b/tools/intel_framebuffer_dump.c
index 624a961..8fb311f 100644
--- a/tools/intel_framebuffer_dump.c
+++ b/tools/intel_framebuffer_dump.c
@@ -41,28 +41,42 @@
 int main(int argc, char **argv)
 {
 	drmModeResPtr res;
-	int fd, n;
+	drmModePlaneRes *plane_resources;
+	drmModePlane *ovr;
+
+	int fd, i;
+
+	fd = drm_open_driver(DRIVER_INTEL);
 
-	fd = drmOpen("i915", NULL);
 	if (fd < 0)
 		return ENOENT;
 
+	drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+
 	res = drmModeGetResources(fd);
+
 	if (res == NULL)
 		return ENOMEM;
 
-	for (n = 0; n < res->count_crtcs; n++) {
-		struct drm_gem_open open_arg;
-		struct drm_gem_flink flink;
-		drmModeCrtcPtr crtc;
+	plane_resources = drmModeGetPlaneResources(fd);
+
+	if (!plane_resources) {
+		return 0;
+	}
+
+	for (i = 0; i < plane_resources->count_planes; i++) {
 		drmModeFBPtr fb;
+		struct drm_gem_flink flink;
+		struct drm_gem_open open_arg;
 
-		crtc = drmModeGetCrtc(fd, res->crtcs[n]);
-		if (crtc == NULL)
+		ovr = drmModeGetPlane(fd, plane_resources->planes[i]);
+		if (!ovr) {
+			printf("GetPlane failed: %s\n",
+			strerror(errno));
 			continue;
+		}
 
-		fb = drmModeGetFB(fd, crtc->buffer_id);
-		drmModeFreeCrtc(crtc);
+		fb = drmModeGetFB(fd, ovr->fb_id);
 		if (fb == NULL)
 			continue;
 
@@ -73,18 +87,21 @@ int main(int argc, char **argv)
 		}
 
 		open_arg.name = flink.name;
+
 		if (drmIoctl(fd, DRM_IOCTL_GEM_OPEN, &open_arg) == 0) {
 			struct drm_i915_gem_mmap_gtt mmap_arg;
 			void *ptr;
 
-						mmap_arg.handle = open_arg.handle;
+			mmap_arg.handle = open_arg.handle;
 			if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg) == 0 &&
 			    (ptr = mmap(0, open_arg.size, PROT_READ, MAP_SHARED, fd, mmap_arg.offset)) != (void *)-1) {
 				cairo_surface_t *surface;
 				cairo_format_t format;
 				char name[80];
 
-				snprintf(name, sizeof(name), "fb-%d.png",  fb->fb_id);
+				snprintf(name, sizeof(name),
+				    "p-%d_w-%d_h-%d_fb-%d.png", ovr->plane_id,
+				    fb->width, fb->height, fb->fb_id);
 
 				switch (fb->depth) {
 				case 16: format = CAIRO_FORMAT_RGB16_565; break;
@@ -98,14 +115,14 @@ int main(int argc, char **argv)
 									      fb->width, fb->height, fb->pitch);
 				cairo_surface_write_to_png(surface, name);
 				cairo_surface_destroy(surface);
-
 				munmap(ptr, open_arg.size);
 			}
 			drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &open_arg.handle);
 		}
 
 		drmModeFreeFB(fb);
+		drmModeFreePlane(ovr);
 	}
-
+	drmClose(fd);
 	return 0;
 }
-- 
1.9.1

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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux