From patchwork Fri Sep 21 08:59:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10609429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CB13112B for ; Fri, 21 Sep 2018 09:19:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C0AF2DA5D for ; Fri, 21 Sep 2018 09:19:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3E0C2DB13; Fri, 21 Sep 2018 09:19:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EEF362DA5D for ; Fri, 21 Sep 2018 09:19:27 +0000 (UTC) Received: from localhost ([::1]:54734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Hax-0001N7-9W for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:19:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HHQ-0000jv-Sa for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3HHN-00078R-Vo for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36830) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3HHN-000780-NK for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:13 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13FA030820D9 for ; Fri, 21 Sep 2018 08:59:13 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6195A89AEE; Fri, 21 Sep 2018 08:59:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2A48941A71; Fri, 21 Sep 2018 10:59:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 10:59:01 +0200 Message-Id: <20180921085905.3038-2-kraxel@redhat.com> In-Reply-To: <20180921085905.3038-1-kraxel@redhat.com> References: <20180921085905.3038-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 21 Sep 2018 08:59:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/5] display/edid: add edid generator to qemu. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- configure | 2 +- Makefile | 2 + include/hw/display/edid.h | 18 +++ hw/display/edid-generate.c | 334 +++++++++++++++++++++++++++++++++++++++++++++ qemu-edid.c | 120 ++++++++++++++++ hw/display/Makefile.objs | 2 + 6 files changed, 477 insertions(+), 1 deletion(-) create mode 100644 include/hw/display/edid.h create mode 100644 hw/display/edid-generate.c create mode 100644 qemu-edid.c diff --git a/configure b/configure index 58862d2ae8..053facfb68 100755 --- a/configure +++ b/configure @@ -5715,7 +5715,7 @@ fi tools="" if test "$want_tools" = "yes" ; then - tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools" + tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools" if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then tools="qemu-nbd\$(EXESUF) $tools" fi diff --git a/Makefile b/Makefile index fe623e4634..7bb6675f4a 100644 --- a/Makefile +++ b/Makefile @@ -543,6 +543,8 @@ qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS) qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS) +qemu-edid$(EXESUF): qemu-edid.o hw/display/edid-generate.o $(COMMON_LDADDS) + fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS) fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap diff --git a/include/hw/display/edid.h b/include/hw/display/edid.h new file mode 100644 index 0000000000..63b60015c3 --- /dev/null +++ b/include/hw/display/edid.h @@ -0,0 +1,18 @@ +#ifndef EDID_H +#define EDID_H + +typedef struct qemu_edid_info { + const char *vendor; + const char *name; + const char *serial; + uint32_t dpi; + uint32_t prefx; + uint32_t prefy; + uint32_t maxx; + uint32_t maxy; +} qemu_edid_info; + +void qemu_edid_generate(uint8_t *edid, size_t size, + qemu_edid_info *info); + +#endif /* EDID_H */ diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c new file mode 100644 index 0000000000..e439b1e893 --- /dev/null +++ b/hw/display/edid-generate.c @@ -0,0 +1,334 @@ +/* + * QEMU EDID generator. + * + * 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 "hw/display/edid.h" + +static const struct edid_mode { + uint32_t xres; + uint32_t yres; + uint32_t byte; + uint32_t xtra3; + uint32_t bit; +} modes[] = { + /* other */ + { .xres = 2048, .yres = 1152 }, + { .xres = 1920, .yres = 1440 }, + { .xres = 1920, .yres = 1080 }, + + /* additional standard timings 3 (all @75Hz) */ + { .xres = 1920, .yres = 1200, .xtra3 = 11, .bit = 7 }, + { .xres = 1856, .yres = 1392, .xtra3 = 10, .bit = 2 }, + { .xres = 1792, .yres = 1344, .xtra3 = 10, .bit = 4 }, + { .xres = 1600, .yres = 1200, .xtra3 = 10, .bit = 7 }, + { .xres = 1680, .yres = 1050, .xtra3 = 9, .bit = 4 }, + { .xres = 1440, .yres = 1050, .xtra3 = 8, .bit = 0 }, + { .xres = 1440, .yres = 900, .xtra3 = 8, .bit = 4 }, + { .xres = 1280, .yres = 768, .xtra3 = 7, .bit = 5 }, + + /* established timings (all @75Hz) */ + { .xres = 1280, .yres = 1024, .byte = 36, .bit = 0 }, + { .xres = 1024, .yres = 768, .byte = 36, .bit = 1 }, + { .xres = 800, .yres = 600, .byte = 36, .bit = 6 }, + { .xres = 640, .yres = 480, .byte = 35, .bit = 2 }, +}; + +static int edid_std_mode(uint8_t *mode, uint32_t xres, uint32_t yres) +{ + uint32_t aspect; + + if (xres == 0 || yres == 0) { + mode[0] = 0x01; + mode[1] = 0x01; + return 0; + + } else if (xres * 10 == yres * 16) { + aspect = 0; + } else if (xres * 3 == yres * 4) { + aspect = 1; + } else if (xres * 4 == yres * 5) { + aspect = 2; + } else if (xres * 9 == yres * 16) { + aspect = 3; + } else { + return -1; + } + + mode[0] = (xres / 8) - 31; + mode[1] = ((aspect << 6) | (75 - 60)); + return 0; +} + +static void edid_fill_modes(uint8_t *edid, uint8_t *xtra3, + uint32_t maxx, uint32_t maxy) +{ + const struct edid_mode *mode; + int std = 38; + int rc, i; + + for (i = 0; i < ARRAY_SIZE(modes); i++) { + mode = modes + i; + + if ((maxx && mode->xres > maxx) || + (maxy && mode->yres > maxy)) { + continue; + } + + if (mode->byte) { + edid[mode->byte] |= (1 << mode->bit); + } else if (mode->xtra3 && xtra3) { + xtra3[mode->xtra3] |= (1 << mode->bit); + } else if (std < 54) { + rc = edid_std_mode(edid + std, mode->xres, mode->yres); + if (rc == 0) { + std += 2; + } + } + } + + while (std < 54) { + edid_std_mode(edid + std, 0, 0); + std += 2; + } +} + +static void edid_checksum(uint8_t *edid) +{ + uint32_t sum = 0; + int i; + + for (i = 0; i < 127; i++) { + sum += edid[i]; + } + sum &= 0xff; + if (sum) { + edid[127] = 0x100 - sum; + } +} + +static void edid_desc_type(uint8_t *desc, uint8_t type) +{ + desc[0] = 0; + desc[1] = 0; + desc[2] = 0; + desc[3] = type; + desc[4] = 0; +} + +static void edid_desc_text(uint8_t *desc, uint8_t type, + const char *text) +{ + size_t len; + + edid_desc_type(desc, type); + memset(desc + 5, ' ', 13); + + len = strlen(text); + if (len > 12) + len = 12; + strncpy((char*)(desc + 5), text, len); + desc[ 5 + len ] = '\n'; +} + +static void edid_desc_ranges(uint8_t *desc) +{ + edid_desc_type(desc, 0xfd); + + /* vertical */ + desc[ 5] = 50; + desc[ 6] = 100; + + /* horizontal */ + desc[ 7] = 30; + desc[ 8] = 120; + + /* dot clock */ + desc[ 9] = 250 / 10; + + /* padding */ + desc[11] = '\n'; + memset(desc + 12, ' ', 6); +} + +/* additional standard timings 3 */ +static void edid_desc_xtra3_std(uint8_t *desc) +{ + edid_desc_type(desc, 0xf7); + desc[5] = 10; +} + +static void edid_desc_dummy(uint8_t *desc) +{ + edid_desc_type(desc, 0x10); +} + +static void edid_desc_timing(uint8_t *desc, + uint32_t xres, uint32_t yres, + uint32_t dpi) +{ + /* physical display size */ + uint32_t xmm = xres * dpi / 254; + uint32_t ymm = yres * dpi / 254; + + /* pull some realistic looking timings out of thin air */ + uint32_t xfront = xres * 25 / 100; + uint32_t xsync = xres * 3 / 100; + uint32_t xblank = xres * 35 / 100; + + uint32_t yfront = yres * 5 / 1000; + uint32_t ysync = yres * 5 / 1000; + uint32_t yblank = yres * 35 / 1000; + + uint32_t clock = 75 * (xres + xblank) * (yres + yblank); + + *(uint32_t*)(desc) = cpu_to_le32(clock / 10000); + + desc[2] = xres & 0xff; + desc[3] = xblank & 0xff; + desc[4] = ((( xres & 0xf00 ) >> 4) | + (( xblank & 0xf00 ) >> 8)); + + desc[5] = yres & 0xff; + desc[6] = yblank & 0xff; + desc[7] = ((( yres & 0xf00 ) >> 4) | + (( yblank & 0xf00 ) >> 8)); + + desc[8] = xfront & 0xff; + desc[9] = xsync & 0xff; + + desc[10] = ((( yfront & 0x00f ) << 4) | + (( ysync & 0x00f ) << 0)); + desc[11] = ((( xfront & 0x300 ) >> 2) | + (( xsync & 0x300 ) >> 4) | + (( yfront & 0x030 ) >> 2) | + (( ysync & 0x030 ) >> 4)); + + desc[12] = xmm & 0xff; + desc[13] = ymm & 0xff; + desc[14] = ((( xmm & 0xf00 ) >> 4) | + (( ymm & 0xf00 ) >> 8)); + + desc[17] = 0x18; +} + +void qemu_edid_generate(uint8_t *edid, size_t size, + qemu_edid_info *info) +{ + uint32_t desc = 54; + uint8_t *xtra3 = NULL; + + /* =============== set defaults =============== */ + + if (!info->vendor || strlen(info->vendor) != 3) { + info->vendor = "EMU"; + } + 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; + } + + /* =============== header information =============== */ + + /* fixed */ + edid[0] = 0x00; + edid[1] = 0xff; + edid[2] = 0xff; + edid[3] = 0xff; + edid[4] = 0xff; + edid[5] = 0xff; + edid[6] = 0xff; + edid[7] = 0x00; + + /* manufacturer id, product code, serial number */ + uint16_t vendor_id = ((((info->vendor[0] - '@') & 0x1f) << 10) | + (((info->vendor[1] - '@') & 0x1f) << 5) | + (((info->vendor[2] - '@') & 0x1f) << 0)); + uint16_t model_nr = 0x1234; + uint32_t serial_nr = info->serial ? atoi(info->serial) : 0; + *(uint16_t*)(edid + 8) = cpu_to_be16(vendor_id); + *(uint16_t*)(edid + 10) = cpu_to_le16(model_nr); + *(uint32_t*)(edid + 12) = cpu_to_le32(serial_nr); + + /* manufacture week and year */ + edid[16] = 42; + edid[17] = 2014 - 1990; + + /* edid version */ + edid[18] = 1; + edid[19] = 4; + + + /* =============== basic display parameters =============== */ + + /* video input: digital, 8bpc, displayport */ + edid[20] = 0xa5; + + /* screen size: undefined */ + edid[21] = info->prefx * info->dpi / 2540; + edid[22] = info->prefy * info->dpi / 2540; + + /* display gamma: 1.0 */ + edid[23] = 0x00; + + /* supported features bitmap: preferred timing */ + edid[24] = 0x02; + + + /* =============== chromaticity coordinates =============== */ + + /* TODO (bytes 25 -> 34) */ + + + /* =============== established timing bitmap =============== */ + /* =============== standard timing information =============== */ + + /* both filled by edid_fill_modes() */ + + + /* =============== descriptor blocks =============== */ + + edid_desc_timing(edid + desc, info->prefx, info->prefy, info->dpi); + desc += 18; + + edid_desc_ranges(edid + desc); + desc += 18; + + if (info->name) { + edid_desc_text(edid + desc, 0xfc, info->name); + desc += 18; + } + + if (info->serial) { + edid_desc_text(edid + desc, 0xff, info->serial); + desc += 18; + } + + if (desc < 126) { + xtra3 = edid + desc; + edid_desc_xtra3_std(xtra3); + desc += 18; + } + + while (desc < 126) { + edid_desc_dummy(edid + desc); + desc += 18; + } + + /* =============== finish up =============== */ + + edid_fill_modes(edid, xtra3, info->maxx, info->maxy); + edid_checksum(edid); +} diff --git a/qemu-edid.c b/qemu-edid.c new file mode 100644 index 0000000000..a5a80df00e --- /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 \n" + "options:\n" + " -h print this text\n" + " -o set output file (stdout by default)\n" + " -v set monitor vendor (three letters)\n" + " -n set monitor name\n" + " -s set monitor serial\n" + " -d set display resolution\n" + " -x set preferred width\n" + " -y set preferred height\n" + " -X set maximum width\n" + " -Y set maximum height\n" + "\n"); +} + +int main(int argc, char *argv[]) +{ + FILE *outfile = NULL; + uint8_t blob[128]; + 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); +} diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs index a606fb7404..492404c09e 100644 --- a/hw/display/Makefile.objs +++ b/hw/display/Makefile.objs @@ -1,3 +1,5 @@ +common-obj-y += edid-generate.o + common-obj-$(CONFIG_FW_CFG_DMA) += ramfb.o common-obj-$(CONFIG_FW_CFG_DMA) += ramfb-standalone.o From patchwork Fri Sep 21 08:59:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10609385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79EBD15A6 for ; Fri, 21 Sep 2018 09:00:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AB672D890 for ; Fri, 21 Sep 2018 09:00:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F00F2D895; Fri, 21 Sep 2018 09:00:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 176B02D890 for ; Fri, 21 Sep 2018 09:00:51 +0000 (UTC) Received: from localhost ([::1]:54622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HIw-0002aw-2Y for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:00:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HHQ-0000ju-Sh for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3HHN-00077j-3j for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3HHM-00077O-TB for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 46F3E308402B for ; Fri, 21 Sep 2018 08:59:12 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7421F17DA3; Fri, 21 Sep 2018 08:59:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 330E699A1F; Fri, 21 Sep 2018 10:59:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 10:59:02 +0200 Message-Id: <20180921085905.3038-3-kraxel@redhat.com> In-Reply-To: <20180921085905.3038-1-kraxel@redhat.com> References: <20180921085905.3038-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 21 Sep 2018 08:59:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/5] display/edid: add qemu_edid_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Helper function to figure the size of a edid blob, by checking how many extensions are present. Both the base edid blob and the extensions are 128 bytes in size. Signed-off-by: Gerd Hoffmann --- include/hw/display/edid.h | 1 + hw/display/edid-generate.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/hw/display/edid.h b/include/hw/display/edid.h index 63b60015c3..96910ada0f 100644 --- a/include/hw/display/edid.h +++ b/include/hw/display/edid.h @@ -14,5 +14,6 @@ typedef struct qemu_edid_info { void qemu_edid_generate(uint8_t *edid, size_t size, qemu_edid_info *info); +size_t qemu_edid_size(uint8_t *edid); #endif /* EDID_H */ diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c index e439b1e893..42ec5df39c 100644 --- a/hw/display/edid-generate.c +++ b/hw/display/edid-generate.c @@ -332,3 +332,17 @@ void qemu_edid_generate(uint8_t *edid, size_t size, edid_fill_modes(edid, xtra3, info->maxx, info->maxy); edid_checksum(edid); } + +size_t qemu_edid_size(uint8_t *edid) +{ + uint32_t exts; + + if (edid[0] != 0x00 || + edid[1] != 0xff) { + /* doesn't look like a valid edid block */ + return 0; + } + + exts = edid[126]; + return 128 * (exts + 1); +} From patchwork Fri Sep 21 08:59:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10609391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39CD715A6 for ; Fri, 21 Sep 2018 09:03:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AC062DBD5 for ; Fri, 21 Sep 2018 09:03:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F1F82DBE4; Fri, 21 Sep 2018 09:03:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AEE172DBD5 for ; Fri, 21 Sep 2018 09:03:55 +0000 (UTC) Received: from localhost ([::1]:54640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HLv-0005it-1X for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:03:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HHQ-0000jw-Sc for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3HHN-00077k-3h for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3HHM-00077M-SJ for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D3D488319 for ; Fri, 21 Sep 2018 08:59:12 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78B7818341; Fri, 21 Sep 2018 08:59:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3D17A9B311; Fri, 21 Sep 2018 10:59:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 10:59:03 +0200 Message-Id: <20180921085905.3038-4-kraxel@redhat.com> In-Reply-To: <20180921085905.3038-1-kraxel@redhat.com> References: <20180921085905.3038-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 21 Sep 2018 08:59:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/5] display/edid: add region helper. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Create a io region for an EDID data block. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé --- include/hw/display/edid.h | 4 ++++ hw/display/edid-region.c | 33 +++++++++++++++++++++++++++++++++ hw/display/Makefile.objs | 1 + 3 files changed, 38 insertions(+) create mode 100644 hw/display/edid-region.c diff --git a/include/hw/display/edid.h b/include/hw/display/edid.h index 96910ada0f..b7fe56a958 100644 --- a/include/hw/display/edid.h +++ b/include/hw/display/edid.h @@ -1,6 +1,8 @@ #ifndef EDID_H #define EDID_H +#include "hw/hw.h" + typedef struct qemu_edid_info { const char *vendor; const char *name; @@ -15,5 +17,7 @@ typedef struct qemu_edid_info { void qemu_edid_generate(uint8_t *edid, size_t size, qemu_edid_info *info); size_t qemu_edid_size(uint8_t *edid); +void qemu_edid_region_io(MemoryRegion *region, Object *owner, + uint8_t *edid, size_t size); #endif /* EDID_H */ diff --git a/hw/display/edid-region.c b/hw/display/edid-region.c new file mode 100644 index 0000000000..9a15734d3a --- /dev/null +++ b/hw/display/edid-region.c @@ -0,0 +1,33 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "hw/display/edid.h" + +static uint64_t edid_region_read(void *ptr, hwaddr addr, unsigned size) +{ + uint8_t *edid = ptr; + + return edid[addr]; +} + +static void edid_region_write(void *ptr, hwaddr addr, + uint64_t val, unsigned size) +{ + /* read only */ +} + +static const MemoryRegionOps edid_region_ops = { + .read = edid_region_read, + .write = edid_region_write, + .valid.min_access_size = 1, + .valid.max_access_size = 4, + .impl.min_access_size = 1, + .impl.max_access_size = 1, + .endianness = DEVICE_LITTLE_ENDIAN, +}; + +void qemu_edid_region_io(MemoryRegion *region, Object *owner, + uint8_t *edid, size_t size) +{ + memory_region_init_io(region, owner, &edid_region_ops, + edid, "edid", size); +} diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs index 492404c09e..780a76b9f0 100644 --- a/hw/display/Makefile.objs +++ b/hw/display/Makefile.objs @@ -15,6 +15,7 @@ common-obj-$(CONFIG_XEN) += xenfb.o common-obj-$(CONFIG_VGA_PCI) += vga-pci.o common-obj-$(CONFIG_VGA_PCI) += bochs-display.o +common-obj-$(CONFIG_VGA_PCI) += edid-region.o common-obj-$(CONFIG_VGA_ISA) += vga-isa.o common-obj-$(CONFIG_VGA_ISA_MM) += vga-isa-mm.o common-obj-$(CONFIG_VMWARE_VGA) += vmware_vga.o From patchwork Fri Sep 21 08:59:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10609427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9F3415A6 for ; Fri, 21 Sep 2018 09:17:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBC1D2DA57 for ; Fri, 21 Sep 2018 09:17:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF8FF2DA88; Fri, 21 Sep 2018 09:17:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 703022DA57 for ; Fri, 21 Sep 2018 09:17:40 +0000 (UTC) Received: from localhost ([::1]:54724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HZD-0000CQ-PL for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:17:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HHQ-0000jx-Sc for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3HHM-000779-1h for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51454) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3HHL-00076c-SJ for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D7133C04F4CD for ; Fri, 21 Sep 2018 08:59:10 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 815487B012; Fri, 21 Sep 2018 08:59:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 44BEE9B312; Fri, 21 Sep 2018 10:59:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 10:59:04 +0200 Message-Id: <20180921085905.3038-5-kraxel@redhat.com> In-Reply-To: <20180921085905.3038-1-kraxel@redhat.com> References: <20180921085905.3038-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 21 Sep 2018 08:59:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/5] display/edid: add DEFINE_EDID_PROPERTIES X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a define for edid monitor properties. Signed-off-by: Gerd Hoffmann --- include/hw/display/edid.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/hw/display/edid.h b/include/hw/display/edid.h index b7fe56a958..bd51d26916 100644 --- a/include/hw/display/edid.h +++ b/include/hw/display/edid.h @@ -20,4 +20,8 @@ size_t qemu_edid_size(uint8_t *edid); void qemu_edid_region_io(MemoryRegion *region, Object *owner, uint8_t *edid, size_t size); +#define DEFINE_EDID_PROPERTIES(_state, _edid_info) \ + DEFINE_PROP_UINT32("xres", _state, _edid_info.prefx, 0), \ + DEFINE_PROP_UINT32("yres", _state, _edid_info.prefy, 0) + #endif /* EDID_H */ From patchwork Fri Sep 21 08:59:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10609433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5239D161F for ; Fri, 21 Sep 2018 09:21:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42EA52DB61 for ; Fri, 21 Sep 2018 09:21:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 371492DBE1; Fri, 21 Sep 2018 09:21:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 99CEB2DBD5 for ; Fri, 21 Sep 2018 09:21:10 +0000 (UTC) Received: from localhost ([::1]:54754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Hcb-0003jR-Q9 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:21:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HHV-0000sU-8R for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3HHU-0007If-6w for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42181) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3HHT-0007H1-Tq for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:20 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C6F3550D6 for ; Fri, 21 Sep 2018 08:59:19 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EE1D4122; Fri, 21 Sep 2018 08:59:11 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 502CF9B31F; Fri, 21 Sep 2018 10:59:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 10:59:05 +0200 Message-Id: <20180921085905.3038-6-kraxel@redhat.com> In-Reply-To: <20180921085905.3038-1-kraxel@redhat.com> References: <20180921085905.3038-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 21 Sep 2018 08:59:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 5/5] display/stdvga: add edid support. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds edid support to the qemu stdvga. It is turned off by default and can be enabled with the new edid property. The patch also adds xres and yres properties to specify the video mode you want the guest use. Works only with edid enabled and updated guest driver. The mmio bar of the stdvga has some unused address space at the start. It was reserved just in case it'll be needed for virtio, but it turned out to not be needed for that. So let's use that region to place the EDID data block there. Signed-off-by: Gerd Hoffmann --- docs/specs/standard-vga.txt | 2 +- hw/display/vga_int.h | 2 +- hw/display/vga-pci.c | 35 +++++++++++++++++++++++++++++++---- hw/display/virtio-vga.c | 2 +- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/docs/specs/standard-vga.txt b/docs/specs/standard-vga.txt index 19d2a74509..18f75f1b30 100644 --- a/docs/specs/standard-vga.txt +++ b/docs/specs/standard-vga.txt @@ -61,7 +61,7 @@ MMIO area spec Likewise applies to the pci variant only for obvious reasons. -0000 - 03ff : reserved, for possible virtio extension. +0000 - 03ff : edid data blob. 0400 - 041f : vga ioports (0x3c0 -> 0x3df), remapped 1:1. word access is supported, bytes are written in little endia order (aka index port first), diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h index 339661bc01..6e4fa48a79 100644 --- a/hw/display/vga_int.h +++ b/hw/display/vga_int.h @@ -197,6 +197,6 @@ void pci_std_vga_mmio_region_init(VGACommonState *s, Object *owner, MemoryRegion *parent, MemoryRegion *subs, - bool qext); + bool qext, bool edid); #endif diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c index e9e62eac70..d3195f9dda 100644 --- a/hw/display/vga-pci.c +++ b/hw/display/vga-pci.c @@ -30,18 +30,22 @@ #include "ui/pixel_ops.h" #include "qemu/timer.h" #include "hw/loader.h" +#include "hw/display/edid.h" enum vga_pci_flags { PCI_VGA_FLAG_ENABLE_MMIO = 1, PCI_VGA_FLAG_ENABLE_QEXT = 2, + PCI_VGA_FLAG_ENABLE_EDID = 3, }; typedef struct PCIVGAState { PCIDevice dev; VGACommonState vga; uint32_t flags; + qemu_edid_info edid_info; MemoryRegion mmio; - MemoryRegion mrs[3]; + MemoryRegion mrs[4]; + uint8_t edid[128]; } PCIVGAState; #define TYPE_PCI_VGA "pci-vga" @@ -195,8 +199,10 @@ void pci_std_vga_mmio_region_init(VGACommonState *s, Object *owner, MemoryRegion *parent, MemoryRegion *subs, - bool qext) + bool qext, bool edid) { + PCIVGAState *d = container_of(s, PCIVGAState, vga); + memory_region_init_io(&subs[0], owner, &pci_vga_ioport_ops, s, "vga ioports remapped", PCI_VGA_IOPORT_SIZE); memory_region_add_subregion(parent, PCI_VGA_IOPORT_OFFSET, @@ -213,6 +219,12 @@ void pci_std_vga_mmio_region_init(VGACommonState *s, memory_region_add_subregion(parent, PCI_VGA_QEXT_OFFSET, &subs[2]); } + + if (edid) { + qemu_edid_generate(d->edid, sizeof(d->edid), &d->edid_info); + qemu_edid_region_io(&subs[3], owner, d->edid, sizeof(d->edid)); + memory_region_add_subregion(parent, 0, &subs[3]); + } } static void pci_std_vga_realize(PCIDevice *dev, Error **errp) @@ -220,6 +232,7 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp) PCIVGAState *d = PCI_VGA(dev); VGACommonState *s = &d->vga; bool qext = false; + bool edid = false; /* vga + console init */ vga_common_init(s, OBJECT(dev)); @@ -240,7 +253,11 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp) qext = true; pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2); } - pci_std_vga_mmio_region_init(s, OBJECT(dev), &d->mmio, d->mrs, qext); + if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_EDID)) { + edid = true; + } + pci_std_vga_mmio_region_init(s, OBJECT(dev), &d->mmio, d->mrs, + qext, edid); pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio); } @@ -263,6 +280,7 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp) PCIVGAState *d = PCI_VGA(dev); VGACommonState *s = &d->vga; bool qext = false; + bool edid = false; /* vga + console init */ vga_common_init(s, OBJECT(dev)); @@ -276,7 +294,10 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp) qext = true; pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2); } - pci_std_vga_mmio_region_init(s, OBJECT(dev), &d->mmio, d->mrs, qext); + if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_EDID)) { + edid = true; + } + pci_std_vga_mmio_region_init(s, OBJECT(dev), &d->mmio, d->mrs, qext, edid); pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram); pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio); @@ -308,6 +329,9 @@ static Property vga_pci_properties[] = { DEFINE_PROP_BIT("mmio", PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_MMIO, true), DEFINE_PROP_BIT("qemu-extended-regs", PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT, true), + DEFINE_PROP_BIT("edid", + PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_EDID, false), + DEFINE_EDID_PROPERTIES(PCIVGAState, edid_info), DEFINE_PROP_BOOL("global-vmstate", PCIVGAState, vga.global_vmstate, false), DEFINE_PROP_END_OF_LIST(), }; @@ -316,6 +340,9 @@ static Property secondary_pci_properties[] = { DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16), DEFINE_PROP_BIT("qemu-extended-regs", PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT, true), + DEFINE_PROP_BIT("edid", + PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_EDID, false), + DEFINE_EDID_PROPERTIES(PCIVGAState, edid_info), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index 701d980872..3bea0693f6 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -163,7 +163,7 @@ static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp) /* add stdvga mmio regions */ pci_std_vga_mmio_region_init(vga, OBJECT(vvga), &vpci_dev->modern_bar, - vvga->vga_mrs, true); + vvga->vga_mrs, true, false); vga->con = g->scanout[0].con; g->disable_scanout = virtio_vga_disable_scanout;