Pretty-print formats and modifiers in IN_FORMATS blob. Signed-off-by: Wladimir J. van der Laan <laanwj@xxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel