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>
Antonio Borneo authored 4 years ago
Antonio Borneo committed 4 years ago
794 | 794 | printf("FS:\n%s\n", get_fs()); |
795 | 795 | } |
796 | 796 | |
797 | static const char *shortopts = "D:e:fsz"; | |
797 | static const char *shortopts = "D:e:fsv:z"; | |
798 | 798 | |
799 | 799 | static const struct option longopts[] = { |
800 | 800 | {"device", required_argument, 0, 'D'}, |
801 | 801 | {"errors", required_argument, 0, 'e'}, |
802 | 802 | {"full", no_argument, 0, 'f'}, |
803 | 803 | {"stop", no_argument, 0, 's'}, |
804 | {"vmode", required_argument, 0, 'v'}, | |
804 | 805 | {"zoom", no_argument, 0, 'z'}, |
805 | 806 | #ifdef HAVE_LIBPNG |
806 | 807 | {"png", no_argument, 0, 'p'}, |
810 | 811 | |
811 | 812 | static void usage(const char *name) |
812 | 813 | { |
813 | printf("Usage: %1$s [-Dz] <target> <format> <minsize> [<maxsize>]\n" | |
814 | printf("Usage: %1$s [-Dvz] <target> <format> <minsize> [<maxsize>]\n" | |
814 | 815 | "\n" |
815 | 816 | "options:\n" |
816 | 817 | " -D, --device=DEVICE use the given device\n" |
817 | 818 | " -e, --errors=N stop after N frames with errors (default 5)\n" |
818 | 819 | " -f, --full check all pixels (do not stop after first faulty pixel)\n" |
819 | 820 | " -s, --stop exit after testing all sizes\n" |
821 | " -v, --vmode=VMODE specify the video mode in the format\n" | |
822 | " <mode>[-<vrefresh>]\n" | |
820 | 823 | " -z, --zoom increase zoom (can be specified multiple times)\n" |
821 | 824 | #ifdef HAVE_LIBPNG |
822 | 825 | " -p, --png capture the screen to a png image\n" |
852 | 855 | int main(int argc, char *argv[]) |
853 | 856 | { |
854 | 857 | const char *device = "/dev/dri/card0"; |
858 | char mode_str[DRM_DISPLAY_MODE_LEN] = ""; | |
859 | char *p; | |
855 | 860 | int ret, opt; |
861 | unsigned int len; | |
862 | unsigned int vrefresh = 0; | |
856 | 863 | |
857 | 864 | while ((opt = getopt_long_only(argc, argv, shortopts, longopts, NULL)) != -1) { |
858 | 865 | switch (opt) { |
868 | 875 | case 's': |
869 | 876 | stop = true; |
870 | 877 | break; |
878 | case 'v': | |
879 | p = strchr(optarg, '-'); | |
880 | if (p == NULL) { | |
881 | len = strlen(optarg); | |
882 | } else { | |
883 | vrefresh = strtoul(p + 1, NULL, 0); | |
884 | len = p - optarg; | |
885 | } | |
886 | if (len > sizeof(mode_str) - 1) | |
887 | len = sizeof(mode_str) - 1; | |
888 | strncpy(mode_str, optarg, len); | |
889 | mode_str[len] = '\0'; | |
890 | break; | |
871 | 891 | case 'z': |
872 | 892 | zoom++; |
873 | 893 | break; |
927 | 947 | print_summary(); |
928 | 948 | |
929 | 949 | /* no real need for atomic here: */ |
930 | drm = init_drm_legacy(device, NULL, 0); | |
950 | drm = init_drm_legacy(device, mode_str, vrefresh); | |
931 | 951 | if (!drm) { |
932 | 952 | printf("failed to initialize DRM\n"); |
933 | 953 | return -1; |