hw/display: qomify vga cards

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJVWw8NAAoJEEy22O7T6HE4A74P/ihkDQXyBiFySkde0gLLOQZ0
 SSRmoO6HN4aNsCssliJSidYxp2AjWYCZJfG0Cc7ExwOcKqZ5u5N8ysOK20DjOuXd
 CjQMtUe7V0zHivJlhUeNHusuKx3+5Bvi+b/Az1fYXaN5UPD8VKKt7FWvRx6P44SE
 kQyP01HhQCvPL29GeJnx5PFaOeB+xMkIzYaywK0ZBzBrFKGpect2kQsEsRcCujil
 nnBn4XgMh7XZ3yPHfPtYaOj2kB5CCStKEfkXkZ58O0KsZGJXsuf+LVGtMuErpOtF
 HHnIUEysaFx5WcWkdgF35e2fRsPgmVUWykVsxQSa/1Gwpbgrxj98jr56pvNqUQ3P
 RebphUCOpB+xzHv1cJeBG5KApxfAKWuBLNqYICMiZgYYZV1kVl61ncLgxrXCBMQJ
 w8BVG9/N0T0MYT/2ITrXfmr6fWS0DhC6o4KSTPvraJ/BId6eCg757eNzI++bp5z3
 Fa8AKLz2aWFQAjO5dKQ5Qx8zMCQcvHu8LxDTv+VpliLl9hn+PUlAjovaLsiNHQtB
 Ij2UOK/ZF3Q9keHAcqYUZK8CmgTl5BzTPAisE/ARdSdnWhPBRxH0+x7Hs8CqXVAy
 M8Sajp4dJNRyn+PSN8Dro54nJnw0GCGrmrsDULldweVFAsC2eZ34gYB06M1F8exP
 SWSl2DPYc6csTKaQZTR1
 =bq6x
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20150519-1' into staging

hw/display: qomify vga cards

# gpg: Signature made Tue May 19 11:23:09 2015 BST using RSA key ID D3E87138
# 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>"

* remotes/kraxel/tags/pull-vga-20150519-1:
  vga-pci: QOMify
  qxl: QOMify
  cirrus_vga: QOMify

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2015-05-19 11:47:03 +01:00
commit fdbe454a24
4 changed files with 66 additions and 39 deletions

View File

@ -235,6 +235,10 @@ typedef struct PCICirrusVGAState {
CirrusVGAState cirrus_vga;
} PCICirrusVGAState;
#define TYPE_PCI_CIRRUS_VGA "cirrus-vga"
#define PCI_CIRRUS_VGA(obj) \
OBJECT_CHECK(PCICirrusVGAState, (obj), TYPE_PCI_CIRRUS_VGA)
#define TYPE_ISA_CIRRUS_VGA "isa-cirrus-vga"
#define ISA_CIRRUS_VGA(obj) \
OBJECT_CHECK(ISACirrusVGAState, (obj), TYPE_ISA_CIRRUS_VGA)
@ -3008,7 +3012,7 @@ static const TypeInfo isa_cirrus_vga_info = {
static void pci_cirrus_vga_realize(PCIDevice *dev, Error **errp)
{
PCICirrusVGAState *d = DO_UPCAST(PCICirrusVGAState, dev, dev);
PCICirrusVGAState *d = PCI_CIRRUS_VGA(dev);
CirrusVGAState *s = &d->cirrus_vga;
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
int16_t device_id = pc->device_id;
@ -3070,7 +3074,7 @@ static void cirrus_vga_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo cirrus_vga_info = {
.name = "cirrus-vga",
.name = TYPE_PCI_CIRRUS_VGA,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PCICirrusVGAState),
.class_init = cirrus_vga_class_init,

View File

@ -1181,7 +1181,7 @@ static void qxl_hard_reset(PCIQXLDevice *d, int loadvm)
static void qxl_reset_handler(DeviceState *dev)
{
PCIQXLDevice *d = DO_UPCAST(PCIQXLDevice, pci.qdev, dev);
PCIQXLDevice *d = PCI_QXL(PCI_DEVICE(dev));
qxl_hard_reset(d, 0);
}
@ -2026,7 +2026,7 @@ static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
static void qxl_realize_primary(PCIDevice *dev, Error **errp)
{
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
PCIQXLDevice *qxl = PCI_QXL(dev);
VGACommonState *vga = &qxl->vga;
Error *local_err = NULL;
@ -2059,7 +2059,7 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp)
static void qxl_realize_secondary(PCIDevice *dev, Error **errp)
{
static int device_id = 1;
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
PCIQXLDevice *qxl = PCI_QXL(dev);
qxl->id = device_id++;
qxl_init_ramsize(qxl);
@ -2277,6 +2277,27 @@ static Property qxl_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
static void qxl_pci_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->vendor_id = REDHAT_PCI_VENDOR_ID;
k->device_id = QXL_DEVICE_ID_STABLE;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->reset = qxl_reset_handler;
dc->vmsd = &qxl_vmstate;
dc->props = qxl_properties;
}
static const TypeInfo qxl_pci_type_info = {
.name = TYPE_PCI_QXL,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PCIQXLDevice),
.abstract = true,
.class_init = qxl_pci_class_init,
};
static void qxl_primary_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@ -2284,21 +2305,14 @@ static void qxl_primary_class_init(ObjectClass *klass, void *data)
k->realize = qxl_realize_primary;
k->romfile = "vgabios-qxl.bin";
k->vendor_id = REDHAT_PCI_VENDOR_ID;
k->device_id = QXL_DEVICE_ID_STABLE;
k->class_id = PCI_CLASS_DISPLAY_VGA;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->desc = "Spice QXL GPU (primary, vga compatible)";
dc->reset = qxl_reset_handler;
dc->vmsd = &qxl_vmstate;
dc->props = qxl_properties;
dc->hotpluggable = false;
}
static const TypeInfo qxl_primary_info = {
.name = "qxl-vga",
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PCIQXLDevice),
.parent = TYPE_PCI_QXL,
.class_init = qxl_primary_class_init,
};
@ -2308,25 +2322,19 @@ static void qxl_secondary_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->realize = qxl_realize_secondary;
k->vendor_id = REDHAT_PCI_VENDOR_ID;
k->device_id = QXL_DEVICE_ID_STABLE;
k->class_id = PCI_CLASS_DISPLAY_OTHER;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->desc = "Spice QXL GPU (secondary)";
dc->reset = qxl_reset_handler;
dc->vmsd = &qxl_vmstate;
dc->props = qxl_properties;
}
static const TypeInfo qxl_secondary_info = {
.name = "qxl",
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PCIQXLDevice),
.parent = TYPE_PCI_QXL,
.class_init = qxl_secondary_class_init,
};
static void qxl_register_types(void)
{
type_register_static(&qxl_pci_type_info);
type_register_static(&qxl_primary_info);
type_register_static(&qxl_secondary_info);
}

View File

@ -122,6 +122,9 @@ typedef struct PCIQXLDevice {
QEMUBH *update_area_bh;
} PCIQXLDevice;
#define TYPE_PCI_QXL "pci-qxl"
#define PCI_QXL(obj) OBJECT_CHECK(PCIQXLDevice, (obj), TYPE_PCI_QXL)
#define PANIC_ON(x) if ((x)) { \
printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \
abort(); \

View File

@ -59,6 +59,9 @@ typedef struct PCIVGAState {
MemoryRegion qext;
} PCIVGAState;
#define TYPE_PCI_VGA "pci-vga"
#define PCI_VGA(obj) OBJECT_CHECK(PCIVGAState, (obj), TYPE_PCI_VGA)
static const VMStateDescription vmstate_vga_pci = {
.name = "vga",
.version_id = 2,
@ -183,14 +186,14 @@ static void pci_vga_qext_write(void *ptr, hwaddr addr,
static bool vga_get_big_endian_fb(Object *obj, Error **errp)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, PCI_DEVICE(obj));
PCIVGAState *d = PCI_VGA(PCI_DEVICE(obj));
return d->vga.big_endian_fb;
}
static void vga_set_big_endian_fb(Object *obj, bool value, Error **errp)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, PCI_DEVICE(obj));
PCIVGAState *d = PCI_VGA(PCI_DEVICE(obj));
d->vga.big_endian_fb = value;
}
@ -205,7 +208,7 @@ static const MemoryRegionOps pci_vga_qext_ops = {
static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
PCIVGAState *d = PCI_VGA(dev);
VGACommonState *s = &d->vga;
/* vga + console init */
@ -257,7 +260,7 @@ static void pci_std_vga_init(Object *obj)
static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
PCIVGAState *d = PCI_VGA(dev);
VGACommonState *s = &d->vga;
/* vga + console init */
@ -297,8 +300,7 @@ static void pci_secondary_vga_init(Object *obj)
static void pci_secondary_vga_reset(DeviceState *dev)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev.qdev, dev);
PCIVGAState *d = PCI_VGA(PCI_DEVICE(dev));
vga_common_reset(&d->vga);
}
@ -317,6 +319,25 @@ static Property secondary_pci_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
static void vga_pci_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->vendor_id = PCI_VENDOR_ID_QEMU;
k->device_id = PCI_DEVICE_ID_QEMU_VGA;
dc->vmsd = &vmstate_vga_pci;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
}
static const TypeInfo vga_pci_type_info = {
.name = TYPE_PCI_VGA,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PCIVGAState),
.abstract = true,
.class_init = vga_pci_class_init,
};
static void vga_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@ -324,13 +345,9 @@ static void vga_class_init(ObjectClass *klass, void *data)
k->realize = pci_std_vga_realize;
k->romfile = "vgabios-stdvga.bin";
k->vendor_id = PCI_VENDOR_ID_QEMU;
k->device_id = PCI_DEVICE_ID_QEMU_VGA;
k->class_id = PCI_CLASS_DISPLAY_VGA;
dc->vmsd = &vmstate_vga_pci;
dc->props = vga_pci_properties;
dc->hotpluggable = false;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
}
static void secondary_class_init(ObjectClass *klass, void *data)
@ -339,33 +356,28 @@ static void secondary_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->realize = pci_secondary_vga_realize;
k->vendor_id = PCI_VENDOR_ID_QEMU;
k->device_id = PCI_DEVICE_ID_QEMU_VGA;
k->class_id = PCI_CLASS_DISPLAY_OTHER;
dc->vmsd = &vmstate_vga_pci;
dc->props = secondary_pci_properties;
dc->reset = pci_secondary_vga_reset;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
}
static const TypeInfo vga_info = {
.name = "VGA",
.parent = TYPE_PCI_DEVICE,
.parent = TYPE_PCI_VGA,
.instance_init = pci_std_vga_init,
.instance_size = sizeof(PCIVGAState),
.class_init = vga_class_init,
};
static const TypeInfo secondary_info = {
.name = "secondary-vga",
.parent = TYPE_PCI_DEVICE,
.parent = TYPE_PCI_VGA,
.instance_init = pci_secondary_vga_init,
.instance_size = sizeof(PCIVGAState),
.class_init = secondary_class_init,
};
static void vga_register_types(void)
{
type_register_static(&vga_pci_type_info);
type_register_static(&vga_info);
type_register_static(&secondary_info);
}