[Spice-devel] [RFCv2 09/21] xspice: stop using pci and vga
Alon Levy
alevy at redhat.com
Fri Apr 29 02:49:47 PDT 2011
This ifdefs out all the parts in qxl_driver.c that are pci device specific
and are not required by xspice. No functional change. The resulting spiceqxl_drv.so
doesn't run.
---
src/qxl.h | 9 ++++-
src/qxl_driver.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 88 insertions(+), 10 deletions(-)
diff --git a/src/qxl.h b/src/qxl.h
index 6a5c63e..443871b 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -40,12 +40,15 @@
#include "xf86xv.h"
#include "shadow.h"
#include "micmap.h"
+#include "uxa/uxa.h"
+
+#ifndef XSPICE
#ifdef XSERVER_PCIACCESS
#include "pciaccess.h"
#endif
#include "fb.h"
-#include "uxa/uxa.h"
#include "vgaHW.h"
+#endif /* XSPICE */
#define hidden _X_HIDDEN
@@ -133,9 +136,10 @@ struct _qxl_screen_t
EntityInfoPtr entity;
+#ifndef XSPICE
void * io_pages;
void * io_pages_physical;
-
+
#ifdef XSERVER_LIBPCIACCESS
struct pci_device * pci;
#else
@@ -143,6 +147,7 @@ struct _qxl_screen_t
PCITAG pci_tag;
#endif
vgaRegRec vgaRegs;
+#endif /* XSPICE */
uxa_driver_t * uxa;
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index b3e2094..198af00 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -204,6 +204,17 @@ qxl_blank_screen(ScreenPtr pScreen, int mode)
return TRUE;
}
+#ifdef XSPICE
+static void
+unmap_memory_helper(qxl_screen_t *qxl, int scrnIndex)
+{
+}
+
+static void
+map_memory_helper(qxl_screen_t *qxl, int scrnIndex)
+{
+}
+#else /* Default */
static void
unmap_memory_helper(qxl_screen_t *qxl, int scrnIndex)
{
@@ -265,6 +276,7 @@ map_memory_helper(qxl_screen_t *qxl, int scrnIndex)
qxl->io_base = qxl->pci->ioBase[3];
#endif
}
+#endif /* XSPICE */
static void
qxl_unmap_memory(qxl_screen_t *qxl, int scrnIndex)
@@ -308,6 +320,17 @@ qxl_map_memory(qxl_screen_t *qxl, int scrnIndex)
return TRUE;
}
+#ifdef XSPICE
+static void
+qxl_save_state(ScrnInfoPtr pScrn)
+{
+}
+
+static void
+qxl_restore_state(ScrnInfoPtr pScrn)
+{
+}
+#else /* QXL */
static void
qxl_save_state(ScrnInfoPtr pScrn)
{
@@ -323,6 +346,7 @@ qxl_restore_state(ScrnInfoPtr pScrn)
vgaHWRestoreFonts(pScrn, &qxl->vgaRegs);
}
+#endif /* XSPICE */
static Bool
qxl_close_screen(int scrnIndex, ScreenPtr pScreen)
@@ -916,8 +940,10 @@ qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
qxl_reset (qxl);
ErrorF ("done reset\n");
+#ifndef XSPICE
qxl->io_pages = (void *)((unsigned long)qxl->ram);
qxl->io_pages_physical = (void *)((unsigned long)qxl->ram_physical);
+#endif
qxl->command_ring = qxl_ring_create ((struct qxl_ring_header *)&(ram_header->cmd_ring),
sizeof (struct QXLCommand),
@@ -1055,6 +1081,7 @@ print_modes (qxl_screen_t *qxl, int scrnIndex)
}
}
+#ifndef XSPICE
static Bool
qxl_check_device(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
{
@@ -1090,15 +1117,9 @@ qxl_check_device(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
xf86DrvMsg(scrnIndex, X_INFO, "Correct RAM signature %x\n",
ram_header->magic);
-
- pScrn->videoRam = (rom->num_pages * 4096) / 1024;
-
- xf86DrvMsg(scrnIndex, X_INFO, "%d KB of video RAM\n", pScrn->videoRam);
-
- xf86DrvMsg(scrnIndex, X_INFO, "%d surfaces\n", rom->n_surfaces);
-
return TRUE;
}
+#endif /* !XSPICE */
static int
qxl_find_native_mode(ScrnInfoPtr pScrn, DisplayModePtr p)
@@ -1215,11 +1236,14 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
pScrn->driverPrivate = xnfcalloc(sizeof(qxl_screen_t), 1);
qxl = pScrn->driverPrivate;
- qxl->entity = xf86GetEntityInfo(pScrn->entityList[0]);
+#ifndef XSPICE
qxl->pci = xf86GetPciInfoForEntity(qxl->entity->index);
#ifndef XSERVER_LIBPCIACCESS
qxl->pci_tag = pciTag(qxl->pci->bus, qxl->pci->device, qxl->pci->func);
#endif
+#endif /* XSPICE */
+
+ qxl->entity = xf86GetEntityInfo(pScrn->entityList[0]);
pScrn->monitor = pScrn->confScreen->monitor;
@@ -1234,8 +1258,13 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
if (!qxl_map_memory(qxl, scrnIndex))
goto out;
+#ifndef XSPICE
if (!qxl_check_device(pScrn, qxl))
goto out;
+#endif
+ pScrn->videoRam = (qxl->rom->num_pages * 4096) / 1024;
+ xf86DrvMsg(scrnIndex, X_INFO, "%d KB of video RAM\n", pScrn->videoRam);
+ xf86DrvMsg(scrnIndex, X_INFO, "%d surfaces\n", qxl->rom->n_surfaces);
/* ddc stuff here */
@@ -1317,9 +1346,11 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
print_modes (qxl, scrnIndex);
+#ifndef XSPICE
/* VGA hardware initialisation */
if (!vgaHWGetHWRec(pScrn))
return FALSE;
+#endif
/* hate */
qxl_unmap_memory(qxl, scrnIndex);
@@ -1338,6 +1369,7 @@ out:
return FALSE;
}
+#ifndef XSPICE
#ifdef XSERVER_LIBPCIACCESS
enum qxl_class
{
@@ -1371,11 +1403,14 @@ static PciChipsets qxlPciChips[] =
{ -1, -1, RES_UNDEFINED }
};
#endif
+#endif /* !XSPICE */
static void
qxl_identify(int flags)
{
+#ifndef XSPICE
xf86PrintChipsets("qxl", "Driver for QXL virtual graphics", qxlChips);
+#endif
}
static void
@@ -1391,6 +1426,37 @@ qxl_init_scrn(ScrnInfoPtr pScrn)
pScrn->LeaveVT = qxl_leave_vt;
}
+#ifdef XSPICE
+static Bool
+qxl_probe(struct _DriverRec *drv, int flags)
+{
+ ScrnInfoPtr pScrn;
+ int entityIndex;
+ EntityInfoPtr pEnt;
+ GDevPtr* device;
+
+ if (flags & PROBE_DETECT) {
+ return TRUE;
+ }
+
+ pScrn = xf86AllocateScreen(drv, flags);
+ qxl_init_scrn(pScrn);
+
+ xf86MatchDevice(QXL_DRIVER_NAME, &device);
+ entityIndex = xf86ClaimNoSlot(drv, 0, device[0], TRUE);
+ pEnt = xf86GetEntityInfo(entityIndex);
+ pEnt->driver = drv;
+
+ xf86AddEntityToScreen(pScrn, entityIndex);
+
+ return TRUE;
+}
+static Bool qxl_driver_func(ScrnInfoPtr screen_info_ptr, xorgDriverFuncOp xorg_driver_func_op, pointer hw_flags)
+{
+ *(xorgHWFlags*)hw_flags = (xorgHWFlags)HW_SKIP_CONSOLE;
+ return TRUE;
+}
+#else /* normal, not XSPICE */
#ifndef XSERVER_LIBPCIACCESS
static Bool
qxl_probe(DriverPtr drv, int flags)
@@ -1459,6 +1525,7 @@ qxl_pci_probe(DriverPtr drv, int entity, struct pci_device *dev, intptr_t match)
#define qxl_probe NULL
#endif
+#endif /* XSPICE */
static DriverRec qxl_driver = {
0,
@@ -1468,11 +1535,17 @@ static DriverRec qxl_driver = {
NULL,
NULL,
0,
+#ifdef XSPICE
+ qxl_driver_func,
+ NULL,
+ NULL
+#else
NULL,
#ifdef XSERVER_LIBPCIACCESS
qxl_device_match,
qxl_pci_probe
#endif
+#endif /* XSPICE */
};
static pointer
--
1.7.4.4
More information about the Spice-devel
mailing list