aboutsummaryrefslogtreecommitdiff
path: root/hw/display
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2020-09-27 18:57:47 +0400
committerGerd Hoffmann <kraxel@redhat.com>2020-09-29 10:08:25 +0200
commitfd36eade0187a4efe0507b41fae22277300d1c7a (patch)
tree02357862c1df0ef7e58f11ace0789600ae680103 /hw/display
parent6c8f847ac1356387692f224b48c7a83ac5918b5d (diff)
edid: use physical dimensions if available
Replace dpi with width_mm/height_mm in qemu_edid_info. Use it when set (non-zero) to compute the DPI and generate the EDID. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20200927145751.365446-3-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/display')
-rw-r--r--hw/display/edid-generate.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c
index 618c74e1df..1665b7cbb2 100644
--- a/hw/display/edid-generate.c
+++ b/hw/display/edid-generate.c
@@ -205,12 +205,8 @@ static void edid_desc_dummy(uint8_t *desc)
static void edid_desc_timing(uint8_t *desc,
uint32_t xres, uint32_t yres,
- uint32_t dpi)
+ uint32_t xmm, uint32_t ymm)
{
- /* physical display size */
- uint32_t xmm = xres * 254 / 10 / dpi;
- uint32_t ymm = yres * 254 / 10 / dpi;
-
/* pull some realistic looking timings out of thin air */
uint32_t xfront = xres * 25 / 100;
uint32_t xsync = xres * 3 / 100;
@@ -290,12 +286,24 @@ static void edid_colorspace(uint8_t *edid,
edid[34] = white_y >> 2;
}
+static uint32_t qemu_edid_dpi_from_mm(uint32_t mm, uint32_t res)
+{
+ return res * 254 / 10 / mm;
+}
+
+uint32_t qemu_edid_dpi_to_mm(uint32_t dpi, uint32_t res)
+{
+ return res * 254 / 10 / dpi;
+}
+
void qemu_edid_generate(uint8_t *edid, size_t size,
qemu_edid_info *info)
{
uint32_t desc = 54;
uint8_t *xtra3 = NULL;
uint8_t *dta = NULL;
+ uint32_t width_mm, height_mm;
+ uint32_t dpi = 100; /* if no width_mm/height_mm */
/* =============== set defaults =============== */
@@ -305,15 +313,20 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
if (!info->name) {
info->name = "QEMU Monitor";
}
- if (!info->dpi) {
- info->dpi = 100;
- }
if (!info->prefx) {
info->prefx = 1024;
}
if (!info->prefy) {
info->prefy = 768;
}
+ if (info->width_mm && info->height_mm) {
+ width_mm = info->width_mm;
+ height_mm = info->height_mm;
+ dpi = qemu_edid_dpi_from_mm(width_mm, info->prefx);
+ } else {
+ width_mm = qemu_edid_dpi_to_mm(dpi, info->prefx);
+ height_mm = qemu_edid_dpi_to_mm(dpi, info->prefy);
+ }
/* =============== extensions =============== */
@@ -360,8 +373,8 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
edid[20] = 0xa5;
/* screen size: undefined */
- edid[21] = info->prefx * 254 / 100 / info->dpi;
- edid[22] = info->prefy * 254 / 100 / info->dpi;
+ edid[21] = width_mm / 10;
+ edid[22] = height_mm / 10;
/* display gamma: 2.2 */
edid[23] = 220 - 100;
@@ -387,7 +400,8 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
/* =============== descriptor blocks =============== */
- edid_desc_timing(edid + desc, info->prefx, info->prefy, info->dpi);
+ edid_desc_timing(edid + desc, info->prefx, info->prefy,
+ width_mm, height_mm);
desc += 18;
edid_desc_ranges(edid + desc);