From 1610c58420e173238656ad11d5f26bf0b0d91edd Mon Sep 17 00:00:00 2001 From: "Leo (Sunpeng) Li" Date: Wed, 28 Mar 2018 10:27:08 -0400 Subject: Add output option, modify help text accordingly. Signed-off-by: Leo (Sunpeng) Li --- demo.c | 15 ++++++++++++--- help.txt | 8 +++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/demo.c b/demo.c index 7c151e9..ead3ba8 100644 --- a/demo.c +++ b/demo.c @@ -609,18 +609,21 @@ int main(int argc, char *const argv[]) char *degamma_opt = NULL; char *ctm_opt = NULL; char *regamma_opt = NULL; + char *output_name = NULL; int degamma_changed, degamma_is_srgb; int ctm_changed; int regamma_changed, regamma_is_srgb; - while ((opt = getopt(argc, argv, "hd:c:r:")) != -1) { + while ((opt = getopt(argc, argv, "ho:d:c:r:")) != -1) { if (opt == 'd') degamma_opt = optarg; else if (opt == 'c') ctm_opt = optarg; else if (opt == 'r') regamma_opt = optarg; + else if (opt == 'o') + output_name = optarg; else if (opt == 'h') { printf("%s", HELP_STR); return 0; @@ -631,6 +634,12 @@ int main(int argc, char *const argv[]) } } + /* Check that output is given */ + if (!output_name) { + print_short_help(); + return 0; + } + /* Parse the input, and generate the intermediate coefficient arrays */ degamma_changed = parse_user_degamma(degamma_opt, degamma_coeffs, °amma_is_srgb); @@ -661,9 +670,9 @@ int main(int argc, char *const argv[]) /* RandR needs to know which output we're setting the property on. * Since we only have a name to work with, find the RROutput using the * name. */ - output = find_output_by_name(dpy, res, "DisplayPort-0"); + output = find_output_by_name(dpy, res, output_name); if (!output) { - printf("Cannot find output!\n"); + printf("Cannot find output %s.\n", output_name); goto done; } diff --git a/help.txt b/help.txt index 26be4c1..d315bc0 100644 --- a/help.txt +++ b/help.txt @@ -1,9 +1,15 @@ -Usage: demo [-d DEGAMMA_OPTS] [-c CTM_OPTS] [-r REGAMMA_OPTS] [-h] +Usage: demo -o OUTPUT_NAME [-d DEGAMMA_OPTS] [-c CTM_OPTS] [-r REGAMMA_OPTS] [-h] Demo app for for creating DRM color/CTM blobs, then setting it via xrandr. Note that this requires updates to the amdpgu DDX driver for color management support. +Mandatory arguments: + + -o OUTPUT_NAME + The output name, as listed in xrandr + + Optional arguments: -d DEGAMMA_OPTS -- cgit v1.2.3