static void handle_mmio_read(struct mdev_state *mdev_state, u16 offset,
			     char *buf, u32 count)
{
	struct device *dev = mdev_dev(mdev_state->mdev);
	struct vfio_region_gfx_edid *edid;
	u16 reg16 = 0;
	int index;

	switch (offset) {
	case 0x000 ... 0x3ff: /* edid block */
		edid = &mdev_state->edid_regs;
		if (edid->link_state != VFIO_DEVICE_GFX_LINK_STATE_UP ||
		    offset >= edid->edid_size) {
			memset(buf, 0, count);
			break;
		}
		memcpy(buf, mdev_state->edid_blob + offset, count);
		break;
	case 0x500 ... 0x515: /* bochs dispi interface */
		if (count != 2)
			goto unhandled;
		index = (offset - 0x500) / 2;
		if (index < ARRAY_SIZE(mdev_state->vbe))
			reg16 = mdev_state->vbe[index];
		dev_dbg(dev, "%s: vbe read %d = %d (%s)\n",
			__func__, index, reg16, vbe_name(index));
		*(u16 *)buf = reg16;
		break;
	default:
unhandled:
		dev_dbg(dev, "%s: @0x%03x, count %d (unhandled)\n",
			__func__, offset, count);
		memset(buf, 0, count);
		break;
	}
}
static void handle_mmio_read(struct mdev_state *mdev_state, u16 offset,
			     char *buf, u32 count)
{
	struct device *dev = mdev_dev(mdev_state->mdev);
	struct vfio_region_gfx_edid *edid;
	u16 reg16 = 0;
	int index;

	switch (offset) {
	case 0x000 ... 0x3ff:  
		edid = &mdev_state->edid_regs;
		if (edid->link_state != VFIO_DEVICE_GFX_LINK_STATE_UP ||
		    offset >= edid->edid_size) {
			memset(buf, 0, count);
			break;
		}
		memcpy(buf, mdev_state->edid_blob + offset, count);
		break;
	case 0x500 ... 0x515:  
		if (count != 2)
			goto unhandled;
		index = (offset - 0x500) / 2;
		if (index < ARRAY_SIZE(mdev_state->vbe))
			reg16 = mdev_state->vbe[index];
		dev_dbg(dev, "%s: vbe read %d = %d (%s)\n",
			__func__, index, reg16, vbe_name(index));
		*(u16 *)buf = reg16;
		break;
	default:
unhandled:
		dev_dbg(dev, "%s: @0x%03x, count %d (unhandled)\n",
			__func__, offset, count);
		memset(buf, 0, count);
		break;
	}
}