diff options
author | Markus Pargmann <mpa@pengutronix.de> | 2015-02-10 13:55:38 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2015-02-12 17:16:14 +0100 |
commit | b2cdcedf621dc0a20f7ce53493a11d7efccf46a4 (patch) | |
tree | 451f7c159615565f48d688a317000d30750b210a | |
parent | 2b43451fdc21698a46da04033e2bdc12c309db60 (diff) | |
download | kmsfbwrap-b2cdcedf621dc0a20f7ce53493a11d7efccf46a4.tar.gz kmsfbwrap-b2cdcedf621dc0a20f7ce53493a11d7efccf46a4.tar.xz |
print: Add quiet option
Only warnings and errors are printed with the quiet option enabled.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | src/kmsfb-manage.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/kmsfb-manage.c b/src/kmsfb-manage.c index 70559a2..5c788b1 100644 --- a/src/kmsfb-manage.c +++ b/src/kmsfb-manage.c @@ -31,6 +31,13 @@ #include "kmsfb.h" int debug; +int quiet; + +#define print(fmt, ...) \ + do { \ + if (!quiet) \ + printf(fmt, ##__VA_ARGS__); \ + } while (0) struct drm_connector { uint32_t id; @@ -649,7 +656,7 @@ static int drm_mode_get_dumb(int fd, struct kms_fb *fb) map.handle = dumb.handle; map.offset = 0x5359485000000000; - printf("dumb handle: %d\n", dumb.handle); + print("dumb handle: %d\n", dumb.handle); err = ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &map); if (err) { @@ -801,6 +808,8 @@ static struct option long_options[] = { static void line(const char *str) { + if (quiet) + return; printf("------------------------ %s ------------------------\n", str); } @@ -873,10 +882,10 @@ static int create_window(struct drm_resource *res, const char *in) if (!kd.encoder) { if (drmcon->encoder_id) { - printf("using current encoder %d\n", drmcon->encoder_id); + print("using current encoder %d\n", drmcon->encoder_id); } else if (drmcon->num_encoders > 0) { drmcon->encoder_id = drmcon->encoders[0]; - printf("using first available encoder %d\n", drmcon->encoder_id); + print("using first available encoder %d\n", drmcon->encoder_id); } kd.encoder = drmcon->encoder_id; } @@ -890,14 +899,14 @@ static int create_window(struct drm_resource *res, const char *in) if (!kd.crtc) { if (drmenc->crtc_id > 0) { - printf("using current crtc %d\n", drmenc->crtc_id); + print("using current crtc %d\n", drmenc->crtc_id); kd.crtc = drmenc->crtc_id; } else { for (i = 0, p = drmenc->possible_crtcs; p && (i < res->num_crtcs); p >>= 1, i++) { if (p & 1) { kd.crtc = res->crtcs[i].crtc_id; - printf("using first possible crtc %d\n", + print("using first possible crtc %d\n", kd.crtc); break; } @@ -962,7 +971,7 @@ static int create_overlay(struct drm_resource *res, const char *in) if (!kd.plane) { kd.plane = res->planes[0].plane_id; - printf("using first plane %d\n", kd.plane); + print("using first plane %d\n", kd.plane); } for (i = 0; i < res->num_planes; i++) { @@ -986,7 +995,7 @@ static int create_overlay(struct drm_resource *res, const char *in) return -1; } kd.crtc = res->crtcs[i].crtc_id; - printf("using first possible crtc %d\n", kd.crtc); + print("using first possible crtc %d\n", kd.crtc); } ret = drm_mode_set_plane(drmfd, kd.plane, kd.crtc, @@ -1231,7 +1240,7 @@ static int fb_create(struct drm_resource *res, int fd, const char *cmd) if (ret) return ret; - printf("created framebuffer: %dx%d, pitch %d, bpp %d\n", + print("created framebuffer: %dx%d, pitch %d, bpp %d\n", fb->xres, fb->yres, fb->pitch, fb->bpp); return 0; @@ -1272,6 +1281,7 @@ static void usage(const char *prgname) " xofs, yofs [optional]: offset in pixels into the FB\n" " xpos, ypos [optional]: top left position of the overlay plane (default: 0,0)\n" "-d debug\n" + "-q quiet\n" , prgname); exit(1); } @@ -1295,7 +1305,7 @@ int main(int argc, char *argv[]) pid = fork(); if (pid > 0) { - printf("kmsfb-manage forking init\n"); + print("kmsfb-manage forking init\n"); execl("/sbin/init", "/sbin/init", NULL); exit(1); } @@ -1367,7 +1377,7 @@ int main(int argc, char *argv[]) while (1) { int option_index = 0; - c = getopt_long(argc, parse_args, "f:w:o:hsd", + c = getopt_long(argc, parse_args, "f:w:o:hsdq", long_options, &option_index); if (c == -1) break; @@ -1401,6 +1411,9 @@ int main(int argc, char *argv[]) case 'd': debug = 1; break; + case 'q': + quiet = 1; + break; default: printf("getopt returned %d %c\n", c, c); } |