summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-04-27 18:18:57 +0300
committerAlon Levy <alevy@redhat.com>2011-07-22 04:37:40 +0300
commitc48574980b1c0924e04a93631ea8fda09f6487da (patch)
tree570f72539eb0cf40caf33a82d443c02bde0c9a77
parent0848656de81df95a456c740d59b05ab51a71b425 (diff)
xspice: add init_qxl_ram
-rw-r--r--src/qxl_driver.c2
-rw-r--r--src/spiceqxl_io_port.c49
-rw-r--r--src/spiceqxl_io_port.h4
3 files changed, 55 insertions, 0 deletions
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 7afbc63..97570e5 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -1321,6 +1321,8 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
#ifndef XSPICE
if (!qxl_check_device(pScrn, qxl))
goto out;
+#else
+ init_qxl_ram(qxl); /* initialize the rings */
#endif
pScrn->videoRam = (qxl->rom->num_pages * 4096) / 1024;
xf86DrvMsg(scrnIndex, X_INFO, "%d KB of video RAM\n", pScrn->videoRam);
diff --git a/src/spiceqxl_io_port.c b/src/spiceqxl_io_port.c
index 8a2ea03..ba6ac4a 100644
--- a/src/spiceqxl_io_port.c
+++ b/src/spiceqxl_io_port.c
@@ -5,6 +5,55 @@
#include "qxl.h"
#include "spiceqxl_io_port.h"
+/* TODO: taken from qemu qxl.c, try to remove dupplication */
+#undef SPICE_RING_PROD_ITEM
+#define SPICE_RING_PROD_ITEM(r, ret) { \
+ typeof(r) start = r; \
+ typeof(r) end = r + 1; \
+ uint32_t prod = (r)->prod & SPICE_RING_INDEX_MASK(r); \
+ typeof(&(r)->items[prod]) m_item = &(r)->items[prod]; \
+ if (!((uint8_t*)m_item >= (uint8_t*)(start) && (uint8_t*)(m_item + 1) <= (uint8_t*)(end))) { \
+ abort(); \
+ } \
+ ret = &m_item->el; \
+ }
+
+#undef SPICE_RING_CONS_ITEM
+#define SPICE_RING_CONS_ITEM(r, ret) { \
+ typeof(r) start = r; \
+ typeof(r) end = r + 1; \
+ uint32_t cons = (r)->cons & SPICE_RING_INDEX_MASK(r); \
+ typeof(&(r)->items[cons]) m_item = &(r)->items[cons]; \
+ if (!((uint8_t*)m_item >= (uint8_t*)(start) && (uint8_t*)(m_item + 1) <= (uint8_t*)(end))) { \
+ abort(); \
+ } \
+ ret = &m_item->el; \
+ }
+
+static int spiceqxl_io_port_debug_level = 5;
+
+#define dprint(_level, _fmt, ...) \
+ do { \
+ if (spiceqxl_io_port_debug_level >= _level) { \
+ fprintf(stderr, _fmt, ## __VA_ARGS__); \
+ } \
+ } while (0)
+
+void init_qxl_ram(qxl_screen_t *qxl)
+{
+ QXLRam *ram = get_ram_header(qxl);
+ uint64_t *item;
+
+ ram->magic = QXL_RAM_MAGIC;
+ ram->int_pending = 0;
+ ram->int_mask = 0;
+ SPICE_RING_INIT(&ram->cmd_ring);
+ SPICE_RING_INIT(&ram->cursor_ring);
+ SPICE_RING_INIT(&ram->release_ring);
+ SPICE_RING_PROD_ITEM(&ram->release_ring, item);
+ *item = 0;
+}
+
/* called from Xorg thread - not worker thread! */
void ioport_write(qxl_screen_t *qxl, uint32_t io_port, uint32_t val)
{
diff --git a/src/spiceqxl_io_port.h b/src/spiceqxl_io_port.h
index 366d23c..f442773 100644
--- a/src/spiceqxl_io_port.h
+++ b/src/spiceqxl_io_port.h
@@ -3,4 +3,8 @@
#include "qxl.h"
+/* used to initialize the rings before the first reset, avoid a valgrind
+ * warning */
+void init_qxl_ram(qxl_screen_t *qxl);
+
#endif // SPICEQXL_IO_PORT_H