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.
7 #include "qemu/osdep.h"
8 #include "qemu-common.h"
9 #include "qemu/bswap.h"
10 #include "qemu/cutils.h"
11 #include "hw/display/edid.h"
13 static qemu_edid_info info
;
15 static void usage(FILE *out
)
19 "This is a test tool for the qemu edid generator.\n"
21 "Typically you'll pipe the output into edid-decode\n"
22 "to check if the generator works correctly.\n"
24 "usage: qemu-edid <options>\n"
26 " -h print this text\n"
27 " -o <file> set output file (stdout by default)\n"
28 " -v <vendor> set monitor vendor (three letters)\n"
29 " -n <name> set monitor name\n"
30 " -s <serial> set monitor serial\n"
31 " -d <dpi> set display resolution\n"
32 " -x <prefx> set preferred width\n"
33 " -y <prefy> set preferred height\n"
34 " -X <maxx> set maximum width\n"
35 " -Y <maxy> set maximum height\n"
39 int main(int argc
, char *argv
[])
46 rc
= getopt(argc
, argv
, "ho:x:y:X:Y:d:v:n:s:");
53 fprintf(stderr
, "outfile specified twice\n");
56 outfile
= fopen(optarg
, "w");
57 if (outfile
== NULL
) {
58 fprintf(stderr
, "open %s: %s\n", optarg
, strerror(errno
));
63 if (qemu_strtoui(optarg
, NULL
, 10, &info
.prefx
) < 0) {
64 fprintf(stderr
, "not a number: %s\n", optarg
);
69 if (qemu_strtoui(optarg
, NULL
, 10, &info
.prefy
) < 0) {
70 fprintf(stderr
, "not a number: %s\n", optarg
);
75 if (qemu_strtoui(optarg
, NULL
, 10, &info
.maxx
) < 0) {
76 fprintf(stderr
, "not a number: %s\n", optarg
);
81 if (qemu_strtoui(optarg
, NULL
, 10, &info
.maxy
) < 0) {
82 fprintf(stderr
, "not a number: %s\n", optarg
);
87 if (qemu_strtoui(optarg
, NULL
, 10, &info
.dpi
) < 0) {
88 fprintf(stderr
, "not a number: %s\n", optarg
);
110 if (outfile
== NULL
) {
114 memset(blob
, 0, sizeof(blob
));
115 qemu_edid_generate(blob
, sizeof(blob
), &info
);
116 fwrite(blob
, sizeof(blob
), 1, outfile
);