[Spice-devel] [spice-protocol PATCH 04/46] qxlhw: introducing hardware access callbacks.
Alon Levy
alevy at redhat.com
Tue Apr 10 04:50:00 PDT 2012
qxl_driver_t will not access io ports and pci resources directly, but
through an opaque struct qxlhw which will have two implementations,
qxlhw_pci and qxlhw_drm.
---
src/Makefile.am | 4 ++++
src/qxl.h | 3 +++
src/qxlhw.c | 19 +++++++++++++++++++
src/qxlhw.h | 16 ++++++++++++++++
src/qxlhw_pci.c | 17 +++++++++++++++++
src/qxlhw_pci.h | 14 ++++++++++++++
6 files changed, 73 insertions(+)
create mode 100644 src/qxlhw.c
create mode 100644 src/qxlhw.h
create mode 100644 src/qxlhw_pci.c
create mode 100644 src/qxlhw_pci.h
diff --git a/src/Makefile.am b/src/Makefile.am
index c3ba074..3972b3d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,6 +43,8 @@ qxl_drv_la_SOURCES = \
qxl_surface.c \
qxl_ring.c \
qxl_mem.c \
+ qxlhw.c \
+ qxlhw_pci.c \
mspace.c \
mspace.h \
murmurhash3.c \
@@ -80,6 +82,8 @@ spiceqxl_drv_la_SOURCES = \
qxl_surface.c \
qxl_ring.c \
qxl_mem.c \
+ qxlhw.c \
+ qxlhw_pci.c \
mspace.c \
mspace.h \
murmurhash3.c \
diff --git a/src/qxl.h b/src/qxl.h
index f20a26c..9b3459c 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -31,8 +31,11 @@
#include <spice.h>
#endif
+#include <xorg-server.h>
+
#include "compiler.h"
#include "xf86.h"
+#include "xf86Pci.h"
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
#include "xf86Resources.h"
#endif
diff --git a/src/qxlhw.c b/src/qxlhw.c
new file mode 100644
index 0000000..5673251
--- /dev/null
+++ b/src/qxlhw.c
@@ -0,0 +1,19 @@
+#include "qxlhw.h"
+#include "qxlhw_pci.h"
+
+void qxlhw_init(struct qxlhw *base, qxl_screen_t *qxl)
+{
+ base->qxl = qxl;
+}
+
+struct qxlhw *qxlhw_create(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
+{
+ struct qxlhw *ret = NULL;
+
+ ret = create_qxlhw_pci(qxl, pScrn);
+ if (ret == NULL) {
+ fprintf(stderr, "mayday, cannot find a pci or a drm device!\n");
+ return NULL;
+ }
+ return ret;
+}
diff --git a/src/qxlhw.h b/src/qxlhw.h
new file mode 100644
index 0000000..8c8925b
--- /dev/null
+++ b/src/qxlhw.h
@@ -0,0 +1,16 @@
+#ifndef QXLHW_H
+#define QXLHW_H
+
+#include "qxl.h"
+
+struct qxlhw {
+ qxl_screen_t *qxl;
+};
+
+void qxlhw_init(struct qxlhw *base, qxl_screen_t *qxl);
+
+/* initialization function, determines the qxlhw provider
+ * to use. currently just PCI. */
+struct qxlhw *qxlhw_create(qxl_screen_t *qxl, ScrnInfoPtr pScrn);
+
+#endif // QXLHW_H
diff --git a/src/qxlhw_pci.c b/src/qxlhw_pci.c
new file mode 100644
index 0000000..2d7ac94
--- /dev/null
+++ b/src/qxlhw_pci.c
@@ -0,0 +1,17 @@
+/* vim: set ts=8 : */
+
+#include "qxlhw_pci.h"
+
+struct qxlhw_pci {
+ struct qxlhw base;
+};
+
+/* public entry point */
+struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
+{
+ struct qxlhw_pci *ret = xnfalloc (sizeof(struct qxlhw_pci));
+ struct qxlhw *base = &ret->base;
+
+ qxlhw_init(base, qxl);
+ return base;
+}
diff --git a/src/qxlhw_pci.h b/src/qxlhw_pci.h
new file mode 100644
index 0000000..45c58da
--- /dev/null
+++ b/src/qxlhw_pci.h
@@ -0,0 +1,14 @@
+#ifndef QXLHW_PCI_H
+#define QXLHW_PCI_H
+
+/*
+ * struct qxlhw implementation for direct pci access
+ */
+
+#include "qxlhw.h"
+
+struct qxlhw_pci;
+
+struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn);
+
+#endif
--
1.7.9.3
More information about the Spice-devel
mailing list