aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drminfo.c8
-rw-r--r--drmtest.c2
-rw-r--r--drmtools.c28
-rw-r--r--drmtools.h3
4 files changed, 28 insertions, 13 deletions
diff --git a/drminfo.c b/drminfo.c
index c270be7..275277c 100644
--- a/drminfo.c
+++ b/drminfo.c
@@ -99,7 +99,7 @@ static void drm_info_fmts(int fd)
for (i = 0; i < fmtcnt; i++) {
if (!drm_probe_format(fd, &fmts[i]))
continue;
- drm_print_format(stdout, &fmts[i], " ", "");
+ drm_print_format(stdout, &fmts[i], 4, true);
}
fprintf(stdout, "\n");
}
@@ -164,14 +164,12 @@ static void drm_info(int devnr)
static void list_formats(FILE *fp)
{
- char libs[64];
int i;
fprintf(stdout, "all known framebuffer formats (rgb + packed yuv)\n");
+ drm_print_format_hdr(stdout, 0, true);
for (i = 0; i < fmtcnt; i++) {
- snprintf(libs, sizeof(libs), " %s",
- (fmts[i].cairo == CAIRO_FORMAT_INVALID) ? "" : "cairo");
- drm_print_format(stdout, &fmts[i], "", libs);
+ drm_print_format(stdout, &fmts[i], 0, true);
}
fprintf(stdout, "\n");
}
diff --git a/drmtest.c b/drmtest.c
index bd0ac5f..ab7be00 100644
--- a/drmtest.c
+++ b/drmtest.c
@@ -516,7 +516,7 @@ int main(int argc, char **argv)
for (i = 0; i < fmtcnt; i++) {
if (fmts[i].cairo == CAIRO_FORMAT_INVALID)
continue;
- drm_print_format(stderr, &fmts[i], " ", "");
+ drm_print_format(stderr, &fmts[i], 4, false);
}
exit(1);
}
diff --git a/drmtools.c b/drmtools.c
index b09bab8..8442e44 100644
--- a/drmtools.c
+++ b/drmtools.c
@@ -513,13 +513,29 @@ done:
}
void drm_print_format(FILE *fp, const struct fbformat *fmt,
- const char *pre, const char *post)
+ int indent, bool libs)
{
- fprintf(fp, "%s%-8s: [%2d:0] %-14s %-11s %-24s%s\n",
- pre,
+ fprintf(fp, "%*s%-8s: [%2d:0] %-14s %-11s %-16s",
+ indent, "",
fmt->name, fmt->bpp - 1, fmt->fields, fmt->bits,
fmt->fourcc
- ? "fourcc (addfb2), le"
- : "legacy (addfb), cpu " LE_BE("(le)", "(be)"),
- post);
+ ? "fourcc le"
+ : "legacy cpu " LE_BE("(le)", "(be)"));
+ if (libs) {
+ fprintf(fp, " %s",
+ (fmt->cairo == CAIRO_FORMAT_INVALID) ? "" : "cairo");
+ }
+ fprintf(fp, "\n");
+}
+
+void drm_print_format_hdr(FILE *fp, int indent, bool libs)
+{
+ fprintf(fp, "%*s%-8s: %-6s %-14s %-11s %-16s",
+ indent, "",
+ "name", "bpp", "fields", "bits",
+ "type endian");
+ if (libs) {
+ fprintf(fp, " libs");
+ }
+ fprintf(fp, "\n");
}
diff --git a/drmtools.h b/drmtools.h
index ed3073f..d1a3f2f 100644
--- a/drmtools.h
+++ b/drmtools.h
@@ -19,4 +19,5 @@ const char *drm_encoder_type_name(int nr);
void drm_conn_name(drmModeConnector *conn, char *dest, int dlen);
bool drm_probe_format(int fd, const struct fbformat *fmt);
void drm_print_format(FILE *fp, const struct fbformat *fmt,
- const char *pre, const char *post);
+ int indent, bool libs);
+void drm_print_format_hdr(FILE *fp, int indent, bool libs);