diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2018-09-25 09:56:42 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-09-27 08:07:51 +0200 |
commit | 72d277a70e8b2d4eb1b3667ab934fb1fecf41410 (patch) | |
tree | 14f8fa96ede6c8b499a645d88c45c0c5d8f83b06 /qemu-edid.c | |
parent | c5e4e49258e9b89cb34c085a419dd9f862935c48 (diff) |
display/edid: add edid generator to qemu.
EDID is a metadata format to describe monitors. On physical hardware
the monitor has an eeprom with that data block which can be read over
i2c bus.
On a linux system you can usually find the EDID data block in
/sys/class/drm/$card/$connector/edid. xorg ships a edid-decode utility
which you can use to turn the blob into readable form.
I think it would be a good idea to use EDID for virtual displays too.
Needs changes in both qemu and guest kms drivers. This patch is the
first step, it adds an generator for EDID blobs to qemu. Comes with a
qemu-edid test tool included.
With EDID we can pass more information to the guest. Names and serial
numbers, so the guests display configuration has no boring "Unknown
Monitor". List of video modes. Display resolution, pretty important
in case we want add HiDPI support some day.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20180925075646.25114-2-kraxel@redhat.com
Diffstat (limited to 'qemu-edid.c')
-rw-r--r-- | qemu-edid.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/qemu-edid.c b/qemu-edid.c new file mode 100644 index 0000000000..ae8b8a6d9b --- /dev/null +++ b/qemu-edid.c @@ -0,0 +1,120 @@ +/* + * QEMU EDID test tool. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qemu/bswap.h" +#include "qemu/cutils.h" +#include "hw/display/edid.h" + +static qemu_edid_info info; + +static void usage(FILE *out) +{ + fprintf(out, + "\n" + "This is a test tool for the qemu edid generator.\n" + "\n" + "Typically you'll pipe the output into edid-decode\n" + "to check if the generator works correctly.\n" + "\n" + "usage: qemu-edid <options>\n" + "options:\n" + " -h print this text\n" + " -o <file> set output file (stdout by default)\n" + " -v <vendor> set monitor vendor (three letters)\n" + " -n <name> set monitor name\n" + " -s <serial> set monitor serial\n" + " -d <dpi> set display resolution\n" + " -x <prefx> set preferred width\n" + " -y <prefy> set preferred height\n" + " -X <maxx> set maximum width\n" + " -Y <maxy> set maximum height\n" + "\n"); +} + +int main(int argc, char *argv[]) +{ + FILE *outfile = NULL; + uint8_t blob[256]; + int rc; + + for (;;) { + rc = getopt(argc, argv, "ho:x:y:X:Y:d:v:n:s:"); + if (rc == -1) { + break; + } + switch (rc) { + case 'o': + if (outfile) { + fprintf(stderr, "outfile specified twice\n"); + exit(1); + } + outfile = fopen(optarg, "w"); + if (outfile == NULL) { + fprintf(stderr, "open %s: %s\n", optarg, strerror(errno)); + exit(1); + } + break; + case 'x': + if (qemu_strtoui(optarg, NULL, 10, &info.prefx) < 0) { + fprintf(stderr, "not a number: %s\n", optarg); + exit(1); + } + break; + case 'y': + if (qemu_strtoui(optarg, NULL, 10, &info.prefy) < 0) { + fprintf(stderr, "not a number: %s\n", optarg); + exit(1); + } + break; + case 'X': + if (qemu_strtoui(optarg, NULL, 10, &info.maxx) < 0) { + fprintf(stderr, "not a number: %s\n", optarg); + exit(1); + } + break; + case 'Y': + if (qemu_strtoui(optarg, NULL, 10, &info.maxy) < 0) { + fprintf(stderr, "not a number: %s\n", optarg); + exit(1); + } + break; + case 'd': + if (qemu_strtoui(optarg, NULL, 10, &info.dpi) < 0) { + fprintf(stderr, "not a number: %s\n", optarg); + exit(1); + } + break; + case 'v': + info.vendor = optarg; + break; + case 'n': + info.name = optarg; + break; + case 's': + info.serial = optarg; + break; + case 'h': + usage(stdout); + exit(0); + default: + usage(stderr); + exit(1); + } + } + + if (outfile == NULL) { + outfile = stdout; + } + + memset(blob, 0, sizeof(blob)); + qemu_edid_generate(blob, sizeof(blob), &info); + fwrite(blob, sizeof(blob), 1, outfile); + fflush(outfile); + + exit(0); +} |