qcow2_format.py: QcowHeaderExtension: add dump method
[qemu.git] / qemu-edid.c
blob46eef7049803c0ae6145dc6cf45d29ceeefde519
1 /*
2 * QEMU EDID test tool.
4 * This work is licensed under the terms of the GNU GPL, version 2 or later.
5 * See the COPYING file in the top-level directory.
6 */
7 #include "qemu/osdep.h"
8 #include "qemu/bswap.h"
9 #include "qemu/cutils.h"
10 #include "hw/display/edid.h"
12 static qemu_edid_info info;
14 static void usage(FILE *out)
16 fprintf(out,
17 "\n"
18 "This is a test tool for the qemu edid generator.\n"
19 "\n"
20 "Typically you'll pipe the output into edid-decode\n"
21 "to check if the generator works correctly.\n"
22 "\n"
23 "usage: qemu-edid <options>\n"
24 "options:\n"
25 " -h print this text\n"
26 " -o <file> set output file (stdout by default)\n"
27 " -v <vendor> set monitor vendor (three letters)\n"
28 " -n <name> set monitor name\n"
29 " -s <serial> set monitor serial\n"
30 " -d <dpi> set display resolution\n"
31 " -x <prefx> set preferred width\n"
32 " -y <prefy> set preferred height\n"
33 " -X <maxx> set maximum width\n"
34 " -Y <maxy> set maximum height\n"
35 "\n");
38 int main(int argc, char *argv[])
40 FILE *outfile = NULL;
41 uint8_t blob[256];
42 int rc;
44 for (;;) {
45 rc = getopt(argc, argv, "ho:x:y:X:Y:d:v:n:s:");
46 if (rc == -1) {
47 break;
49 switch (rc) {
50 case 'o':
51 if (outfile) {
52 fprintf(stderr, "outfile specified twice\n");
53 exit(1);
55 outfile = fopen(optarg, "w");
56 if (outfile == NULL) {
57 fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
58 exit(1);
60 break;
61 case 'x':
62 if (qemu_strtoui(optarg, NULL, 10, &info.prefx) < 0) {
63 fprintf(stderr, "not a number: %s\n", optarg);
64 exit(1);
66 break;
67 case 'y':
68 if (qemu_strtoui(optarg, NULL, 10, &info.prefy) < 0) {
69 fprintf(stderr, "not a number: %s\n", optarg);
70 exit(1);
72 break;
73 case 'X':
74 if (qemu_strtoui(optarg, NULL, 10, &info.maxx) < 0) {
75 fprintf(stderr, "not a number: %s\n", optarg);
76 exit(1);
78 break;
79 case 'Y':
80 if (qemu_strtoui(optarg, NULL, 10, &info.maxy) < 0) {
81 fprintf(stderr, "not a number: %s\n", optarg);
82 exit(1);
84 break;
85 case 'd':
86 if (qemu_strtoui(optarg, NULL, 10, &info.dpi) < 0) {
87 fprintf(stderr, "not a number: %s\n", optarg);
88 exit(1);
90 break;
91 case 'v':
92 info.vendor = optarg;
93 break;
94 case 'n':
95 info.name = optarg;
96 break;
97 case 's':
98 info.serial = optarg;
99 break;
100 case 'h':
101 usage(stdout);
102 exit(0);
103 default:
104 usage(stderr);
105 exit(1);
109 if (outfile == NULL) {
110 outfile = stdout;
113 memset(blob, 0, sizeof(blob));
114 qemu_edid_generate(blob, sizeof(blob), &info);
115 fwrite(blob, sizeof(blob), 1, outfile);
116 fflush(outfile);
118 exit(0);