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;
14 static void usage(FILE *out)
18 "This is a test tool for the qemu edid generator.\n"
20 "Typically you'll pipe the output into edid-decode\n"
21 "to check if the generator works correctly.\n"
23 "usage: qemu-edid <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"
38 int main(int argc, char *argv[])
45 rc = getopt(argc, argv, "ho:x:y:X:Y:d:v:n:s:");
52 fprintf(stderr, "outfile specified twice\n");
55 outfile = fopen(optarg, "w");
56 if (outfile == NULL) {
57 fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
62 if (qemu_strtoui(optarg, NULL, 10, &info.prefx) < 0) {
63 fprintf(stderr, "not a number: %s\n", optarg);
68 if (qemu_strtoui(optarg, NULL, 10, &info.prefy) < 0) {
69 fprintf(stderr, "not a number: %s\n", optarg);
74 if (qemu_strtoui(optarg, NULL, 10, &info.maxx) < 0) {
75 fprintf(stderr, "not a number: %s\n", optarg);
80 if (qemu_strtoui(optarg, NULL, 10, &info.maxy) < 0) {
81 fprintf(stderr, "not a number: %s\n", optarg);
86 if (qemu_strtoui(optarg, NULL, 10, &info.dpi) < 0) {
87 fprintf(stderr, "not a number: %s\n", optarg);
109 if (outfile == NULL) {
113 memset(blob, 0, sizeof(blob));
114 qemu_edid_generate(blob, sizeof(blob), &info);
115 fwrite(blob, sizeof(blob), 1, outfile);