dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Wladimir J. van der Laan" <laanwj@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>,
	"Wladimir J. van der Laan" <laanwj@gmail.com>,
	Emil Velikov <emil.l.velikov@gmail.com>
Subject: [PATCH libdrm 2/2] tests/modeprint: Print details for IN_FORMATS blob
Date: Sun, 19 Nov 2017 10:49:31 +0100	[thread overview]
Message-ID: <1511084971-7638-3-git-send-email-laanwj@gmail.com> (raw)
In-Reply-To: <1511084971-7638-1-git-send-email-laanwj@gmail.com>

Pretty-print formats and modifiers in IN_FORMATS blob.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>
---
 tests/modeprint/modeprint.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/modeprint/modeprint.c b/tests/modeprint/modeprint.c
index 42c0a1b..ce84279 100644
--- a/tests/modeprint/modeprint.c
+++ b/tests/modeprint/modeprint.c
@@ -93,6 +93,28 @@ static int printMode(struct drm_mode_modeinfo *mode)
 	return 0;
 }
 
+static int printBlob(const char *name, void *data, uint32_t length)
+{
+	if (!strcmp(name, "IN_FORMATS")) {
+		struct drm_format_modifier_blob *m = data;
+		uint32_t *fmts = (uint32_t *)(((char *)data) + m->formats_offset);
+		struct drm_format_modifier *mod = (struct drm_format_modifier *)(((char *)data) + m->modifiers_offset);
+		int i,j,k;
+		printf("\tmodifiers    :\n");
+		for (j = 0; j < (int)m->count_modifiers; j++) {
+			printf("\t\t0x%016" PRIx64, mod[j].modifier);
+			for (i = 0; i < 64 && (i + mod[j].offset) < (int)m->count_formats; i++) {
+				if (mod[j].formats & (1<<i)) {
+					k = i + mod[j].offset;
+					printf(" %c%c%c%c", fmts[k] >> 24, fmts[k] >> 16, fmts[k] >> 8, fmts[k] >> 0);
+				}
+			}
+			printf("\n");
+		}
+	}
+	return 0;
+}
+
 static int printProperty(int fd, drmModePropertyPtr props, uint64_t value)
 {
 	const char *name = NULL;
@@ -120,6 +142,7 @@ static int printProperty(int fd, drmModePropertyPtr props, uint64_t value)
 		blob = drmModeGetPropertyBlob(fd, value);
 		if (blob) {
 			printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data);
+			printBlob(props->name, blob->data, blob->length);
 			drmModeFreePropertyBlob(blob);
 		} else {
 			printf("error getting blob %" PRIu64 "\n", value);
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-11-19  9:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-19  9:49 [PATCH libdrm 0/2] Print plane modifiers in modeprint Wladimir J. van der Laan
2017-11-19  9:49 ` [PATCH libdrm 1/2] tests/modeprint: Print plane and other object properties Wladimir J. van der Laan
2017-11-19  9:49 ` Wladimir J. van der Laan [this message]
2017-11-20 11:36 ` [PATCH libdrm 0/2] Print plane modifiers in modeprint Emil Velikov

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=1511084971-7638-3-git-send-email-laanwj@gmail.com \
    --to=laanwj@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox