diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2017-04-24 10:48:14 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2017-04-24 10:48:14 +0200 |
commit | a45855472178e478c4cca77458542f1beec666dd (patch) | |
tree | fd6d24671edc9a796a2e19990d04e1bc434f2ebb | |
parent | 7e510e53fe4c715d1a3630910136bfded41fbfbd (diff) | |
download | drminfo-a45855472178e478c4cca77458542f1beec666dd.tar.gz |
more list format tweaks
-rw-r--r-- | drminfo.c | 8 | ||||
-rw-r--r-- | drmtest.c | 2 | ||||
-rw-r--r-- | drmtools.c | 28 | ||||
-rw-r--r-- | drmtools.h | 3 |
4 files changed, 28 insertions, 13 deletions
@@ -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"); } @@ -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); } @@ -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"); } @@ -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); |