vga: add ramfb, print virglrenderer version

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJbJ4ISAAoJEEy22O7T6HE4vJsP/11VphYRW9cd7E0+wuH4zqb/
 r0x540BQ+TH8+xVaZDMJgQuwLUFnq/3dWO4ImOSblZs+MD/ojk0XNw8tWLxqAVjk
 CrSA0aZj4tT+Dwpx6ylC+ta6klDr8Y75dK2Zo9ZJrDy3aniqTQNk7QyLuFcrlfPk
 QBJm3J/lrbwTwtFEG9lXe5jZud5eR2rZsPXljuCPAAiIy3WdOMA57OZwND+zngW8
 QCYJH+2K41BXta9o5jKmhDNFc24nnYFtoo9xpZp0S0mP5TKzMP6zmI/JtP270FhC
 KvX4SFgqs2zuQkgbG4MouoXqKAiY8lgarEdiWggAjacTBEkEZ/nBmVLuN7S5nIoA
 M70b+eriybIVVX7fCe0CykcqxXGnuEEPtLGlZ5vk/rCaZiKGmsFaYYF+xcfswMtz
 gVkgZMSgIoJ0pxc4qKOTxy2J6ZxOc+Dz0NEMSSzv8Y4AwYn5d9b+ri8Zc8jnYzLZ
 EHPv+1zXHwXBmwmKcgysW58b4Z5DGyNShpFTPh74Nep72P68Uf4lQOf+gYyjtIIE
 VJ5sdd0kK5cfQHwKaBHgefnyNSPy6WCu4ogEKs3WQKmNVNFS8Zsl4c5kJhgP5pZz
 IEUGyFDV1+yl3ZUilnj/a02IWNOmkHNXdgSUeveqhiaTzl7DMr8oj3byizVnJ/3J
 T6U1DNus9BS7W+UnH+Fw
 =x6JE
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/vga-20180618-pull-request' into staging

vga: add ramfb, print virglrenderer version

# gpg: Signature made Mon 18 Jun 2018 10:57:38 BST
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/vga-20180618-pull-request:
  Add ramfb MAINTAINERS entry
  hw/display: add standalone ramfb device
  hw/display: add ramfb, a simple boot framebuffer living in guest ram
  configure: print virglrenderer version

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-06-19 13:43:35 +01:00
commit 59926de998
10 changed files with 193 additions and 1 deletions

View File

@ -1331,6 +1331,12 @@ F: hw/display/bochs-display.c
F: include/hw/display/vga.h
F: include/hw/display/bochs-vbe.h
ramfb
M: Gerd Hoffmann <kraxel@redhat.com>
S: Maintained
F: hw/display/ramfb*.c
F: include/hw/display/ramfb.h
virtio-gpu
M: Gerd Hoffmann <kraxel@redhat.com>
S: Maintained

3
configure vendored
View File

@ -4599,6 +4599,7 @@ int main(void) { virgl_renderer_poll(); return 0; }
EOF
virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
if $pkg_config virglrenderer >/dev/null 2>&1 && \
compile_prog "$virgl_cflags" "$virgl_libs" ; then
virglrenderer="yes"
@ -5827,7 +5828,7 @@ echo "nettle $nettle $(echo_version $nettle $nettle_version)"
echo "nettle kdf $nettle_kdf"
echo "libtasn1 $tasn1"
echo "curses support $curses"
echo "virgl support $virglrenderer"
echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
echo "curl support $curl"
echo "mingw32 support $mingw32"
echo "Audio drivers $audio_drv_list"

View File

@ -36,6 +36,7 @@
#include "hw/vfio/vfio-platform.h"
#include "hw/vfio/vfio-calxeda-xgmac.h"
#include "hw/vfio/vfio-amd-xgbe.h"
#include "hw/display/ramfb.h"
#include "hw/arm/fdt.h"
/*
@ -406,12 +407,18 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev, void *opaque)
#endif /* CONFIG_LINUX */
static int no_fdt_node(SysBusDevice *sbdev, void *opaque)
{
return 0;
}
/* list of supported dynamic sysbus devices */
static const NodeCreationPair add_fdt_node_functions[] = {
#ifdef CONFIG_LINUX
{TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node},
{TYPE_VFIO_AMD_XGBE, add_amd_xgbe_fdt_node},
#endif
{TYPE_RAMFB_DEVICE, no_fdt_node},
{"", NULL}, /* last element */
};

View File

@ -36,6 +36,7 @@
#include "hw/arm/virt.h"
#include "hw/vfio/vfio-calxeda-xgmac.h"
#include "hw/vfio/vfio-amd-xgbe.h"
#include "hw/display/ramfb.h"
#include "hw/devices.h"
#include "net/net.h"
#include "sysemu/device_tree.h"
@ -1659,6 +1660,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
mc->max_cpus = 255;
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_CALXEDA_XGMAC);
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_AMD_XGBE);
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE);
mc->block_default_type = IF_VIRTIO;
mc->no_cdrom = 1;
mc->pci_allow_0_address = true;

View File

@ -1,3 +1,6 @@
common-obj-y += ramfb.o
common-obj-y += ramfb-standalone.o
common-obj-$(CONFIG_ADS7846) += ads7846.o
common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
common-obj-$(CONFIG_G364FB) += g364fb.o

View File

@ -0,0 +1,62 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "hw/loader.h"
#include "hw/isa/isa.h"
#include "hw/display/ramfb.h"
#include "ui/console.h"
#include "sysemu/sysemu.h"
#define RAMFB(obj) OBJECT_CHECK(RAMFBStandaloneState, (obj), TYPE_RAMFB_DEVICE)
typedef struct RAMFBStandaloneState {
SysBusDevice parent_obj;
QemuConsole *con;
RAMFBState *state;
} RAMFBStandaloneState;
static void display_update_wrapper(void *dev)
{
RAMFBStandaloneState *ramfb = RAMFB(dev);
if (0 /* native driver active */) {
/* non-standalone device would run native display update here */;
} else {
ramfb_display_update(ramfb->con, ramfb->state);
}
}
static const GraphicHwOps wrapper_ops = {
.gfx_update = display_update_wrapper,
};
static void ramfb_realizefn(DeviceState *dev, Error **errp)
{
RAMFBStandaloneState *ramfb = RAMFB(dev);
ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
ramfb->state = ramfb_setup(errp);
}
static void ramfb_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->realize = ramfb_realizefn;
dc->desc = "ram framebuffer standalone device";
dc->user_creatable = true;
}
static const TypeInfo ramfb_info = {
.name = TYPE_RAMFB_DEVICE,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(RAMFBStandaloneState),
.class_init = ramfb_class_initfn,
};
static void ramfb_register_types(void)
{
type_register_static(&ramfb_info);
}
type_init(ramfb_register_types)

95
hw/display/ramfb.c Normal file
View File

@ -0,0 +1,95 @@
/*
* early boot framebuffer in guest ram
* configured using fw_cfg
*
* Copyright Red Hat, Inc. 2017
*
* Author:
* Gerd Hoffmann <kraxel@redhat.com>
*
* 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 "qapi/error.h"
#include "hw/loader.h"
#include "hw/display/ramfb.h"
#include "ui/console.h"
#include "sysemu/sysemu.h"
struct QEMU_PACKED RAMFBCfg {
uint64_t addr;
uint32_t fourcc;
uint32_t flags;
uint32_t width;
uint32_t height;
uint32_t stride;
};
struct RAMFBState {
DisplaySurface *ds;
uint32_t width, height;
struct RAMFBCfg cfg;
};
static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len)
{
RAMFBState *s = dev;
void *framebuffer;
uint32_t stride, fourcc, format;
hwaddr addr, length;
s->width = be32_to_cpu(s->cfg.width);
s->height = be32_to_cpu(s->cfg.height);
stride = be32_to_cpu(s->cfg.stride);
fourcc = be32_to_cpu(s->cfg.fourcc);
addr = be64_to_cpu(s->cfg.addr);
length = stride * s->height;
format = qemu_drm_format_to_pixman(fourcc);
fprintf(stderr, "%s: %dx%d @ 0x%" PRIx64 "\n", __func__,
s->width, s->height, addr);
framebuffer = address_space_map(&address_space_memory,
addr, &length, false,
MEMTXATTRS_UNSPECIFIED);
if (!framebuffer || length < stride * s->height) {
s->width = 0;
s->height = 0;
return;
}
s->ds = qemu_create_displaysurface_from(s->width, s->height,
format, stride, framebuffer);
}
void ramfb_display_update(QemuConsole *con, RAMFBState *s)
{
if (!s->width || !s->height) {
return;
}
if (s->ds) {
dpy_gfx_replace_surface(con, s->ds);
s->ds = NULL;
}
/* simple full screen update */
dpy_gfx_update_full(con);
}
RAMFBState *ramfb_setup(Error **errp)
{
FWCfgState *fw_cfg = fw_cfg_find();
RAMFBState *s;
if (!fw_cfg || !fw_cfg->dma_enabled) {
error_setg(errp, "ramfb device requires fw_cfg with DMA");
return NULL;
}
s = g_new0(RAMFBState, 1);
fw_cfg_add_file_callback(fw_cfg, "etc/ramfb",
NULL, ramfb_fw_cfg_write, s,
&s->cfg, sizeof(s->cfg), false);
return s;
}

View File

@ -28,6 +28,7 @@
#include "hw/loader.h"
#include "hw/i386/pc.h"
#include "hw/i386/apic.h"
#include "hw/display/ramfb.h"
#include "hw/smbios/smbios.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_ids.h"
@ -423,6 +424,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
m->desc = "Standard PC (i440FX + PIIX, 1996)";
m->default_machine_opts = "firmware=bios-256k.bin";
m->default_display = "std";
machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
}
static void pc_i440fx_3_0_machine_options(MachineClass *m)

View File

@ -45,6 +45,7 @@
#include "hw/i386/ich9.h"
#include "hw/i386/amd_iommu.h"
#include "hw/i386/intel_iommu.h"
#include "hw/display/ramfb.h"
#include "hw/smbios/smbios.h"
#include "hw/ide/pci.h"
#include "hw/ide/ahci.h"
@ -305,6 +306,7 @@ static void pc_q35_machine_options(MachineClass *m)
m->no_floppy = 1;
machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE);
machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE);
machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
m->max_cpus = 288;
}

View File

@ -0,0 +1,12 @@
#ifndef RAMFB_H
#define RAMFB_H
/* ramfb.c */
typedef struct RAMFBState RAMFBState;
void ramfb_display_update(QemuConsole *con, RAMFBState *s);
RAMFBState *ramfb_setup(Error **errp);
/* ramfb-standalone.c */
#define TYPE_RAMFB_DEVICE "ramfb"
#endif /* RAMFB_H */