OSDN Git Service

display/edid: add region helper.
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 25 Sep 2018 07:56:44 +0000 (09:56 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 27 Sep 2018 06:07:51 +0000 (08:07 +0200)
Create a io region for an EDID data block.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20180925075646.25114-4-kraxel@redhat.com

hw/display/Makefile.objs
hw/display/edid-region.c [new file with mode: 0644]
include/hw/display/edid.h

index 492404c..780a76b 100644 (file)
@@ -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
diff --git a/hw/display/edid-region.c b/hw/display/edid-region.c
new file mode 100644 (file)
index 0000000..9a15734
--- /dev/null
@@ -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);
+}
index 96910ad..b7fe56a 100644 (file)
@@ -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 */