qemu-e2k/qemu-edid.c

129 lines
3.6 KiB
C
Raw Normal View History

/*
* 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/bswap.h"
#include "qemu/cutils.h"
#include "hw/display/edid.h"
static qemu_edid_info info = {
edid: set default resolution to 1280x800 (WXGA) Currently QEMU defaults to a resolution of 1024x768 when exposing EDID info to the guest OS. The EDID default info is important as this will influence what resolution many guest OS will configure the screen with on boot. It can also potentially influence what resolution the firmware will configure the screen with, though until very recently EDK2 would not handle EDID info. One important thing to bear in mind is that the default graphics card driver provided by Windows will leave the display set to whatever resolution was enabled by the firmware on boot. Even if sufficient VRAM is available, the resolution can't be changed without installing new drivers. IOW, the default resolution choice is quite important for usability of Windows. Modern real world monitor hardware for desktop/laptop has supported resolutions higher than 1024x768 for a long time now, perhaps as long as 15+ years. There are quite a wide variety of native resolutions in use today, however, and in wide screen form factors the height may not be all that tall. None the less, it is considered that there is scope for making the QEMU default resolution slightly larger. In considering what possible new default could be suitable, choices considered were 1280x720 (720p), 1280x800 (WXGA) and 1280x1024 (SXGA). In many ways, vertical space is the most important, and so 720p was discarded due to loosing vertical space, despite being 25% wider. The SXGA resolution would be good, but when taking into account window titlebars/toolbars and window manager desktop UI, this might be a little too tall for some users to fit the guest on their physical montior. This patch thus suggests a modest change to 1280x800 (WXGA). This only consumes 1 MB per colour channel, allowing double buffered framebuffer in 8 MB of VRAM. Width wise this is 25% larger than QEMU's current default, but height wise this only adds 5%, so the difference isn't massive on the QEMU side. Overall there doesn't appear to be a compelling reason to stick with 1024x768 resolution. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20211129140508.1745130-1-berrange@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-11-29 15:05:08 +01:00
.prefx = 1280,
.prefy = 800,
};
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[512];
size_t size;
uint32_t dpi = 100;
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, &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;
}
info.width_mm = qemu_edid_dpi_to_mm(dpi, info.prefx);
info.height_mm = qemu_edid_dpi_to_mm(dpi, info.prefy);
memset(blob, 0, sizeof(blob));
qemu_edid_generate(blob, sizeof(blob), &info);
size = qemu_edid_size(blob);
fwrite(blob, size, 1, outfile);
fflush(outfile);
exit(0);
}