summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Borneo <antonio.borneo@st.com>2019-06-18 10:53:57 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2019-07-23 15:11:34 +0200
commite888ea1d233b2639b87a68e099d18d4e919905df (patch)
tree6a0d5540a12bb4686ee9975621ba2d3ccd2a56be
parenta0a4c0238026b24ac7ace5919132921160673ce2 (diff)
texturator: add command-line selection of video mode
Extend also to texturator the command line flag to select the video mode. Signed-off-by: Antonio Borneo <antonio.borneo@st.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
-rw-r--r--texturator.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/texturator.c b/texturator.c
index 8fcdb39..ddd8014 100644
--- a/texturator.c
+++ b/texturator.c
@@ -795,13 +795,14 @@ static void print_summary(void)
printf("FS:\n%s\n", get_fs());
}
-static const char *shortopts = "D:e:fsz";
+static const char *shortopts = "D:e:fsv:z";
static const struct option longopts[] = {
{"device", required_argument, 0, 'D'},
{"errors", required_argument, 0, 'e'},
{"full", no_argument, 0, 'f'},
{"stop", no_argument, 0, 's'},
+ {"vmode", required_argument, 0, 'v'},
{"zoom", no_argument, 0, 'z'},
#ifdef HAVE_LIBPNG
{"png", no_argument, 0, 'p'},
@@ -811,13 +812,15 @@ static const struct option longopts[] = {
static void usage(const char *name)
{
- printf("Usage: %1$s [-Dz] <target> <format> <minsize> [<maxsize>]\n"
+ printf("Usage: %1$s [-Dvz] <target> <format> <minsize> [<maxsize>]\n"
"\n"
"options:\n"
" -D, --device=DEVICE use the given device\n"
" -e, --errors=N stop after N frames with errors (default 5)\n"
" -f, --full check all pixels (do not stop after first faulty pixel)\n"
" -s, --stop exit after testing all sizes\n"
+ " -v, --vmode=VMODE specify the video mode in the format\n"
+ " <mode>[-<vrefresh>]\n"
" -z, --zoom increase zoom (can be specified multiple times)\n"
#ifdef HAVE_LIBPNG
" -p, --png capture the screen to a png image\n"
@@ -853,7 +856,11 @@ static void parse_dims(const char *argv0, const char *sizestr, struct size *size
int main(int argc, char *argv[])
{
const char *device = "/dev/dri/card0";
+ char mode_str[DRM_DISPLAY_MODE_LEN] = "";
+ char *p;
int ret, opt;
+ unsigned int len;
+ unsigned int vrefresh = 0;
while ((opt = getopt_long_only(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (opt) {
@@ -869,6 +876,19 @@ int main(int argc, char *argv[])
case 's':
stop = true;
break;
+ case 'v':
+ p = strchr(optarg, '-');
+ if (p == NULL) {
+ len = strlen(optarg);
+ } else {
+ vrefresh = strtoul(p + 1, NULL, 0);
+ len = p - optarg;
+ }
+ if (len > sizeof(mode_str) - 1)
+ len = sizeof(mode_str) - 1;
+ strncpy(mode_str, optarg, len);
+ mode_str[len] = '\0';
+ break;
case 'z':
zoom++;
break;
@@ -928,7 +948,7 @@ int main(int argc, char *argv[])
print_summary();
/* no real need for atomic here: */
- drm = init_drm_legacy(device, NULL, 0);
+ drm = init_drm_legacy(device, mode_str, vrefresh);
if (!drm) {
printf("failed to initialize DRM\n");
return -1;