Skip to content

Commit

Permalink
display/edid: add region helper.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kraxel committed Sep 27, 2018
1 parent e7992fc commit 97917e9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions hw/display/Makefile.objs
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions 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);
}
4 changes: 4 additions & 0 deletions 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;
Expand All @@ -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 */

0 comments on commit 97917e9

Please sign in to comment.