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