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/bswap.h"
9 #include "qemu/cutils.h"
10 #include "hw/display/edid.h"
12 static qemu_edid_info info
= {
17 static void usage(FILE *out
)
21 "This is a test tool for the qemu edid generator.\n"
23 "Typically you'll pipe the output into edid-decode\n"
24 "to check if the generator works correctly.\n"
26 "usage: qemu-edid <options>\n"
28 " -h print this text\n"
29 " -o <file> set output file (stdout by default)\n"
30 " -v <vendor> set monitor vendor (three letters)\n"
31 " -n <name> set monitor name\n"
32 " -s <serial> set monitor serial\n"
33 " -d <dpi> set display resolution\n"
34 " -x <prefx> set preferred width\n"
35 " -y <prefy> set preferred height\n"
36 " -X <maxx> set maximum width\n"
37 " -Y <maxy> set maximum height\n"
41 int main(int argc
, char *argv
[])
50 rc
= getopt(argc
, argv
, "ho:x:y:X:Y:d:v:n:s:");
57 fprintf(stderr
, "outfile specified twice\n");
60 outfile
= fopen(optarg
, "w");
61 if (outfile
== NULL
) {
62 fprintf(stderr
, "open %s: %s\n", optarg
, strerror(errno
));
67 if (qemu_strtoui(optarg
, NULL
, 10, &info
.prefx
) < 0) {
68 fprintf(stderr
, "not a number: %s\n", optarg
);
73 if (qemu_strtoui(optarg
, NULL
, 10, &info
.prefy
) < 0) {
74 fprintf(stderr
, "not a number: %s\n", optarg
);
79 if (qemu_strtoui(optarg
, NULL
, 10, &info
.maxx
) < 0) {
80 fprintf(stderr
, "not a number: %s\n", optarg
);
85 if (qemu_strtoui(optarg
, NULL
, 10, &info
.maxy
) < 0) {
86 fprintf(stderr
, "not a number: %s\n", optarg
);
91 if (qemu_strtoui(optarg
, NULL
, 10, &dpi
) < 0) {
92 fprintf(stderr
, "not a number: %s\n", optarg
);
103 info
.serial
= optarg
;
114 if (outfile
== NULL
) {
118 info
.width_mm
= qemu_edid_dpi_to_mm(dpi
, info
.prefx
);
119 info
.height_mm
= qemu_edid_dpi_to_mm(dpi
, info
.prefy
);
121 memset(blob
, 0, sizeof(blob
));
122 qemu_edid_generate(blob
, sizeof(blob
), &info
);
123 size
= qemu_edid_size(blob
);
124 fwrite(blob
, size
, 1, outfile
);