[xorg-x11-drv-qxl/f19] add support for udev event catching - for dynamic resize from kernel
Dave Airlie
airlied at fedoraproject.org
Wed Jul 3 04:22:24 UTC 2013
commit 34619717a0047f2d0cffa24c355045554e55b794
Author: Dave Airlie <airlied at redhat.com>
Date: Wed Jul 3 14:21:33 2013 +1000
add support for udev event catching - for dynamic resize from kernel
reorder some patches to make it all build okay
.gitignore | 1 -
0001-qxl-add-uevent-handler-support.patch | 196 +
...dd-old-driver-in-as-a-compatibility-layer.patch | 3845 ++++++++++----------
...nk-in-the-compat-driver-various-renamings.patch | 3762 ++++++++++----------
xorg-x11-drv-qxl.spec | 24 +-
5 files changed, 3972 insertions(+), 3856 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e32a9c3..f709744 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,7 +64,6 @@ core
*.l[oa]
*.[oa]
*.obj
-*.patch
*.so
*.pcf.gz
*.pdb
diff --git a/0001-qxl-add-uevent-handler-support.patch b/0001-qxl-add-uevent-handler-support.patch
new file mode 100644
index 0000000..024d60b
--- /dev/null
+++ b/0001-qxl-add-uevent-handler-support.patch
@@ -0,0 +1,196 @@
+From 131b7a87506adb304be9c479803d6952dce599cd Mon Sep 17 00:00:00 2001
+From: Dave Airlie <airlied at redhat.com>
+Date: Mon, 1 Jul 2013 13:21:13 +1000
+Subject: [PATCH] qxl: add uevent handler support
+
+This allows the driver to process uevents from the kernel when the mode
+changes.
+
+Signed-off-by: Dave Airlie <airlied at redhat.com>
+---
+ configure.ac | 14 +++++++++++++
+ src/Makefile.am | 6 +++++-
+ src/qxl_drmmode.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ src/qxl_drmmode.h | 10 +++++++++
+ src/qxl_kms.c | 3 +++
+ 5 files changed, 94 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index d481cc1..8b2d450 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -135,6 +135,20 @@ fi
+ AM_CONDITIONAL(BUILD_XSPICE, test "x$enable_xspice" = "xyes")
+ AM_CONDITIONAL(BUILD_QXL, test "x$enable_qxl" = "xyes")
+
++AC_ARG_ENABLE([udev],
++ AS_HELP_STRING([--disable-udev], [Disable libudev support [default=auto]]),
++ [enable_udev="$enableval"],
++ [enable_udev=auto])
++if test "x$enable_udev" != "xno"; then
++ PKG_CHECK_MODULES(LIBUDEV, [libudev], [LIBUDEV=yes], [LIBUDEV=no])
++ if test "x$LIBUDEV" = xyes; then
++ AC_DEFINE(HAVE_LIBUDEV, 1,[libudev support])
++ elif test "x$enable_udev" != "xauto"; then
++ AC_MSG_ERROR([Building with udev requested but libudev not found])
++ fi
++fi
++AM_CONDITIONAL(LIBUDEV, test x$LIBUDEV = xyes)
++
+ PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.0])
+
+ # AC_CHECK_FILE is not supported when cross compiling
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 4349b4e..d6a5445 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -27,7 +27,7 @@
+
+ SUBDIRS=uxa
+
+-AM_CFLAGS = $(SPICE_PROTOCOL_CFLAGS) $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(DRM_CFLAGS)
++AM_CFLAGS = $(SPICE_PROTOCOL_CFLAGS) $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(DRM_CFLAGS) @LIBUDEV_CFLAGS@
+
+ if BUILD_QXL
+ qxl_drv_la_LTLIBRARIES = qxl_drv.la
+@@ -35,6 +35,10 @@ qxl_drv_la_LDFLAGS = -module -avoid-version
+ qxl_drv_ladir = @moduledir@/drivers
+
+ qxl_drv_la_LIBADD = uxa/libuxa.la
++if LIBUDEV
++qxl_drv_la_LIBADD += $(LIBUDEV_LIBS)
++endif
++
+
+ qxl_drv_la_SOURCES = \
+ qxl.h \
+diff --git a/src/qxl_drmmode.c b/src/qxl_drmmode.c
+index c1f5c15..03b4124 100644
+--- a/src/qxl_drmmode.c
++++ b/src/qxl_drmmode.c
+@@ -875,4 +875,66 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
+ return TRUE;
+ }
+
++#ifdef HAVE_LIBUDEV
++static void
++drmmode_handle_uevents(int fd, void *closure)
++{
++ drmmode_ptr drmmode = closure;
++ ScrnInfoPtr scrn = drmmode->scrn;
++ struct udev_device *dev;
++ dev = udev_monitor_receive_device(drmmode->uevent_monitor);
++ if (!dev)
++ return;
++
++ RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
++ udev_device_unref(dev);
++}
++#endif
++
++void qxl_drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
++{
++#ifdef HAVE_LIBUDEV
++ struct udev *u;
++ struct udev_monitor *mon;
++
++ u = udev_new();
++ if (!u)
++ return;
++ mon = udev_monitor_new_from_netlink(u, "udev");
++ if (!mon) {
++ udev_unref(u);
++ return;
++ }
++
++ if (udev_monitor_filter_add_match_subsystem_devtype(mon,
++ "drm",
++ "drm_minor") < 0 ||
++ udev_monitor_enable_receiving(mon) < 0) {
++ udev_monitor_unref(mon);
++ udev_unref(u);
++ return;
++ }
++
++ drmmode->uevent_handler =
++ xf86AddGeneralHandler(udev_monitor_get_fd(mon),
++ drmmode_handle_uevents,
++ drmmode);
++
++ drmmode->uevent_monitor = mon;
++#endif
++}
++
++void qxl_drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
++{
++#ifdef HAVE_LIBUDEV
++ if (drmmode->uevent_handler) {
++ struct udev *u = udev_monitor_get_udev(drmmode->uevent_monitor);
++ xf86RemoveGeneralHandler(drmmode->uevent_handler);
++
++ udev_monitor_unref(drmmode->uevent_monitor);
++ udev_unref(u);
++ }
++#endif
++}
++
+ #endif
+diff --git a/src/qxl_drmmode.h b/src/qxl_drmmode.h
+index df076c7..04752ec 100644
+--- a/src/qxl_drmmode.h
++++ b/src/qxl_drmmode.h
+@@ -34,6 +34,9 @@
+ #include "xf86str.h"
+ #include "randrstr.h"
+ #include "xf86Crtc.h"
++#ifdef HAVE_LIBUDEV
++#include "libudev.h"
++#endif
+
+ typedef struct {
+ int fd;
+@@ -42,6 +45,10 @@ typedef struct {
+ drmModeFBPtr mode_fb;
+ int cpp;
+ ScrnInfoPtr scrn;
++#ifdef HAVE_LIBUDEV
++ struct udev_monitor *uevent_monitor;
++ InputHandlerProc uevent_handler;
++#endif
+ } drmmode_rec, *drmmode_ptr;
+
+ typedef struct {
+@@ -78,6 +85,9 @@ typedef struct {
+ } drmmode_output_private_rec, *drmmode_output_private_ptr;
+
+ extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
++
++extern void qxl_drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
++extern void qxl_drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
+ #endif
+
+ #endif
+diff --git a/src/qxl_kms.c b/src/qxl_kms.c
+index b673294..b091a12 100644
+--- a/src/qxl_kms.c
++++ b/src/qxl_kms.c
+@@ -95,6 +95,7 @@ qxl_close_screen_kms (CLOSE_SCREEN_ARGS_DECL)
+ qxl_screen_t *qxl = pScrn->driverPrivate;
+ Bool result;
+
++ qxl_drmmode_uevent_fini(pScrn, &qxl->drmmode);
+ pScreen->CloseScreen = qxl->close_screen;
+
+ result = pScreen->CloseScreen (CLOSE_SCREEN_ARGS);
+@@ -198,6 +199,8 @@ qxl_create_screen_resources_kms(ScreenPtr pScreen)
+
+ set_surface (pPixmap, qxl->primary);
+
++ qxl_drmmode_uevent_init(pScrn, &qxl->drmmode);
++
+ if (!uxa_resources_init (pScreen))
+ return FALSE;
+
+--
+1.8.3.1
+
diff --git a/0002-Add-old-driver-in-as-a-compatibility-layer.patch b/0002-Add-old-driver-in-as-a-compatibility-layer.patch
index 925e109..64930bb 100644
--- a/0002-Add-old-driver-in-as-a-compatibility-layer.patch
+++ b/0002-Add-old-driver-in-as-a-compatibility-layer.patch
@@ -1,36 +1,7 @@
-From d790ececff408f113c40005512c64330f87626eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp at redhat.com>
-Date: Thu, 3 Feb 2011 05:53:01 -0500
-Subject: [PATCH 2/4] Add old driver in as a compatibility layer
-
----
- configure.ac | 1 +
- src/Makefile.am | 2 +-
- src/compat/Makefile.am | 41 ++
- src/compat/compat-lookup3.c | 769 +++++++++++++++++++++
- src/compat/compat-lookup3.h | 26 +
- src/compat/compat-qxl.h | 610 +++++++++++++++++
- src/compat/compat-qxl_cursor.c | 196 ++++++
- src/compat/compat-qxl_driver.c | 1454 ++++++++++++++++++++++++++++++++++++++++
- src/compat/compat-qxl_image.c | 255 +++++++
- src/compat/compat-qxl_mem.c | 321 +++++++++
- src/compat/compat-qxl_ring.c | 97 +++
- 11 files changed, 3771 insertions(+), 1 deletion(-)
- create mode 100644 src/compat/Makefile.am
- create mode 100644 src/compat/compat-lookup3.c
- create mode 100644 src/compat/compat-lookup3.h
- create mode 100644 src/compat/compat-qxl.h
- create mode 100644 src/compat/compat-qxl_cursor.c
- create mode 100644 src/compat/compat-qxl_driver.c
- create mode 100644 src/compat/compat-qxl_image.c
- create mode 100644 src/compat/compat-qxl_mem.c
- create mode 100644 src/compat/compat-qxl_ring.c
-
-diff --git a/configure.ac b/configure.ac
-index 9ebdbd9..847ec30 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -140,6 +140,7 @@ AC_CONFIG_FILES([
+diff -up xf86-video-qxl-20130514/configure.ac.compat xf86-video-qxl-20130514/configure.ac
+--- xf86-video-qxl-20130514/configure.ac.compat 2013-07-03 14:18:40.381914397 +1000
++++ xf86-video-qxl-20130514/configure.ac 2013-07-03 14:18:57.093319209 +1000
+@@ -155,6 +155,7 @@ AC_CONFIG_FILES([
Makefile
src/Makefile
src/uxa/Makefile
@@ -38,71 +9,9 @@ index 9ebdbd9..847ec30 100644
scripts/Makefile
examples/Makefile
])
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 4349b4e..48814bc 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -25,7 +25,7 @@
- # _ladir passes a dummy rpath to libtool so the thing will actually link
- # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
-
--SUBDIRS=uxa
-+SUBDIRS=uxa compat
-
- AM_CFLAGS = $(SPICE_PROTOCOL_CFLAGS) $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(DRM_CFLAGS)
-
-diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am
-new file mode 100644
-index 0000000..84a30f2
---- /dev/null
-+++ b/src/compat/Makefile.am
-@@ -0,0 +1,41 @@
-+# Copyright 2008 Red Hat, Inc.
-+#
-+# Permission is hereby granted, free of charge, to any person obtaining a
-+# copy of this software and associated documentation files (the "Software"),
-+# to deal in the Software without restriction, including without limitation
-+# on the rights to use, copy, modify, merge, publish, distribute, sub
-+# license, and/or sell copies of the Software, and to permit persons to whom
-+# the Software is furnished to do so, subject to the following conditions:
-+#
-+# The above copyright notice and this permission notice (including the next
-+# paragraph) shall be included in all copies or substantial portions of the
-+# Software.
-+#
-+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-+# THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-+# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+
-+
-+# this is obnoxious:
-+# -module lets us name the module exactly how we want
-+# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
-+# _ladir passes a dummy rpath to libtool so the thing will actually link
-+# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
-+qxl_drv_la_LTLIBRARIES = qxl_drv.la
-+qxl_drv_la_LDFLAGS = -module -avoid-version
-+qxl_drv_ladir = @moduledir@/drivers
-+AM_CFLAGS = -g
-+AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS)
-+
-+qxl_drv_la_SOURCES = \
-+ compat-qxl.h \
-+ compat-qxl_driver.c \
-+ compat-qxl_image.c \
-+ compat-qxl_ring.c \
-+ compat-qxl_mem.c \
-+ compat-lookup3.c \
-+ compat-lookup3.h \
-+ compat-qxl_cursor.c
-diff --git a/src/compat/compat-lookup3.c b/src/compat/compat-lookup3.c
-new file mode 100644
-index 0000000..c301d85
---- /dev/null
-+++ b/src/compat/compat-lookup3.c
+diff -up xf86-video-qxl-20130514/src/compat/compat-lookup3.c.compat xf86-video-qxl-20130514/src/compat/compat-lookup3.c
+--- xf86-video-qxl-20130514/src/compat/compat-lookup3.c.compat 2013-07-03 14:18:57.094319233 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-lookup3.c 2013-07-03 14:18:57.094319233 +1000
@@ -0,0 +1,769 @@
+/*
+-------------------------------------------------------------------------------
@@ -873,11 +782,9 @@ index 0000000..c301d85
+ return c;
+}
+
-diff --git a/src/compat/compat-lookup3.h b/src/compat/compat-lookup3.h
-new file mode 100644
-index 0000000..50c1cf4
---- /dev/null
-+++ b/src/compat/compat-lookup3.h
+diff -up xf86-video-qxl-20130514/src/compat/compat-lookup3.h.compat xf86-video-qxl-20130514/src/compat/compat-lookup3.h
+--- xf86-video-qxl-20130514/src/compat/compat-lookup3.h.compat 2013-07-03 14:18:57.094319233 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-lookup3.h 2013-07-03 14:18:57.094319233 +1000
@@ -0,0 +1,26 @@
+#ifndef __LOOKUP3_H
+#define __LOOKUP3_H
@@ -905,14 +812,12 @@ index 0000000..50c1cf4
+uint32_t hashlittle( const void *key, size_t length, uint32_t initval);
+
+#endif
-diff --git a/src/compat/compat-qxl.h b/src/compat/compat-qxl.h
-new file mode 100644
-index 0000000..bec43b3
---- /dev/null
-+++ b/src/compat/compat-qxl.h
-@@ -0,0 +1,610 @@
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_cursor.c.compat xf86-video-qxl-20130514/src/compat/compat-qxl_cursor.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_cursor.c.compat 2013-07-03 14:18:57.094319233 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_cursor.c 2013-07-03 14:18:57.094319233 +1000
+@@ -0,0 +1,196 @@
+/*
-+ * Copyright 2008 Red Hat, Inc.
++ * Copyright 2009 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
@@ -933,2261 +838,2255 @@ index 0000000..bec43b3
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
-+#include "config.h"
-+
-+#include <stdint.h>
++#include <string.h>
++#include "compat-qxl.h"
++#include <cursorstr.h>
+
-+#include "compiler.h"
-+#include "xf86.h"
-+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
-+#include "xf86Resources.h"
-+#endif
-+#include "xf86PciInfo.h"
-+#include "xf86Cursor.h"
-+#include "xf86_OSproc.h"
-+#include "xf86xv.h"
-+#include "shadow.h"
-+#include "micmap.h"
-+#ifdef XSERVER_PCIACCESS
-+#include "pciaccess.h"
-+#endif
-+#include "fb.h"
-+#include "vgaHW.h"
++static void
++push_cursor (qxl_screen_t *qxl, struct qxl_cursor_cmd *cursor)
++{
++ struct qxl_command cmd;
+
-+#define hidden _X_HIDDEN
++ /* See comment on push_command() in qxl_driver.c */
++ if (qxl->rom->mode != ~0)
++ {
++ cmd.type = QXL_CMD_CURSOR;
++ cmd.data = physical_address (qxl, cursor);
++
++ qxl_ring_push (qxl->cursor_ring, &cmd);
++ }
++}
+
-+#define QXL_NAME "qxl"
-+#define QXL_DRIVER_NAME "qxl"
-+#define PCI_VENDOR_RED_HAT 0x1b36
++static struct qxl_cursor_cmd *
++qxl_alloc_cursor_cmd(qxl_screen_t *qxl)
++{
++ struct qxl_cursor_cmd *cmd =
++ qxl_allocnf (qxl, sizeof(struct qxl_cursor_cmd));
+
-+#define PCI_CHIP_QXL_0100 0x0100
++ cmd->release_info.id = pointer_to_u64 (cmd) | 1;
++
++ return cmd;
++}
+
-+#pragma pack(push,1)
++static void
++qxl_set_cursor_position(ScrnInfoPtr pScrn, int x, int y)
++{
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++ struct qxl_cursor_cmd *cmd = qxl_alloc_cursor_cmd(qxl);
+
-+/* I/O port definitions */
-+enum {
-+ QXL_IO_NOTIFY_CMD,
-+ QXL_IO_NOTIFY_CURSOR,
-+ QXL_IO_UPDATE_AREA,
-+ QXL_IO_UPDATE_IRQ,
-+ QXL_IO_NOTIFY_OOM,
-+ QXL_IO_RESET,
-+ QXL_IO_SET_MODE,
-+ QXL_IO_LOG,
-+};
++ qxl->cur_x = x;
++ qxl->cur_y = y;
++
++ cmd->type = QXL_CURSOR_MOVE;
++ cmd->u.position.x = qxl->cur_x + qxl->hot_x;
++ cmd->u.position.y = qxl->cur_y + qxl->hot_y;
+
-+struct qxl_mode {
-+ uint32_t id;
-+ uint32_t x_res;
-+ uint32_t y_res;
-+ uint32_t bits;
-+ uint32_t stride;
-+ uint32_t x_mili;
-+ uint32_t y_mili;
-+ uint32_t orientation;
-+};
++ push_cursor(qxl, cmd);
++}
+
-+typedef enum
++static void
++qxl_load_cursor_image(ScrnInfoPtr pScrn, unsigned char *bits)
+{
-+ QXL_CMD_NOP,
-+ QXL_CMD_DRAW,
-+ QXL_CMD_UPDATE,
-+ QXL_CMD_CURSOR,
-+ QXL_CMD_MESSAGE
-+} qxl_command_type;
++}
+
-+struct qxl_command {
-+ uint64_t data;
-+ uint32_t type;
-+ uint32_t pad;
-+};
++static void
++qxl_set_cursor_colors(ScrnInfoPtr pScrn, int bg, int fg)
++{
++ /* Should not be called since UseHWCursor returned FALSE */
++}
+
-+struct qxl_rect {
-+ uint32_t top;
-+ uint32_t left;
-+ uint32_t bottom;
-+ uint32_t right;
-+};
++static void
++qxl_load_cursor_argb (ScrnInfoPtr pScrn, CursorPtr pCurs)
++{
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++ int w = pCurs->bits->width;
++ int h = pCurs->bits->height;
++ int size = w * h * sizeof (CARD32);
+
-+union qxl_release_info {
-+ uint64_t id;
-+ uint64_t next;
-+};
++ struct qxl_cursor_cmd *cmd = qxl_alloc_cursor_cmd (qxl);
++ struct qxl_cursor *cursor =
++ qxl_allocnf(qxl, sizeof(struct qxl_cursor) + size);
+
-+struct qxl_clip {
-+ uint32_t type;
-+ uint64_t address;
-+};
++ cursor->header.unique = 0;
++ cursor->header.type = CURSOR_TYPE_ALPHA;
++ cursor->header.width = w;
++ cursor->header.height = h;
++ /* I wonder if we can just tell the client that the hotspot is 0, 0
++ * always? The coordinates we are getting from X are for 0, 0 anyway,
++ * so the question is if the client uses the hotspot for anything else?
++ */
++ cursor->header.hot_spot_x = pCurs->bits->xhot;
++ cursor->header.hot_spot_y = pCurs->bits->yhot;
+
-+struct qxl_point {
-+ int x;
-+ int y;
-+};
++ cursor->data_size = size;
++
++ cursor->chunk.next_chunk = 0;
++ cursor->chunk.prev_chunk = 0;
++ cursor->chunk.data_size = size;
+
-+struct qxl_pattern {
-+ uint64_t pat;
-+ struct qxl_point pos;
-+};
++ memcpy (cursor->chunk.data, pCurs->bits->argb, size);
+
-+typedef enum
-+{
-+ QXL_BRUSH_TYPE_NONE,
-+ QXL_BRUSH_TYPE_SOLID,
-+ QXL_BRUSH_TYPE_PATTERN
-+} qxl_brush_type;
++#if 0
++ int i, j;
++ for (j = 0; j < h; ++j)
++ {
++ for (i = 0; i < w; ++i)
++ {
++ ErrorF ("%c", (pCurs->bits->argb[j * w + i] & 0xff000000) == 0xff000000? '#' : '.');
++ }
+
-+struct qxl_brush {
-+ uint32_t type;
-+ union {
-+ uint32_t color;
-+ struct qxl_pattern pattern;
-+ } u;
-+};
++ ErrorF ("\n");
++ }
++#endif
+
-+struct qxl_mask {
-+ unsigned char flags;
-+ struct qxl_point pos;
-+ uint64_t bitmap;
-+};
++ qxl->hot_x = pCurs->bits->xhot;
++ qxl->hot_y = pCurs->bits->yhot;
++
++ cmd->type = QXL_CURSOR_SET;
++ cmd->u.set.position.x = qxl->cur_x + qxl->hot_x;
++ cmd->u.set.position.y = qxl->cur_y + qxl->hot_y;
++ cmd->u.set.shape = physical_address (qxl, cursor);
++ cmd->u.set.visible = TRUE;
+
-+typedef enum {
-+ QXL_IMAGE_TYPE_BITMAP,
-+ QXL_IMAGE_TYPE_QUIC,
-+ QXL_IMAGE_TYPE_PNG,
-+ QXL_IMAGE_TYPE_LZ_PLT = 100,
-+ QXL_IMAGE_TYPE_LZ_RGB,
-+ QXL_IMAGE_TYPE_GLZ_RGB,
-+ QXL_IMAGE_TYPE_FROM_CACHE,
-+} qxl_image_type;
++ push_cursor(qxl, cmd);
++}
+
-+typedef enum {
-+ QXL_IMAGE_CACHE = (1 << 0)
-+} qxl_image_flags;
-+
-+struct qxl_image_descriptor
++static Bool
++qxl_use_hw_cursor (ScreenPtr pScrn, CursorPtr pCurs)
+{
-+ uint64_t id;
-+ uint8_t type;
-+ uint8_t flags;
-+ uint32_t width;
-+ uint32_t height;
-+};
++ /* Old-school bitmap cursors are not
++ * hardware accelerated for now.
++ */
++ return FALSE;
++}
+
-+struct qxl_data_chunk {
-+ uint32_t data_size;
-+ uint64_t prev_chunk;
-+ uint64_t next_chunk;
-+ uint8_t data[0];
-+};
++static Bool
++qxl_use_hw_cursorARGB (ScreenPtr pScrn, CursorPtr pCurs)
++{
++ return TRUE;
++}
+
-+typedef enum
++static void
++qxl_hide_cursor(ScrnInfoPtr pScrn)
+{
-+ QXL_BITMAP_FMT_INVALID,
-+ QXL_BITMAP_FMT_1BIT_LE,
-+ QXL_BITMAP_FMT_1BIT_BE,
-+ QXL_BITMAP_FMT_4BIT_LE,
-+ QXL_BITMAP_FMT_4BIT_BE,
-+ QXL_BITMAP_FMT_8BIT,
-+ QXL_BITMAP_FMT_16BIT,
-+ QXL_BITMAP_FMT_24BIT,
-+ QXL_BITMAP_FMT_32BIT,
-+ QXL_BITMAP_FMT_RGBA,
-+} qxl_bitmap_format;
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++ struct qxl_cursor_cmd *cursor = qxl_alloc_cursor_cmd(qxl);
+
-+typedef enum {
-+ QXL_BITMAP_PAL_CACHE_ME = (1 << 0),
-+ QXL_BITMAP_PAL_FROM_CACHE = (1 << 1),
-+ QXL_BITMAP_TOP_DOWN = (1 << 2),
-+} qxl_bitmap_flags;
++ cursor->type = QXL_CURSOR_HIDE;
+
-+struct qxl_bitmap {
-+ uint8_t format;
-+ uint8_t flags;
-+ uint32_t x; /* actually width */
-+ uint32_t y; /* actually height */
-+ uint32_t stride; /* in bytes */
-+ uint64_t palette; /* Can be NULL */
-+ uint64_t data; /* A qxl_data_chunk that actually contains the data */
-+};
++ push_cursor(qxl, cursor);
++}
+
-+struct qxl_image {
-+ struct qxl_image_descriptor descriptor;
-+ union
-+ {
-+ struct qxl_bitmap bitmap;
-+ } u;
-+};
++static void
++qxl_show_cursor(ScrnInfoPtr pScrn)
++{
++ /*
++ * slightly hacky, but there's no QXL_CURSOR_SHOW. Could maybe do
++ * QXL_CURSOR_SET?
++ */
++ qxl_screen_t *qxl = pScrn->driverPrivate;
+
-+struct qxl_fill {
-+ struct qxl_brush brush;
-+ unsigned short rop_descriptor;
-+ struct qxl_mask mask;
-+};
++ qxl_set_cursor_position(pScrn, qxl->cur_x, qxl->cur_y);
++}
+
-+struct qxl_opaque {
-+ uint64_t src_bitmap;
-+ struct qxl_rect src_area;
-+ struct qxl_brush brush;
-+ unsigned short rop_descriptor;
-+ unsigned char scale_mode;
-+ struct qxl_mask mask;
-+};
++hidden void
++qxl_cursor_init(ScreenPtr pScreen)
++{
++ xf86CursorInfoPtr cursor;
+
-+struct qxl_copy {
-+ uint64_t src_bitmap;
-+ struct qxl_rect src_area;
-+ unsigned short rop_descriptor;
-+ unsigned char scale_mode;
-+ struct qxl_mask mask;
-+};
++ cursor = xcalloc(1, sizeof(xf86CursorInfoRec));
++ if (!cursor)
++ return;
+
-+struct qxl_transparent {
-+ uint64_t src_bitmap;
-+ struct qxl_rect src_area;
-+ uint32_t src_color;
-+ uint32_t true_color;
-+};
++ cursor->MaxWidth = cursor->MaxHeight = 64;
++ /* cursor->Flags; */
++ cursor->SetCursorPosition = qxl_set_cursor_position;
++ cursor->LoadCursorARGB = qxl_load_cursor_argb;
++ cursor->UseHWCursor = qxl_use_hw_cursor;
++ cursor->UseHWCursorARGB = qxl_use_hw_cursorARGB;
++ cursor->LoadCursorImage = qxl_load_cursor_image;
++ cursor->SetCursorColors = qxl_set_cursor_colors;
++ cursor->HideCursor = qxl_hide_cursor;
++ cursor->ShowCursor = qxl_show_cursor;
+
-+struct qxl_alpha_blend {
-+ unsigned char alpha;
-+ uint64_t src_bitmap;
-+ struct qxl_rect src_area;
-+};
++ if (!xf86InitCursor(pScreen, cursor))
++ xfree(cursor);
++}
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_driver.c.compat xf86-video-qxl-20130514/src/compat/compat-qxl_driver.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_driver.c.compat 2013-07-03 14:18:57.095319258 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_driver.c 2013-07-03 14:18:57.095319258 +1000
+@@ -0,0 +1,1454 @@
++/*
++ * Copyright 2008 Red Hat, Inc.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * on the rights to use, copy, modify, merge, publish, distribute, sub
++ * license, and/or sell copies of the Software, and to permit persons to whom
++ * the Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice (including the next
++ * paragraph) shall be included in all copies or substantial portions of the
++ * Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
++ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
+
-+struct qxl_copy_bits {
-+ struct qxl_point src_pos;
-+};
++/** \file qxl_driver.c
++ * \author Adam Jackson <ajax at redhat.com>
++ *
++ * This is qxl, a driver for the Qumranet paravirtualized graphics device
++ * in qemu.
++ */
+
-+struct qxl_blend { /* same as copy */
-+ uint64_t src_bitmap;
-+ struct qxl_rect src_area;
-+ unsigned short rop_descriptor;
-+ unsigned char scale_mode;
-+ struct qxl_mask mask;
-+};
++#include <unistd.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++#include <time.h>
++#include <stdlib.h>
++#include "compat-qxl.h"
++#include "assert.h"
+
-+struct qxl_rop3 {
-+ uint64_t src_bitmap;
-+ struct qxl_rect src_area;
-+ struct qxl_brush brush;
-+ unsigned char rop3;
-+ unsigned char scale_mode;
-+ struct qxl_mask mask;
-+};
++#define CHECK_POINT()
+
-+struct qxl_line_attr {
-+ unsigned char flags;
-+ unsigned char join_style;
-+ unsigned char end_style;
-+ unsigned char style_nseg;
-+ int width;
-+ int miter_limit;
-+ uint64_t style;
-+};
++static int
++garbage_collect (qxl_screen_t *qxl)
++{
++ uint64_t id;
++ int i = 0;
++
++ while (qxl_ring_pop (qxl->release_ring, &id))
++ {
++ while (id)
++ {
++ /* We assume that there the two low bits of a pointer are
++ * available. If the low one is set, then the command in
++ * question is a cursor command
++ */
++#define POINTER_MASK ((1 << 2) - 1)
++
++ union qxl_release_info *info = u64_to_pointer (id & ~POINTER_MASK);
++ struct qxl_cursor_cmd *cmd = (struct qxl_cursor_cmd *)info;
++ struct qxl_drawable *drawable = (struct qxl_drawable *)info;
++ int is_cursor = FALSE;
+
-+struct qxl_stroke {
-+ uint64_t path;
-+ struct qxl_line_attr attr;
-+ struct qxl_brush brush;
-+ unsigned short fore_mode;
-+ unsigned short back_mode;
-+};
++ if ((id & POINTER_MASK) == 1)
++ is_cursor = TRUE;
+
-+struct qxl_text {
-+ uint64_t str;
-+ struct qxl_rect back_area;
-+ struct qxl_brush fore_brush;
-+ struct qxl_brush back_brush;
-+ unsigned short fore_mode;
-+ unsigned short back_mode;
-+};
++ if (is_cursor && cmd->type == QXL_CURSOR_SET)
++ {
++ struct qxl_cursor *cursor = (void *)virtual_address (
++ qxl, u64_to_pointer (cmd->u.set.shape));
+
-+struct qxl_blackness {
-+ struct qxl_mask mask;
-+};
++ qxl_free (qxl->mem, cursor);
++ }
++ else if (!is_cursor && drawable->type == QXL_DRAW_COPY)
++ {
++ struct qxl_image *image = virtual_address (
++ qxl, u64_to_pointer (drawable->u.copy.src_bitmap));
+
-+struct qxl_inverse {
-+ struct qxl_mask mask;
-+};
++ qxl_image_destroy (qxl, image);
++ }
++
++ id = info->next;
++
++ qxl_free (qxl->mem, info);
++ }
++ }
+
-+struct qxl_whiteness {
-+ struct qxl_mask mask;
-+};
++ return i > 0;
++}
+
-+/* Effects */
-+typedef enum
++static void
++qxl_usleep (int useconds)
+{
-+ QXL_EFFECT_BLEND,
-+ QXL_EFFECT_OPAQUE,
-+ QXL_EFFECT_REVERT_ON_DUP,
-+ QXL_EFFECT_BLACKNESS_ON_DUP,
-+ QXL_EFFECT_WHITENESS_ON_DUP,
-+ QXL_EFFECT_NOP_ON_DUP,
-+ QXL_EFFECT_NOP,
-+ QXL_EFFECT_OPAQUE_BRUSH
-+} qxl_effect_type;
++ struct timespec t;
+
-+typedef enum
++ t.tv_sec = useconds / 1000000;
++ t.tv_nsec = (useconds - (t.tv_sec * 1000000)) * 1000;
++
++ errno = 0;
++ while (nanosleep (&t, &t) == -1 && errno == EINTR)
++ ;
++
++}
++
++#if 0
++static void
++push_update_area (qxl_screen_t *qxl, const struct qxl_rect *area)
+{
-+ QXL_CLIP_TYPE_NONE,
-+ QXL_CLIP_TYPE_RECTS,
-+ QXL_CLIP_TYPE_PATH,
-+} qxl_clip_type;
++ struct qxl_update_cmd *update = qxl_allocnf (qxl, sizeof *update);
++ struct qxl_command cmd;
+
-+typedef enum {
-+ QXL_DRAW_NOP,
-+ QXL_DRAW_FILL,
-+ QXL_DRAW_OPAQUE,
-+ QXL_DRAW_COPY,
-+ QXL_COPY_BITS,
-+ QXL_DRAW_BLEND,
-+ QXL_DRAW_BLACKNESS,
-+ QXL_DRAW_WHITENESS,
-+ QXL_DRAW_INVERS,
-+ QXL_DRAW_ROP3,
-+ QXL_DRAW_STROKE,
-+ QXL_DRAW_TEXT,
-+ QXL_DRAW_TRANSPARENT,
-+ QXL_DRAW_ALPHA_BLEND,
-+} qxl_draw_type;
++ update->release_info.id = (uint64_t)update;
++ update->area = *area;
++ update->update_id = 0;
+
-+struct qxl_drawable {
-+ union qxl_release_info release_info;
-+ unsigned char effect;
-+ unsigned char type;
-+ unsigned short bitmap_offset;
-+ struct qxl_rect bitmap_area;
-+ struct qxl_rect bbox;
-+ struct qxl_clip clip;
-+ uint32_t mm_time;
-+ union {
-+ struct qxl_fill fill;
-+ struct qxl_opaque opaque;
-+ struct qxl_copy copy;
-+ struct qxl_transparent transparent;
-+ struct qxl_alpha_blend alpha_blend;
-+ struct qxl_copy_bits copy_bits;
-+ struct qxl_blend blend;
-+ struct qxl_rop3 rop3;
-+ struct qxl_stroke stroke;
-+ struct qxl_text text;
-+ struct qxl_blackness blackness;
-+ struct qxl_inverse inverse;
-+ struct qxl_whiteness whiteness;
-+ } u;
-+};
++ cmd.type = QXL_CMD_UDPATE;
++ cmd.data = physical_address (qxl, update);
+
-+struct qxl_update_cmd {
-+ union qxl_release_info release_info;
-+ struct qxl_rect area;
-+ uint32_t update_id;
-+};
++ qxl_ring_push (qxl->command_ring, &cmd);
++}
++#endif
+
-+struct qxl_point16 {
-+ int16_t x;
-+ int16_t y;
-+};
++void *
++qxl_allocnf (qxl_screen_t *qxl, unsigned long size)
++{
++ void *result;
++ int n_attempts = 0;
++ static int nth_oom = 1;
+
-+enum {
-+ QXL_CURSOR_SET,
-+ QXL_CURSOR_MOVE,
-+ QXL_CURSOR_HIDE,
-+ QXL_CURSOR_TRAIL,
-+};
++ garbage_collect (qxl);
++
++ while (!(result = qxl_alloc (qxl->mem, size)))
++ {
++ struct qxl_ram_header *ram_header = (void *)((unsigned long)qxl->ram +
++ qxl->rom->ram_header_offset);
++
++ /* Rather than go out of memory, we simply tell the
++ * device to dump everything
++ */
++ ram_header->update_area.top = 0;
++ ram_header->update_area.bottom = 1280;
++ ram_header->update_area.left = 0;
++ ram_header->update_area.right = 800;
++
++ outb (qxl->io_base + QXL_IO_UPDATE_AREA, 0);
++
++ ErrorF ("eliminated memory (%d)\n", nth_oom++);
+
-+#define QXL_CURSOR_DEVICE_DATA_SIZE 128
++ outb (qxl->io_base + QXL_IO_NOTIFY_OOM, 0);
+
-+enum {
-+ CURSOR_TYPE_ALPHA,
-+ CURSOR_TYPE_MONO,
-+ CURSOR_TYPE_COLOR4,
-+ CURSOR_TYPE_COLOR8,
-+ CURSOR_TYPE_COLOR16,
-+ CURSOR_TYPE_COLOR24,
-+ CURSOR_TYPE_COLOR32,
-+};
++ qxl_usleep (10000);
++
++ if (garbage_collect (qxl))
++ {
++ n_attempts = 0;
++ }
++ else if (++n_attempts == 1000)
++ {
++ qxl_mem_dump_stats (qxl->mem, "Out of mem - stats\n");
++
++ fprintf (stderr, "Out of memory\n");
++ exit (1);
++ }
++ }
+
-+struct qxl_cursor_header {
-+ uint64_t unique;
-+ uint16_t type;
-+ uint16_t width;
-+ uint16_t height;
-+ uint16_t hot_spot_x;
-+ uint16_t hot_spot_y;
-+};
++ return result;
++}
+
-+struct qxl_cursor
++static Bool
++qxl_blank_screen(ScreenPtr pScreen, int mode)
+{
-+ struct qxl_cursor_header header;
-+ uint32_t data_size;
-+ struct qxl_data_chunk chunk;
-+};
++ return TRUE;
++}
+
-+struct qxl_cursor_cmd {
-+ union qxl_release_info release_info;
-+ uint8_t type;
-+ union {
-+ struct {
-+ struct qxl_point16 position;
-+ unsigned char visible;
-+ uint64_t shape;
-+ } set;
-+ struct {
-+ uint16_t length;
-+ uint16_t frequency;
-+ } trail;
-+ struct qxl_point16 position;
-+ } u;
-+ uint8_t device_data[QXL_CURSOR_DEVICE_DATA_SIZE];
-+};
++static void
++qxl_unmap_memory(qxl_screen_t *qxl, int scrnIndex)
++{
++#ifdef XSERVER_LIBPCIACCESS
++ if (qxl->ram)
++ pci_device_unmap_range(qxl->pci, qxl->ram, qxl->pci->regions[0].size);
++ if (qxl->vram)
++ pci_device_unmap_range(qxl->pci, qxl->vram, qxl->pci->regions[1].size);
++ if (qxl->rom)
++ pci_device_unmap_range(qxl->pci, qxl->rom, qxl->pci->regions[2].size);
++#else
++ if (qxl->ram)
++ xf86UnMapVidMem(scrnIndex, qxl->ram, (1 << qxl->pci->size[0]));
++ if (qxl->vram)
++ xf86UnMapVidMem(scrnIndex, qxl->vram, (1 << qxl->pci->size[1]));
++ if (qxl->rom)
++ xf86UnMapVidMem(scrnIndex, qxl->rom, (1 << qxl->pci->size[2]));
++#endif
+
-+struct qxl_rom {
-+ uint32_t magic;
-+ uint32_t id;
-+ uint32_t update_id;
-+ uint32_t compression_level;
-+ uint32_t log_level;
-+ uint32_t mode;
-+ uint32_t modes_offset;
-+ uint32_t num_io_pages;
-+ uint32_t pages_offset;
-+ uint32_t draw_area_offset;
-+ uint32_t draw_area_size;
-+ uint32_t ram_header_offset;
-+ uint32_t mm_clock;
-+};
++ qxl->ram = qxl->ram_physical = qxl->vram = qxl->rom = NULL;
+
-+struct qxl_ring_header {
-+ uint32_t num_items;
-+ uint32_t prod;
-+ uint32_t notify_on_prod;
-+ uint32_t cons;
-+ uint32_t notify_on_cons;
-+};
++ qxl->num_modes = 0;
++ qxl->modes = NULL;
++}
+
-+#define QXL_LOG_BUF_SIZE 4096
++static Bool
++qxl_map_memory(qxl_screen_t *qxl, int scrnIndex)
++{
++#ifdef XSERVER_LIBPCIACCESS
++ pci_device_map_range(qxl->pci, qxl->pci->regions[0].base_addr,
++ qxl->pci->regions[0].size,
++ PCI_DEV_MAP_FLAG_WRITABLE | PCI_DEV_MAP_FLAG_WRITE_COMBINE,
++ &qxl->ram);
++ qxl->ram_physical = u64_to_pointer (qxl->pci->regions[0].base_addr);
+
-+struct qxl_ram_header {
-+ uint32_t magic;
-+ uint32_t int_pending;
-+ uint32_t int_mask;
-+ unsigned char log_buf[QXL_LOG_BUF_SIZE];
-+ struct qxl_ring_header cmd_ring_hdr;
-+ struct qxl_command cmd_ring[32];
-+ struct qxl_ring_header cursor_ring_hdr;
-+ struct qxl_command cursor_ring[32];
-+ struct qxl_ring_header release_ring_hdr;
-+ uint64_t release_ring[8];
-+ struct qxl_rect update_area;
-+};
++ pci_device_map_range(qxl->pci, qxl->pci->regions[1].base_addr,
++ qxl->pci->regions[1].size,
++ PCI_DEV_MAP_FLAG_WRITABLE,
++ &qxl->vram);
+
-+#pragma pack(pop)
-+
-+typedef struct _qxl_screen_t qxl_screen_t;
++ pci_device_map_range(qxl->pci, qxl->pci->regions[2].base_addr,
++ qxl->pci->regions[2].size, 0,
++ (void **)&qxl->rom);
+
-+struct _qxl_screen_t
-+{
-+ /* These are the names QXL uses */
-+ void * ram; /* Video RAM */
-+ void * ram_physical;
-+ void * vram; /* Command RAM */
-+ struct qxl_rom * rom; /* Parameter RAM */
-+
-+ struct qxl_ring * command_ring;
-+ struct qxl_ring * cursor_ring;
-+ struct qxl_ring * release_ring;
++ qxl->io_base = qxl->pci->regions[3].base_addr;
++#else
++ qxl->ram = xf86MapPciMem(scrnIndex, VIDMEM_FRAMEBUFFER,
++ qxl->pci_tag, qxl->pci->memBase[0],
++ (1 << qxl->pci->size[0]));
++ qxl->ram_physical = (void *)qxl->pci->memBase[0];
+
-+ int num_modes;
-+ struct qxl_mode * modes;
-+ int io_base;
-+ int draw_area_offset;
-+ int draw_area_size;
-+
-+ void * fb;
-+ int bytes_per_pixel;
-+
-+ struct qxl_mem * mem; /* Context for qxl_alloc/free */
++ qxl->vram = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
++ qxl->pci_tag, qxl->pci->memBase[1],
++ (1 << qxl->pci->size[1]));
+
-+ EntityInfoPtr entity;
-+
-+ void * io_pages;
-+ void * io_pages_physical;
++ qxl->rom = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
++ qxl->pci_tag, qxl->pci->memBase[2],
++ (1 << qxl->pci->size[2]));
+
-+#ifdef XSERVER_LIBPCIACCESS
-+ struct pci_device * pci;
-+#else
-+ pciVideoPtr pci;
-+ PCITAG pci_tag;
++ qxl->io_base = qxl->pci->ioBase[3];
+#endif
-+ vgaRegRec vgaRegs;
++ if (!qxl->ram || !qxl->vram || !qxl->rom)
++ return FALSE;
+
-+ CreateScreenResourcesProcPtr create_screen_resources;
-+ CloseScreenProcPtr close_screen;
-+ CreateGCProcPtr create_gc;
-+#if 0
-+ PaintWindowProcPtr paint_window_background;
-+ PaintWindowProcPtr paint_window_border;
-+#endif
-+ CopyWindowProcPtr copy_window;
-+
-+ DamagePtr damage;
-+ RegionRec pending_copy;
-+ RegionRec to_be_sent;
-+
-+ int16_t cur_x;
-+ int16_t cur_y;
-+ int16_t hot_x;
-+ int16_t hot_y;
-+
-+ ScrnInfoPtr pScrn;
-+};
++ xf86DrvMsg(scrnIndex, X_INFO, "ram at %p; vram at %p; rom at %p\n",
++ qxl->ram, qxl->vram, qxl->rom);
+
-+static inline uint64_t
-+physical_address (qxl_screen_t *qxl, void *virtual)
-+{
-+ return (uint64_t) ((unsigned long)virtual + (((unsigned long)qxl->ram_physical - (unsigned long)qxl->ram)));
-+}
++ qxl->num_modes = *(uint32_t *)((uint8_t *)qxl->rom + qxl->rom->modes_offset);
++ qxl->modes = (struct qxl_mode *)(((uint8_t *)qxl->rom) + qxl->rom->modes_offset + 4);
+
-+static inline void *
-+virtual_address (qxl_screen_t *qxl, void *physical)
-+{
-+ return (void *) ((unsigned long)physical + ((unsigned long)qxl->ram - (unsigned long)qxl->ram_physical));
++ return TRUE;
+}
+
-+static inline void *
-+u64_to_pointer (uint64_t u)
++static void
++qxl_save_state(ScrnInfoPtr pScrn)
+{
-+ return (void *)(unsigned long)u;
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++
++ vgaHWSaveFonts(pScrn, &qxl->vgaRegs);
+}
+
-+static inline uint64_t
-+pointer_to_u64 (void *p)
++static void
++qxl_restore_state(ScrnInfoPtr pScrn)
+{
-+ return (uint64_t)(unsigned long)p;
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++
++ vgaHWRestoreFonts(pScrn, &qxl->vgaRegs);
+}
+
-+struct qxl_ring;
++static Bool
++qxl_close_screen(int scrnIndex, ScreenPtr pScreen)
++{
++ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
++ qxl_screen_t *qxl = pScrn->driverPrivate;
+
-+/*
-+ * HW cursor
-+ */
-+void qxl_cursor_init (ScreenPtr pScreen);
++ if (pScrn->vtSema) {
++ qxl_restore_state(pScrn);
++ qxl_unmap_memory(qxl, scrnIndex);
++ }
++ pScrn->vtSema = FALSE;
+
++ xfree(qxl->fb);
+
++ pScreen->CreateScreenResources = qxl->create_screen_resources;
++ pScreen->CloseScreen = qxl->close_screen;
+
-+/*
-+ * Rings
-+ */
-+struct qxl_ring * qxl_ring_create (struct qxl_ring_header *header,
-+ int element_size,
-+ int n_elements,
-+ int prod_notify);
-+void qxl_ring_push (struct qxl_ring *ring,
-+ const void *element);
-+Bool qxl_ring_pop (struct qxl_ring *ring,
-+ void *element);
-+void qxl_ring_wait_idle (struct qxl_ring *ring);
++ return pScreen->CloseScreen(scrnIndex, pScreen);
++}
+
++static Bool
++qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
++{
++ qxl_screen_t *qxl = xf86Screens[scrnIndex]->driverPrivate;
++ int mode_index = (int)(unsigned long)p->Private;
++ struct qxl_mode *m = qxl->modes + mode_index;
++ ScreenPtr pScreen = qxl->pScrn->pScreen;
+
++ if (!m)
++ return FALSE;
+
-+/*
-+ * Images
-+ */
-+struct qxl_image *qxl_image_create (qxl_screen_t *qxl,
-+ const uint8_t *data,
-+ int x,
-+ int y,
-+ int width,
-+ int height,
-+ int stride);
-+void qxl_image_destroy (qxl_screen_t *qxl,
-+ struct qxl_image *image);
-+void qxl_drop_image_cache (qxl_screen_t *qxl);
++ /* if (debug) */
++ xf86DrvMsg (scrnIndex, X_INFO, "Setting mode %d (%d x %d) (%d x %d) %p\n",
++ m->id, m->x_res, m->y_res, p->HDisplay, p->VDisplay, p);
+
++ outb(qxl->io_base + QXL_IO_RESET, 0);
++
++ outb(qxl->io_base + QXL_IO_SET_MODE, m->id);
+
-+/*
-+ * Malloc
-+ */
-+struct qxl_mem * qxl_mem_create (void *base,
-+ unsigned long n_bytes);
-+void qxl_mem_dump_stats (struct qxl_mem *mem,
-+ const char *header);
-+void * qxl_alloc (struct qxl_mem *mem,
-+ unsigned long n_bytes);
-+void qxl_free (struct qxl_mem *mem,
-+ void *d);
-+void qxl_mem_free_all (struct qxl_mem *mem);
-+void * qxl_allocnf (qxl_screen_t *qxl,
-+ unsigned long size);
++ qxl->bytes_per_pixel = (qxl->pScrn->bitsPerPixel + 7) / 8;
+
++ /* If this happens out of ScreenInit, we won't have a screen yet. In that
++ * case createScreenResources will make things right.
++ */
++ if (pScreen)
++ {
++ PixmapPtr pPixmap = pScreen->GetScreenPixmap(pScreen);
+
-diff --git a/src/compat/compat-qxl_cursor.c b/src/compat/compat-qxl_cursor.c
-new file mode 100644
-index 0000000..bb5387e
---- /dev/null
-+++ b/src/compat/compat-qxl_cursor.c
-@@ -0,0 +1,196 @@
-+/*
-+ * Copyright 2009 Red Hat, Inc.
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * on the rights to use, copy, modify, merge, publish, distribute, sub
-+ * license, and/or sell copies of the Software, and to permit persons to whom
-+ * the Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice (including the next
-+ * paragraph) shall be included in all copies or substantial portions of the
-+ * Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
++ if (pPixmap)
++ {
++ pScreen->ModifyPixmapHeader(
++ pPixmap,
++ m->x_res, m->y_res,
++ -1, -1,
++ qxl->pScrn->displayWidth * qxl->bytes_per_pixel,
++ NULL);
++ }
++ }
++
++ if (qxl->mem)
++ {
++ qxl_mem_free_all (qxl->mem);
++ qxl_drop_image_cache (qxl);
++ }
+
-+#include <string.h>
-+#include "compat-qxl.h"
-+#include <cursorstr.h>
++
++ return TRUE;
++}
+
+static void
-+push_cursor (qxl_screen_t *qxl, struct qxl_cursor_cmd *cursor)
++push_drawable (qxl_screen_t *qxl, struct qxl_drawable *drawable)
+{
+ struct qxl_command cmd;
+
-+ /* See comment on push_command() in qxl_driver.c */
++ /* When someone runs "init 3", the device will be
++ * switched into VGA mode and there is nothing we
++ * can do about it. We get no notification.
++ *
++ * However, if commands are submitted when the device
++ * is in VGA mode, they will be queued up, and then
++ * the next time a mode set set, an assertion in the
++ * device will take down the entire virtual machine.
++ *
++ * The author of the QXL device is opposed to this
++ * for reasons I don't understand.
++ */
+ if (qxl->rom->mode != ~0)
+ {
-+ cmd.type = QXL_CMD_CURSOR;
-+ cmd.data = physical_address (qxl, cursor);
-+
-+ qxl_ring_push (qxl->cursor_ring, &cmd);
++ cmd.type = QXL_CMD_DRAW;
++ cmd.data = physical_address (qxl, drawable);
++
++ qxl_ring_push (qxl->command_ring, &cmd);
+ }
+}
+
-+static struct qxl_cursor_cmd *
-+qxl_alloc_cursor_cmd(qxl_screen_t *qxl)
++static struct qxl_drawable *
++make_drawable (qxl_screen_t *qxl, uint8_t type,
++ const struct qxl_rect *rect
++ /* , pRegion clip */)
+{
-+ struct qxl_cursor_cmd *cmd =
-+ qxl_allocnf (qxl, sizeof(struct qxl_cursor_cmd));
++ struct qxl_drawable *drawable;
+
-+ cmd->release_info.id = pointer_to_u64 (cmd) | 1;
++ CHECK_POINT();
+
-+ return cmd;
++ drawable = qxl_allocnf (qxl, sizeof *drawable);
++
++ CHECK_POINT();
++
++ drawable->release_info.id = pointer_to_u64 (drawable);
++
++ drawable->type = type;
++
++ drawable->effect = QXL_EFFECT_OPAQUE;
++ drawable->bitmap_offset = 0;
++ drawable->bitmap_area.top = 0;
++ drawable->bitmap_area.left = 0;
++ drawable->bitmap_area.bottom = 0;
++ drawable->bitmap_area.right = 0;
++ /* FIXME: add clipping */
++ drawable->clip.type = QXL_CLIP_TYPE_NONE;
++
++ if (rect)
++ drawable->bbox = *rect;
++
++ drawable->mm_time = qxl->rom->mm_clock;
++
++ CHECK_POINT();
++
++ return drawable;
+}
+
++enum ROPDescriptor {
++ ROPD_INVERS_SRC = (1 << 0),
++ ROPD_INVERS_BRUSH = (1 << 1),
++ ROPD_INVERS_DEST = (1 << 2),
++ ROPD_OP_PUT = (1 << 3),
++ ROPD_OP_OR = (1 << 4),
++ ROPD_OP_AND = (1 << 5),
++ ROPD_OP_XOR = (1 << 6),
++ ROPD_OP_BLACKNESS = (1 << 7),
++ ROPD_OP_WHITENESS = (1 << 8),
++ ROPD_OP_INVERS = (1 << 9),
++ ROPD_INVERS_RES = (1 <<10),
++};
++
+static void
-+qxl_set_cursor_position(ScrnInfoPtr pScrn, int x, int y)
++undamage_box (qxl_screen_t *qxl, const struct qxl_rect *rect)
+{
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ struct qxl_cursor_cmd *cmd = qxl_alloc_cursor_cmd(qxl);
++ RegionRec region;
++ BoxRec box;
+
-+ qxl->cur_x = x;
-+ qxl->cur_y = y;
-+
-+ cmd->type = QXL_CURSOR_MOVE;
-+ cmd->u.position.x = qxl->cur_x + qxl->hot_x;
-+ cmd->u.position.y = qxl->cur_y + qxl->hot_y;
++ box.x1 = rect->left;
++ box.y1 = rect->top;
++ box.x2 = rect->right;
++ box.y2 = rect->bottom;
+
-+ push_cursor(qxl, cmd);
++ REGION_INIT (qxl->pScrn->pScreen, ®ion, &box, 0);
++
++ REGION_SUBTRACT (qxl->pScrn->pScreen, &(qxl->pending_copy), &(qxl->pending_copy), ®ion);
++
++ REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
+}
+
+static void
-+qxl_load_cursor_image(ScrnInfoPtr pScrn, unsigned char *bits)
++clear_pending_damage (qxl_screen_t *qxl)
+{
++ REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
+}
+
+static void
-+qxl_set_cursor_colors(ScrnInfoPtr pScrn, int bg, int fg)
++submit_fill (qxl_screen_t *qxl, const struct qxl_rect *rect, uint32_t color)
+{
-+ /* Should not be called since UseHWCursor returned FALSE */
++ struct qxl_drawable *drawable;
++
++ CHECK_POINT();
++
++ drawable = make_drawable (qxl, QXL_DRAW_FILL, rect);
++
++ CHECK_POINT();
++
++ drawable->u.fill.brush.type = QXL_BRUSH_TYPE_SOLID;
++ drawable->u.fill.brush.u.color = color;
++ drawable->u.fill.rop_descriptor = ROPD_OP_PUT;
++ drawable->u.fill.mask.flags = 0;
++ drawable->u.fill.mask.pos.x = 0;
++ drawable->u.fill.mask.pos.y = 0;
++ drawable->u.fill.mask.bitmap = 0;
++
++ push_drawable (qxl, drawable);
++
++ undamage_box (qxl, rect);
+}
+
+static void
-+qxl_load_cursor_argb (ScrnInfoPtr pScrn, CursorPtr pCurs)
++translate_rect (struct qxl_rect *rect)
+{
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ int w = pCurs->bits->width;
-+ int h = pCurs->bits->height;
-+ int size = w * h * sizeof (CARD32);
-+
-+ struct qxl_cursor_cmd *cmd = qxl_alloc_cursor_cmd (qxl);
-+ struct qxl_cursor *cursor =
-+ qxl_allocnf(qxl, sizeof(struct qxl_cursor) + size);
++ rect->right -= rect->left;
++ rect->bottom -= rect->top;
++ rect->left = rect->top = 0;
++}
+
-+ cursor->header.unique = 0;
-+ cursor->header.type = CURSOR_TYPE_ALPHA;
-+ cursor->header.width = w;
-+ cursor->header.height = h;
-+ /* I wonder if we can just tell the client that the hotspot is 0, 0
-+ * always? The coordinates we are getting from X are for 0, 0 anyway,
-+ * so the question is if the client uses the hotspot for anything else?
-+ */
-+ cursor->header.hot_spot_x = pCurs->bits->xhot;
-+ cursor->header.hot_spot_y = pCurs->bits->yhot;
++static void
++submit_copy (qxl_screen_t *qxl, const struct qxl_rect *rect)
++{
++ struct qxl_drawable *drawable;
++ ScrnInfoPtr pScrn = qxl->pScrn;
+
-+ cursor->data_size = size;
++ if (rect->left == rect->right ||
++ rect->top == rect->bottom)
++ {
++ /* Empty rectangle */
++ return ;
++ }
+
-+ cursor->chunk.next_chunk = 0;
-+ cursor->chunk.prev_chunk = 0;
-+ cursor->chunk.data_size = size;
++ drawable = make_drawable (qxl, QXL_DRAW_COPY, rect);
+
-+ memcpy (cursor->chunk.data, pCurs->bits->argb, size);
++ drawable->u.copy.src_bitmap = physical_address (
++ qxl, qxl_image_create (qxl, qxl->fb, rect->left, rect->top,
++ rect->right - rect->left,
++ rect->bottom - rect->top,
++ pScrn->displayWidth * qxl->bytes_per_pixel));
++ drawable->u.copy.src_area = *rect;
++ translate_rect (&drawable->u.copy.src_area);
++ drawable->u.copy.rop_descriptor = ROPD_OP_PUT;
++ drawable->u.copy.scale_mode = 0;
++ drawable->u.copy.mask.flags = 0;
++ drawable->u.copy.mask.pos.x = 0;
++ drawable->u.copy.mask.pos.y = 0;
++ drawable->u.copy.mask.bitmap = 0;
+
-+#if 0
-+ int i, j;
-+ for (j = 0; j < h; ++j)
-+ {
-+ for (i = 0; i < w; ++i)
-+ {
-+ ErrorF ("%c", (pCurs->bits->argb[j * w + i] & 0xff000000) == 0xff000000? '#' : '.');
-+ }
++ push_drawable (qxl, drawable);
++}
+
-+ ErrorF ("\n");
-+ }
-+#endif
++static void
++print_region (const char *header, RegionPtr pRegion)
++{
++ int nbox = REGION_NUM_RECTS (pRegion);
++ BoxPtr pbox = REGION_RECTS (pRegion);
+
-+ qxl->hot_x = pCurs->bits->xhot;
-+ qxl->hot_y = pCurs->bits->yhot;
++ ErrorF ("%s \n", header);
+
-+ cmd->type = QXL_CURSOR_SET;
-+ cmd->u.set.position.x = qxl->cur_x + qxl->hot_x;
-+ cmd->u.set.position.y = qxl->cur_y + qxl->hot_y;
-+ cmd->u.set.shape = physical_address (qxl, cursor);
-+ cmd->u.set.visible = TRUE;
++ while (nbox--)
++ {
++ ErrorF (" %d %d %d %d (size: %d %d)\n",
++ pbox->x1, pbox->y1, pbox->x2, pbox->y2,
++ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
+
-+ push_cursor(qxl, cmd);
-+}
++ pbox++;
++ }
++}
+
-+static Bool
-+qxl_use_hw_cursor (ScreenPtr pScrn, CursorPtr pCurs)
++static void
++accept_damage (qxl_screen_t *qxl)
+{
-+ /* Old-school bitmap cursors are not
-+ * hardware accelerated for now.
-+ */
-+ return FALSE;
++ REGION_UNION (qxl->pScrn->pScreen, &(qxl->to_be_sent), &(qxl->to_be_sent),
++ &(qxl->pending_copy));
++
++ REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
+}
+
-+static Bool
-+qxl_use_hw_cursorARGB (ScreenPtr pScrn, CursorPtr pCurs)
++static void
++qxl_send_copies (qxl_screen_t *qxl)
+{
-+ return TRUE;
++ BoxPtr pBox;
++ int nbox;
++
++ nbox = REGION_NUM_RECTS (&qxl->to_be_sent);
++ pBox = REGION_RECTS (&qxl->to_be_sent);
++
++/* if (REGION_NUM_RECTS (&qxl->to_be_sent) > 0) */
++/* print_region ("send bits", &qxl->to_be_sent); */
++
++ while (nbox--)
++ {
++ struct qxl_rect qrect;
++
++ qrect.top = pBox->y1;
++ qrect.left = pBox->x1;
++ qrect.bottom = pBox->y2;
++ qrect.right = pBox->x2;
++
++ submit_copy (qxl, &qrect);
++
++ pBox++;
++ }
++
++ REGION_EMPTY(qxl->pScrn->pScreen, &qxl->to_be_sent);
+}
+
+static void
-+qxl_hide_cursor(ScrnInfoPtr pScrn)
++paint_shadow (qxl_screen_t *qxl)
+{
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ struct qxl_cursor_cmd *cursor = qxl_alloc_cursor_cmd(qxl);
++ struct qxl_rect qrect;
+
-+ cursor->type = QXL_CURSOR_HIDE;
++ qrect.top = 0;
++ qrect.bottom = 1200;
++ qrect.left = 0;
++ qrect.right = 1600;
+
-+ push_cursor(qxl, cursor);
++ submit_copy (qxl, &qrect);
+}
+
+static void
-+qxl_show_cursor(ScrnInfoPtr pScrn)
++qxl_sanity_check (qxl_screen_t *qxl)
+{
-+ /*
-+ * slightly hacky, but there's no QXL_CURSOR_SHOW. Could maybe do
-+ * QXL_CURSOR_SET?
-+ */
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
++ /* read the mode back from the rom */
++ if (!qxl->rom || !qxl->pScrn)
++ return;
+
-+ qxl_set_cursor_position(pScrn, qxl->cur_x, qxl->cur_y);
++ if (qxl->rom->mode == ~0)
++ {
++ ErrorF("QXL device jumped back to VGA mode - resetting mode\n");
++ qxl_switch_mode(qxl->pScrn->scrnIndex, qxl->pScrn->currentMode, 0);
++ }
+}
+
-+hidden void
-+qxl_cursor_init(ScreenPtr pScreen)
++static void
++qxl_block_handler (pointer data, OSTimePtr pTimeout, pointer pRead)
+{
-+ xf86CursorInfoPtr cursor;
++ qxl_screen_t *qxl = (qxl_screen_t *) data;
+
-+ cursor = xcalloc(1, sizeof(xf86CursorInfoRec));
-+ if (!cursor)
-+ return;
++ if (!qxl->pScrn->vtSema)
++ return;
+
-+ cursor->MaxWidth = cursor->MaxHeight = 64;
-+ /* cursor->Flags; */
-+ cursor->SetCursorPosition = qxl_set_cursor_position;
-+ cursor->LoadCursorARGB = qxl_load_cursor_argb;
-+ cursor->UseHWCursor = qxl_use_hw_cursor;
-+ cursor->UseHWCursorARGB = qxl_use_hw_cursorARGB;
-+ cursor->LoadCursorImage = qxl_load_cursor_image;
-+ cursor->SetCursorColors = qxl_set_cursor_colors;
-+ cursor->HideCursor = qxl_hide_cursor;
-+ cursor->ShowCursor = qxl_show_cursor;
++ qxl_sanity_check(qxl);
+
-+ if (!xf86InitCursor(pScreen, cursor))
-+ xfree(cursor);
++ accept_damage (qxl);
++
++ qxl_send_copies (qxl);
+}
-diff --git a/src/compat/compat-qxl_driver.c b/src/compat/compat-qxl_driver.c
-new file mode 100644
-index 0000000..7cd5f40
---- /dev/null
-+++ b/src/compat/compat-qxl_driver.c
-@@ -0,0 +1,1454 @@
-+/*
-+ * Copyright 2008 Red Hat, Inc.
++
++static void
++qxl_wakeup_handler (pointer data, int i, pointer LastSelectMask)
++{
++}
++
++/* Damage Handling
++ *
++ * When something is drawn, X first generates a damage callback, then
++ * it calls the GC function to actually draw it. In most cases, we want
++ * to simply draw into the shadow framebuffer, then submit a copy to the
++ * device, but when the operation is hardware accelerated, we don't want
++ * to submit the copy. So, damage is first accumulated into 'pending_copy',
++ * then if we accelerated the operation, that damage is deleted.
+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * on the rights to use, copy, modify, merge, publish, distribute, sub
-+ * license, and/or sell copies of the Software, and to permit persons to whom
-+ * the Software is furnished to do so, subject to the following conditions:
++ * If we _didn't_ accelerate, we need to union the pending_copy damage
++ * onto the to_be_sent damage, and then submit a copy command in the block
++ * handler.
+ *
-+ * The above copyright notice and this permission notice (including the next
-+ * paragraph) shall be included in all copies or substantial portions of the
-+ * Software.
++ * This means that when new damage happens, if there is already pending
++ * damage, that must first be unioned onto to_be_sent, and then the new
++ * damage must be stored in pending_copy.
++ *
++ * The qxl_screen_t struct contains two regions, "pending_copy" and
++ * "to_be_sent".
+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ * Pending copy is
++ *
+ */
++static void
++qxl_on_damage (DamagePtr pDamage, RegionPtr pRegion, pointer closure)
++{
++ qxl_screen_t *qxl = closure;
+
-+/** \file qxl_driver.c
-+ * \author Adam Jackson <ajax at redhat.com>
-+ *
-+ * This is qxl, a driver for the Qumranet paravirtualized graphics device
-+ * in qemu.
-+ */
++/* print_region ("damage", pRegion); */
++
++/* print_region ("on_damage ", pRegion); */
+
-+#include <unistd.h>
-+#include <string.h>
-+#include <stdio.h>
-+#include <errno.h>
-+#include <time.h>
-+#include <stdlib.h>
-+#include "compat-qxl.h"
-+#include "assert.h"
++ accept_damage (qxl);
+
-+#define CHECK_POINT()
++/* print_region ("accepting, qxl->to_be_sent is now", &qxl->to_be_sent); */
+
-+static int
-+garbage_collect (qxl_screen_t *qxl)
++ REGION_COPY (qxl->pScrn->pScreen, &(qxl->pending_copy), pRegion);
++}
++
++
++static Bool
++qxl_create_screen_resources(ScreenPtr pScreen)
+{
-+ uint64_t id;
-+ int i = 0;
-+
-+ while (qxl_ring_pop (qxl->release_ring, &id))
-+ {
-+ while (id)
-+ {
-+ /* We assume that there the two low bits of a pointer are
-+ * available. If the low one is set, then the command in
-+ * question is a cursor command
-+ */
-+#define POINTER_MASK ((1 << 2) - 1)
-+
-+ union qxl_release_info *info = u64_to_pointer (id & ~POINTER_MASK);
-+ struct qxl_cursor_cmd *cmd = (struct qxl_cursor_cmd *)info;
-+ struct qxl_drawable *drawable = (struct qxl_drawable *)info;
-+ int is_cursor = FALSE;
++ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++ Bool ret;
++ PixmapPtr pPixmap;
+
-+ if ((id & POINTER_MASK) == 1)
-+ is_cursor = TRUE;
++ pScreen->CreateScreenResources = qxl->create_screen_resources;
++ ret = pScreen->CreateScreenResources (pScreen);
++ pScreen->CreateScreenResources = qxl_create_screen_resources;
+
-+ if (is_cursor && cmd->type == QXL_CURSOR_SET)
-+ {
-+ struct qxl_cursor *cursor = (void *)virtual_address (
-+ qxl, u64_to_pointer (cmd->u.set.shape));
++ if (!ret)
++ return FALSE;
+
-+ qxl_free (qxl->mem, cursor);
-+ }
-+ else if (!is_cursor && drawable->type == QXL_DRAW_COPY)
-+ {
-+ struct qxl_image *image = virtual_address (
-+ qxl, u64_to_pointer (drawable->u.copy.src_bitmap));
++ qxl->damage = DamageCreate (qxl_on_damage, NULL,
++ DamageReportRawRegion,
++ TRUE, pScreen, qxl);
+
-+ qxl_image_destroy (qxl, image);
-+ }
-+
-+ id = info->next;
-+
-+ qxl_free (qxl->mem, info);
-+ }
-+ }
+
-+ return i > 0;
-+}
++ pPixmap = pScreen->GetScreenPixmap(pScreen);
+
-+static void
-+qxl_usleep (int useconds)
-+{
-+ struct timespec t;
++ if (!RegisterBlockAndWakeupHandlers(qxl_block_handler, qxl_wakeup_handler, qxl))
++ return FALSE;
+
-+ t.tv_sec = useconds / 1000000;
-+ t.tv_nsec = (useconds - (t.tv_sec * 1000000)) * 1000;
++ REGION_INIT (pScreen, &(qxl->pending_copy), NullBox, 0);
+
-+ errno = 0;
-+ while (nanosleep (&t, &t) == -1 && errno == EINTR)
-+ ;
-+
++ REGION_INIT (pScreen, &(qxl->to_be_sent), NullBox, 0);
++
++ DamageRegister (&pPixmap->drawable, qxl->damage);
++ return TRUE;
+}
+
-+#if 0
-+static void
-+push_update_area (qxl_screen_t *qxl, const struct qxl_rect *area)
++static PixmapPtr
++get_window_pixmap (DrawablePtr pDrawable, int *xoff, int *yoff)
+{
-+ struct qxl_update_cmd *update = qxl_allocnf (qxl, sizeof *update);
-+ struct qxl_command cmd;
++ ScreenPtr pScreen = pDrawable->pScreen;
++ PixmapPtr result;
+
-+ update->release_info.id = (uint64_t)update;
-+ update->area = *area;
-+ update->update_id = 0;
++ if (pDrawable->type != DRAWABLE_WINDOW)
++ return NULL;
+
-+ cmd.type = QXL_CMD_UDPATE;
-+ cmd.data = physical_address (qxl, update);
++ result = pScreen->GetWindowPixmap ((WindowPtr)pDrawable);
+
-+ qxl_ring_push (qxl->command_ring, &cmd);
++ *xoff = pDrawable->x;
++ *yoff = pDrawable->y;
++
++ return result;
+}
-+#endif
+
-+void *
-+qxl_allocnf (qxl_screen_t *qxl, unsigned long size)
++static void
++qxl_poly_fill_rect (DrawablePtr pDrawable,
++ GCPtr pGC,
++ int nrect,
++ xRectangle *prect)
+{
-+ void *result;
-+ int n_attempts = 0;
-+ static int nth_oom = 1;
++ ScrnInfoPtr pScrn = xf86Screens[pDrawable->pScreen->myNum];
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++ PixmapPtr pPixmap;
++ int xoff, yoff;
+
-+ garbage_collect (qxl);
-+
-+ while (!(result = qxl_alloc (qxl->mem, size)))
++ if ((pPixmap = get_window_pixmap (pDrawable, &xoff, &yoff)) &&
++ pGC->fillStyle == FillSolid &&
++ pGC->alu == GXcopy &&
++ (unsigned int)pGC->planemask == FB_ALLONES)
+ {
-+ struct qxl_ram_header *ram_header = (void *)((unsigned long)qxl->ram +
-+ qxl->rom->ram_header_offset);
-+
-+ /* Rather than go out of memory, we simply tell the
-+ * device to dump everything
-+ */
-+ ram_header->update_area.top = 0;
-+ ram_header->update_area.bottom = 1280;
-+ ram_header->update_area.left = 0;
-+ ram_header->update_area.right = 800;
-+
-+ outb (qxl->io_base + QXL_IO_UPDATE_AREA, 0);
++ RegionPtr pReg = RECTS_TO_REGION (pScreen, nrect, prect, CT_UNSORTED);
++ RegionPtr pClip = fbGetCompositeClip (pGC);
++ BoxPtr pBox;
++ int nbox;
+
-+ ErrorF ("eliminated memory (%d)\n", nth_oom++);
++ REGION_TRANSLATE(pScreen, pReg, xoff, yoff);
++ REGION_INTERSECT(pScreen, pReg, pClip, pReg);
+
-+ outb (qxl->io_base + QXL_IO_NOTIFY_OOM, 0);
++ pBox = REGION_RECTS (pReg);
++ nbox = REGION_NUM_RECTS (pReg);
+
-+ qxl_usleep (10000);
-+
-+ if (garbage_collect (qxl))
-+ {
-+ n_attempts = 0;
-+ }
-+ else if (++n_attempts == 1000)
++ while (nbox--)
+ {
-+ qxl_mem_dump_stats (qxl->mem, "Out of mem - stats\n");
-+
-+ fprintf (stderr, "Out of memory\n");
-+ exit (1);
-+ }
-+ }
++ struct qxl_rect qrect;
+
-+ return result;
-+}
++ qrect.left = pBox->x1;
++ qrect.right = pBox->x2;
++ qrect.top = pBox->y1;
++ qrect.bottom = pBox->y2;
+
-+static Bool
-+qxl_blank_screen(ScreenPtr pScreen, int mode)
-+{
-+ return TRUE;
++ submit_fill (qxl, &qrect, pGC->fgPixel);
++
++ pBox++;
++ }
++
++ REGION_DESTROY (pScreen, pReg);
++ }
++
++ fbPolyFillRect (pDrawable, pGC, nrect, prect);
+}
+
+static void
-+qxl_unmap_memory(qxl_screen_t *qxl, int scrnIndex)
++qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
++ DrawablePtr pDstDrawable,
++ GCPtr pGC,
++ BoxPtr pbox,
++ int nbox,
++ int dx,
++ int dy,
++ Bool reverse,
++ Bool upsidedown,
++ Pixel bitplane,
++ void *closure)
+{
-+#ifdef XSERVER_LIBPCIACCESS
-+ if (qxl->ram)
-+ pci_device_unmap_range(qxl->pci, qxl->ram, qxl->pci->regions[0].size);
-+ if (qxl->vram)
-+ pci_device_unmap_range(qxl->pci, qxl->vram, qxl->pci->regions[1].size);
-+ if (qxl->rom)
-+ pci_device_unmap_range(qxl->pci, qxl->rom, qxl->pci->regions[2].size);
-+#else
-+ if (qxl->ram)
-+ xf86UnMapVidMem(scrnIndex, qxl->ram, (1 << qxl->pci->size[0]));
-+ if (qxl->vram)
-+ xf86UnMapVidMem(scrnIndex, qxl->vram, (1 << qxl->pci->size[1]));
-+ if (qxl->rom)
-+ xf86UnMapVidMem(scrnIndex, qxl->rom, (1 << qxl->pci->size[2]));
-+#endif
++ ScreenPtr pScreen = pSrcDrawable->pScreen;
++ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++ int src_xoff, src_yoff;
++ int dst_xoff, dst_yoff;
++ PixmapPtr pSrcPixmap, pDstPixmap;
+
-+ qxl->ram = qxl->ram_physical = qxl->vram = qxl->rom = NULL;
++ if ((pSrcPixmap = get_window_pixmap (pSrcDrawable, &src_xoff, &src_yoff)) &&
++ (pDstPixmap = get_window_pixmap (pDstDrawable, &dst_xoff, &dst_yoff)))
++ {
++ int n = nbox;
++ BoxPtr b = pbox;
++
++ assert (pSrcPixmap == pDstPixmap);
+
-+ qxl->num_modes = 0;
-+ qxl->modes = NULL;
-+}
++/* ErrorF ("Accelerated copy: %d boxes\n", n); */
+
-+static Bool
-+qxl_map_memory(qxl_screen_t *qxl, int scrnIndex)
-+{
-+#ifdef XSERVER_LIBPCIACCESS
-+ pci_device_map_range(qxl->pci, qxl->pci->regions[0].base_addr,
-+ qxl->pci->regions[0].size,
-+ PCI_DEV_MAP_FLAG_WRITABLE | PCI_DEV_MAP_FLAG_WRITE_COMBINE,
-+ &qxl->ram);
-+ qxl->ram_physical = u64_to_pointer (qxl->pci->regions[0].base_addr);
++ /* At this point we know that any pending damage must
++ * have been caused by whatever copy operation triggered us.
++ *
++ * Therefore we can clear it.
++ *
++ * We couldn't clear it at the toplevel function because
++ * the copy might end up being empty, in which case no
++ * damage would have been generated. Which means the
++ * pending damage would have been caused by some
++ * earlier operation.
++ */
++ if (n)
++ {
++/* ErrorF ("Clearing pending damage\n"); */
++ clear_pending_damage (qxl);
++
++ /* We have to do this because the copy will cause the damage
++ * to be sent to move.
++ *
++ * Instead of just sending the bits, we could also move
++ * the existing damage around; however that's a bit more
++ * complex, and the performance win is unlikely to be
++ * very big.
++ */
++ qxl_send_copies (qxl);
++ }
++
++ while (n--)
++ {
++ struct qxl_drawable *drawable;
++ struct qxl_rect qrect;
++
++ qrect.top = b->y1;
++ qrect.bottom = b->y2;
++ qrect.left = b->x1;
++ qrect.right = b->x2;
+
-+ pci_device_map_range(qxl->pci, qxl->pci->regions[1].base_addr,
-+ qxl->pci->regions[1].size,
-+ PCI_DEV_MAP_FLAG_WRITABLE,
-+ &qxl->vram);
++/* ErrorF (" Translate %d %d %d %d by %d %d (offsets %d %d)\n", */
++/* b->x1, b->y1, b->x2, b->y2, */
++/* dx, dy, dst_xoff, dst_yoff); */
++
++ drawable = make_drawable (qxl, QXL_COPY_BITS, &qrect);
++ drawable->u.copy_bits.src_pos.x = b->x1 + dx;
++ drawable->u.copy_bits.src_pos.y = b->y1 + dy;
+
-+ pci_device_map_range(qxl->pci, qxl->pci->regions[2].base_addr,
-+ qxl->pci->regions[2].size, 0,
-+ (void **)&qxl->rom);
++ push_drawable (qxl, drawable);
+
-+ qxl->io_base = qxl->pci->regions[3].base_addr;
-+#else
-+ qxl->ram = xf86MapPciMem(scrnIndex, VIDMEM_FRAMEBUFFER,
-+ qxl->pci_tag, qxl->pci->memBase[0],
-+ (1 << qxl->pci->size[0]));
-+ qxl->ram_physical = (void *)qxl->pci->memBase[0];
-+
-+ qxl->vram = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
-+ qxl->pci_tag, qxl->pci->memBase[1],
-+ (1 << qxl->pci->size[1]));
-+
-+ qxl->rom = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
-+ qxl->pci_tag, qxl->pci->memBase[2],
-+ (1 << qxl->pci->size[2]));
-+
-+ qxl->io_base = qxl->pci->ioBase[3];
++#if 0
++ if (closure)
++ qxl_usleep (1000000);
++#endif
++
++#if 0
++ submit_fill (qxl, &qrect, rand());
+#endif
-+ if (!qxl->ram || !qxl->vram || !qxl->rom)
-+ return FALSE;
-+
-+ xf86DrvMsg(scrnIndex, X_INFO, "ram at %p; vram at %p; rom at %p\n",
-+ qxl->ram, qxl->vram, qxl->rom);
+
-+ qxl->num_modes = *(uint32_t *)((uint8_t *)qxl->rom + qxl->rom->modes_offset);
-+ qxl->modes = (struct qxl_mode *)(((uint8_t *)qxl->rom) + qxl->rom->modes_offset + 4);
++ b++;
++ }
++ }
++/* else */
++/* ErrorF ("Unaccelerated copy\n"); */
+
-+ return TRUE;
++ fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, pbox, nbox, dx, dy, reverse, upsidedown, bitplane, closure);
+}
+
-+static void
-+qxl_save_state(ScrnInfoPtr pScrn)
++static RegionPtr
++qxl_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
++ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
++ if (pSrcDrawable->type == DRAWABLE_WINDOW &&
++ pDstDrawable->type == DRAWABLE_WINDOW)
++ {
++ RegionPtr res;
+
-+ vgaHWSaveFonts(pScrn, &qxl->vgaRegs);
++/* ErrorF ("accelerated copy %d %d %d %d %d %d\n", */
++/* srcx, srcy, width, height, dstx, dsty); */
++
++ res = fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
++ srcx, srcy, width, height, dstx, dsty,
++ qxl_copy_n_to_n, 0, NULL);
++
++ return res;
++ }
++ else
++ {
++/* ErrorF ("Falling back %d %d %d %d %d %d\n", */
++/* srcx, srcy, width, height, dstx, dsty); */
++
++ return fbCopyArea (pSrcDrawable, pDstDrawable, pGC,
++ srcx, srcy, width, height, dstx, dsty);
++ }
+}
+
+static void
-+qxl_restore_state(ScrnInfoPtr pScrn)
++qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel)
+{
++ ScreenPtr pScreen = pDrawable->pScreen;
++ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ qxl_screen_t *qxl = pScrn->driverPrivate;
++ PixmapPtr pPixmap;
++ int xoff, yoff;
+
-+ vgaHWRestoreFonts(pScrn, &qxl->vgaRegs);
-+}
++ if ((pPixmap = get_window_pixmap (pDrawable, &xoff, &yoff)))
++ {
++ int nbox = REGION_NUM_RECTS (pRegion);
++ BoxPtr pBox = REGION_RECTS (pRegion);
+
-+static Bool
-+qxl_close_screen(int scrnIndex, ScreenPtr pScreen)
-+{
-+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
++ while (nbox--)
++ {
++ struct qxl_rect qrect;
+
-+ if (pScrn->vtSema) {
-+ qxl_restore_state(pScrn);
-+ qxl_unmap_memory(qxl, scrnIndex);
-+ }
-+ pScrn->vtSema = FALSE;
++ qrect.left = pBox->x1;
++ qrect.right = pBox->x2;
++ qrect.top = pBox->y1;
++ qrect.bottom = pBox->y2;
+
-+ xfree(qxl->fb);
++ submit_fill (qxl, &qrect, pixel);
+
-+ pScreen->CreateScreenResources = qxl->create_screen_resources;
-+ pScreen->CloseScreen = qxl->close_screen;
++ pBox++;
++ }
++ }
+
-+ return pScreen->CloseScreen(scrnIndex, pScreen);
++ fbFillRegionSolid (pDrawable, pRegion, 0,
++ fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
+}
+
-+static Bool
-+qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
++static void
++qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
-+ qxl_screen_t *qxl = xf86Screens[scrnIndex]->driverPrivate;
-+ int mode_index = (int)(unsigned long)p->Private;
-+ struct qxl_mode *m = qxl->modes + mode_index;
-+ ScreenPtr pScreen = qxl->pScrn->pScreen;
++ RegionRec rgnDst;
++ int dx, dy;
+
-+ if (!m)
-+ return FALSE;
++ dx = ptOldOrg.x - pWin->drawable.x;
++ dy = ptOldOrg.y - pWin->drawable.y;
+
-+ /* if (debug) */
-+ xf86DrvMsg (scrnIndex, X_INFO, "Setting mode %d (%d x %d) (%d x %d) %p\n",
-+ m->id, m->x_res, m->y_res, p->HDisplay, p->VDisplay, p);
++ REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
+
-+ outb(qxl->io_base + QXL_IO_RESET, 0);
-+
-+ outb(qxl->io_base + QXL_IO_SET_MODE, m->id);
++ REGION_INIT (pScreen, &rgnDst, NullBox, 0);
+
-+ qxl->bytes_per_pixel = (qxl->pScrn->bitsPerPixel + 7) / 8;
++ REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
-+ /* If this happens out of ScreenInit, we won't have a screen yet. In that
-+ * case createScreenResources will make things right.
-+ */
-+ if (pScreen)
-+ {
-+ PixmapPtr pPixmap = pScreen->GetScreenPixmap(pScreen);
++ fbCopyRegion (&pWin->drawable, &pWin->drawable,
++ NULL,
++ &rgnDst, dx, dy, qxl_copy_n_to_n, 0, NULL);
+
-+ if (pPixmap)
-+ {
-+ pScreen->ModifyPixmapHeader(
-+ pPixmap,
-+ m->x_res, m->y_res,
-+ -1, -1,
-+ qxl->pScrn->displayWidth * qxl->bytes_per_pixel,
-+ NULL);
-+ }
-+ }
-+
-+ if (qxl->mem)
-+ {
-+ qxl_mem_free_all (qxl->mem);
-+ qxl_drop_image_cache (qxl);
-+ }
++ REGION_UNINIT (pScreen, &rgnDst);
+
++/* REGION_TRANSLATE (pScreen, prgnSrc, dx, dy); */
+
-+ return TRUE;
++/* fbCopyWindow (pWin, ptOldOrg, prgnSrc); */
+}
+
-+static void
-+push_drawable (qxl_screen_t *qxl, struct qxl_drawable *drawable)
++static int
++qxl_create_gc (GCPtr pGC)
+{
-+ struct qxl_command cmd;
++ static GCOps ops;
++ static int initialized;
++
++ if (!fbCreateGC (pGC))
++ return FALSE;
+
-+ /* When someone runs "init 3", the device will be
-+ * switched into VGA mode and there is nothing we
-+ * can do about it. We get no notification.
-+ *
-+ * However, if commands are submitted when the device
-+ * is in VGA mode, they will be queued up, and then
-+ * the next time a mode set set, an assertion in the
-+ * device will take down the entire virtual machine.
-+ *
-+ * The author of the QXL device is opposed to this
-+ * for reasons I don't understand.
-+ */
-+ if (qxl->rom->mode != ~0)
++ if (!initialized)
+ {
-+ cmd.type = QXL_CMD_DRAW;
-+ cmd.data = physical_address (qxl, drawable);
-+
-+ qxl_ring_push (qxl->command_ring, &cmd);
++ ops = *pGC->ops;
++ ops.PolyFillRect = qxl_poly_fill_rect;
++ ops.CopyArea = qxl_copy_area;
++
++ initialized = TRUE;
+ }
++
++ pGC->ops = &ops;
++ return TRUE;
+}
+
-+static struct qxl_drawable *
-+make_drawable (qxl_screen_t *qxl, uint8_t type,
-+ const struct qxl_rect *rect
-+ /* , pRegion clip */)
++static Bool
++qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
-+ struct qxl_drawable *drawable;
++ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++ struct qxl_rom *rom;
++ struct qxl_ram_header *ram_header;
++ VisualPtr visual;
+
+ CHECK_POINT();
-+
-+ drawable = qxl_allocnf (qxl, sizeof *drawable);
+
-+ CHECK_POINT();
++ qxl->pScrn = pScrn;
++
++ if (!qxl_map_memory(qxl, scrnIndex))
++ return FALSE;
+
-+ drawable->release_info.id = pointer_to_u64 (drawable);
++ rom = qxl->rom;
++ ram_header = (void *)((unsigned long)qxl->ram + (unsigned long)qxl->rom->ram_header_offset);
+
-+ drawable->type = type;
++ qxl_save_state(pScrn);
++ qxl_blank_screen(pScreen, SCREEN_SAVER_ON);
++
++ miClearVisualTypes();
++ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
++ pScrn->rgbBits, pScrn->defaultVisual))
++ goto out;
++ if (!miSetPixmapDepths())
++ goto out;
+
-+ drawable->effect = QXL_EFFECT_OPAQUE;
-+ drawable->bitmap_offset = 0;
-+ drawable->bitmap_area.top = 0;
-+ drawable->bitmap_area.left = 0;
-+ drawable->bitmap_area.bottom = 0;
-+ drawable->bitmap_area.right = 0;
-+ /* FIXME: add clipping */
-+ drawable->clip.type = QXL_CLIP_TYPE_NONE;
++ /* Note we do this before setting pScrn->virtualY to match our current
++ mode, so as to allocate a buffer large enough for the largest mode.
++ FIXME: add support for resizing the framebuffer on modeset. */
++ qxl->fb = xcalloc(pScrn->virtualY * pScrn->displayWidth, 4);
++ if (!qxl->fb)
++ goto out;
+
-+ if (rect)
-+ drawable->bbox = *rect;
++ pScrn->virtualX = pScrn->currentMode->HDisplay;
++ pScrn->virtualY = pScrn->currentMode->VDisplay;
++
++ if (!fbScreenInit(pScreen, qxl->fb,
++ pScrn->currentMode->HDisplay,
++ pScrn->currentMode->VDisplay,
++ pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
++ pScrn->bitsPerPixel))
++ {
++ goto out;
++ }
+
-+ drawable->mm_time = qxl->rom->mm_clock;
++ visual = pScreen->visuals + pScreen->numVisuals;
++ while (--visual >= pScreen->visuals)
++ {
++ if ((visual->class | DynamicClass) == DirectColor)
++ {
++ visual->offsetRed = pScrn->offset.red;
++ visual->offsetGreen = pScrn->offset.green;
++ visual->offsetBlue = pScrn->offset.blue;
++ visual->redMask = pScrn->mask.red;
++ visual->greenMask = pScrn->mask.green;
++ visual->blueMask = pScrn->mask.blue;
++ }
++ }
+
-+ CHECK_POINT();
+
-+ return drawable;
-+}
++ fbPictureInit(pScreen, 0, 0);
+
-+enum ROPDescriptor {
-+ ROPD_INVERS_SRC = (1 << 0),
-+ ROPD_INVERS_BRUSH = (1 << 1),
-+ ROPD_INVERS_DEST = (1 << 2),
-+ ROPD_OP_PUT = (1 << 3),
-+ ROPD_OP_OR = (1 << 4),
-+ ROPD_OP_AND = (1 << 5),
-+ ROPD_OP_XOR = (1 << 6),
-+ ROPD_OP_BLACKNESS = (1 << 7),
-+ ROPD_OP_WHITENESS = (1 << 8),
-+ ROPD_OP_INVERS = (1 << 9),
-+ ROPD_INVERS_RES = (1 <<10),
-+};
++ qxl->create_screen_resources = pScreen->CreateScreenResources;
++ pScreen->CreateScreenResources = qxl_create_screen_resources;
+
-+static void
-+undamage_box (qxl_screen_t *qxl, const struct qxl_rect *rect)
-+{
-+ RegionRec region;
-+ BoxRec box;
++ /* Set up resources */
++ qxl->mem = qxl_mem_create ((void *)((unsigned long)qxl->ram + (unsigned long)rom->pages_offset),
++ rom->num_io_pages * getpagesize());
++ qxl->io_pages = (void *)((unsigned long)qxl->ram + (unsigned long)rom->pages_offset);
++ qxl->io_pages_physical = (void *)((unsigned long)qxl->ram_physical + (unsigned long)rom->pages_offset);
+
-+ box.x1 = rect->left;
-+ box.y1 = rect->top;
-+ box.x2 = rect->right;
-+ box.y2 = rect->bottom;
++ qxl->command_ring = qxl_ring_create (&(ram_header->cmd_ring_hdr),
++ sizeof (struct qxl_command),
++ 32, qxl->io_base + QXL_IO_NOTIFY_CMD);
++ qxl->cursor_ring = qxl_ring_create (&(ram_header->cursor_ring_hdr),
++ sizeof (struct qxl_command),
++ 32, qxl->io_base + QXL_IO_NOTIFY_CURSOR);
++ qxl->release_ring = qxl_ring_create (&(ram_header->release_ring_hdr),
++ sizeof (uint64_t),
++ 8, 0);
++
++ /* xf86DPMSInit(pScreen, xf86DPMSSet, 0); */
+
-+ REGION_INIT (qxl->pScrn->pScreen, ®ion, &box, 0);
++#if 0 /* XV accel */
++ qxlInitVideo(pScreen);
++#endif
+
-+ REGION_SUBTRACT (qxl->pScrn->pScreen, &(qxl->pending_copy), &(qxl->pending_copy), ®ion);
++ pScreen->SaveScreen = qxl_blank_screen;
++ qxl->close_screen = pScreen->CloseScreen;
++ pScreen->CloseScreen = qxl_close_screen;
+
-+ REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
-+}
++ qxl->create_gc = pScreen->CreateGC;
++ pScreen->CreateGC = qxl_create_gc;
+
-+static void
-+clear_pending_damage (qxl_screen_t *qxl)
-+{
-+ REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
-+}
++#if 0
++ qxl->paint_window_background = pScreen->PaintWindowBackground;
++ qxl->paint_window_border = pScreen->PaintWindowBorder;
++#endif
++ qxl->copy_window = pScreen->CopyWindow;
++#if 0
++ pScreen->PaintWindowBackground = qxl_paint_window;
++ pScreen->PaintWindowBorder = qxl_paint_window;
++#endif
++ pScreen->CopyWindow = qxl_copy_window;
+
-+static void
-+submit_fill (qxl_screen_t *qxl, const struct qxl_rect *rect, uint32_t color)
-+{
-+ struct qxl_drawable *drawable;
++ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
-+ CHECK_POINT();
++ if (!miCreateDefColormap(pScreen))
++ goto out;
++
++ qxl_cursor_init (pScreen);
+
-+ drawable = make_drawable (qxl, QXL_DRAW_FILL, rect);
++ CHECK_POINT();
++
++ qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
+
+ CHECK_POINT();
++
++ return TRUE;
+
-+ drawable->u.fill.brush.type = QXL_BRUSH_TYPE_SOLID;
-+ drawable->u.fill.brush.u.color = color;
-+ drawable->u.fill.rop_descriptor = ROPD_OP_PUT;
-+ drawable->u.fill.mask.flags = 0;
-+ drawable->u.fill.mask.pos.x = 0;
-+ drawable->u.fill.mask.pos.y = 0;
-+ drawable->u.fill.mask.bitmap = 0;
++out:
++ return FALSE;
++}
+
-+ push_drawable (qxl, drawable);
++static Bool
++qxl_enter_vt(int scrnIndex, int flags)
++{
++ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
-+ undamage_box (qxl, rect);
++ qxl_save_state(pScrn);
++ qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
++
++ return TRUE;
+}
+
+static void
-+translate_rect (struct qxl_rect *rect)
++qxl_leave_vt(int scrnIndex, int flags)
+{
-+ rect->right -= rect->left;
-+ rect->bottom -= rect->top;
-+ rect->left = rect->top = 0;
++ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
++
++ qxl_restore_state(pScrn);
+}
+
-+static void
-+submit_copy (qxl_screen_t *qxl, const struct qxl_rect *rect)
++static Bool
++qxl_color_setup(ScrnInfoPtr pScrn)
+{
-+ struct qxl_drawable *drawable;
-+ ScrnInfoPtr pScrn = qxl->pScrn;
++ int scrnIndex = pScrn->scrnIndex;
++ Gamma gzeros = { 0.0, 0.0, 0.0 };
++ rgb rzeros = { 0, 0, 0 };
+
-+ if (rect->left == rect->right ||
-+ rect->top == rect->bottom)
++ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb))
++ return FALSE;
++
++ if (pScrn->depth != 15 && pScrn->depth != 24)
+ {
-+ /* Empty rectangle */
-+ return ;
++ xf86DrvMsg(scrnIndex, X_ERROR, "Depth %d is not supported\n",
++ pScrn->depth);
++ return FALSE;
+ }
-+
-+ drawable = make_drawable (qxl, QXL_DRAW_COPY, rect);
++ xf86PrintDepthBpp(pScrn);
+
-+ drawable->u.copy.src_bitmap = physical_address (
-+ qxl, qxl_image_create (qxl, qxl->fb, rect->left, rect->top,
-+ rect->right - rect->left,
-+ rect->bottom - rect->top,
-+ pScrn->displayWidth * qxl->bytes_per_pixel));
-+ drawable->u.copy.src_area = *rect;
-+ translate_rect (&drawable->u.copy.src_area);
-+ drawable->u.copy.rop_descriptor = ROPD_OP_PUT;
-+ drawable->u.copy.scale_mode = 0;
-+ drawable->u.copy.mask.flags = 0;
-+ drawable->u.copy.mask.pos.x = 0;
-+ drawable->u.copy.mask.pos.y = 0;
-+ drawable->u.copy.mask.bitmap = 0;
++ if (!xf86SetWeight(pScrn, rzeros, rzeros))
++ return FALSE;
+
-+ push_drawable (qxl, drawable);
++ if (!xf86SetDefaultVisual(pScrn, -1))
++ return FALSE;
++
++ if (!xf86SetGamma(pScrn, gzeros))
++ return FALSE;
++
++ return TRUE;
+}
+
+static void
-+print_region (const char *header, RegionPtr pRegion)
++print_modes (qxl_screen_t *qxl, int scrnIndex)
+{
-+ int nbox = REGION_NUM_RECTS (pRegion);
-+ BoxPtr pbox = REGION_RECTS (pRegion);
++ int i;
+
-+ ErrorF ("%s \n", header);
-+
-+ while (nbox--)
++ for (i = 0; i < qxl->num_modes; ++i)
+ {
-+ ErrorF (" %d %d %d %d (size: %d %d)\n",
-+ pbox->x1, pbox->y1, pbox->x2, pbox->y2,
-+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
++ struct qxl_mode *m = qxl->modes + i;
+
-+ pbox++;
++ xf86DrvMsg (scrnIndex, X_INFO,
++ "%d: %dx%d, %d bits, stride %d, %dmm x %dmm, orientation %d\n",
++ m->id, m->x_res, m->y_res, m->bits, m->stride, m->x_mili,
++ m->y_mili, m->orientation);
+ }
+}
+
-+static void
-+accept_damage (qxl_screen_t *qxl)
++static Bool
++qxl_check_device(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
+{
-+ REGION_UNION (qxl->pScrn->pScreen, &(qxl->to_be_sent), &(qxl->to_be_sent),
-+ &(qxl->pending_copy));
++ int scrnIndex = pScrn->scrnIndex;
++ struct qxl_rom *rom = qxl->rom;
++ struct qxl_ram_header *ram_header = (void *)((unsigned long)qxl->ram + rom->ram_header_offset);
+
-+ REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
-+}
++ CHECK_POINT();
++
++ if (rom->magic != 0x4f525851) { /* "QXRO" little-endian */
++ xf86DrvMsg(scrnIndex, X_ERROR, "Bad ROM signature %x\n", rom->magic);
++ return FALSE;
++ }
+
-+static void
-+qxl_send_copies (qxl_screen_t *qxl)
-+{
-+ BoxPtr pBox;
-+ int nbox;
++ xf86DrvMsg(scrnIndex, X_INFO, "Device version %d.%d\n",
++ rom->id, rom->update_id);
+
-+ nbox = REGION_NUM_RECTS (&qxl->to_be_sent);
-+ pBox = REGION_RECTS (&qxl->to_be_sent);
++ xf86DrvMsg(scrnIndex, X_INFO, "Compression level %d, log level %d\n",
++ rom->compression_level,
++ rom->log_level);
+
-+/* if (REGION_NUM_RECTS (&qxl->to_be_sent) > 0) */
-+/* print_region ("send bits", &qxl->to_be_sent); */
-+
-+ while (nbox--)
-+ {
-+ struct qxl_rect qrect;
++ xf86DrvMsg(scrnIndex, X_INFO, "Currently using mode #%d, list at 0x%x\n",
++ rom->mode, rom->modes_offset);
+
-+ qrect.top = pBox->y1;
-+ qrect.left = pBox->x1;
-+ qrect.bottom = pBox->y2;
-+ qrect.right = pBox->x2;
-+
-+ submit_copy (qxl, &qrect);
++ xf86DrvMsg(scrnIndex, X_INFO, "%d io pages at 0x%x\n",
++ rom->num_io_pages, rom->pages_offset);
+
-+ pBox++;
-+ }
++ xf86DrvMsg(scrnIndex, X_INFO, "%d byte draw area at 0x%x\n",
++ rom->draw_area_size, rom->draw_area_offset);
+
-+ REGION_EMPTY(qxl->pScrn->pScreen, &qxl->to_be_sent);
-+}
++ xf86DrvMsg(scrnIndex, X_INFO, "RAM header offset: 0x%x\n", rom->ram_header_offset);
+
-+static void
-+paint_shadow (qxl_screen_t *qxl)
-+{
-+ struct qxl_rect qrect;
++ if (ram_header->magic != 0x41525851) { /* "QXRA" little-endian */
++ xf86DrvMsg(scrnIndex, X_ERROR, "Bad RAM signature %x at %p\n",
++ ram_header->magic,
++ &ram_header->magic);
++ return FALSE;
++ }
+
-+ qrect.top = 0;
-+ qrect.bottom = 1200;
-+ qrect.left = 0;
-+ qrect.right = 1600;
++ xf86DrvMsg(scrnIndex, X_INFO, "Correct RAM signature %x\n",
++ ram_header->magic);
+
-+ submit_copy (qxl, &qrect);
++ qxl->draw_area_offset = rom->draw_area_offset;
++ qxl->draw_area_size = rom->draw_area_size;
++ pScrn->videoRam = rom->draw_area_size / 1024;
++
++ return TRUE;
+}
+
-+static void
-+qxl_sanity_check (qxl_screen_t *qxl)
++static int
++qxl_find_native_mode(ScrnInfoPtr pScrn, DisplayModePtr p)
+{
-+ /* read the mode back from the rom */
-+ if (!qxl->rom || !qxl->pScrn)
-+ return;
++ int i;
++ qxl_screen_t *qxl = pScrn->driverPrivate;
+
-+ if (qxl->rom->mode == ~0)
++ CHECK_POINT();
++
++ for (i = 0; i < qxl->num_modes; i++)
+ {
-+ ErrorF("QXL device jumped back to VGA mode - resetting mode\n");
-+ qxl_switch_mode(qxl->pScrn->scrnIndex, qxl->pScrn->currentMode, 0);
++ struct qxl_mode *m = qxl->modes + i;
++
++ if (m->x_res == p->HDisplay &&
++ m->y_res == p->VDisplay &&
++ m->bits == pScrn->bitsPerPixel)
++ {
++ if (m->bits == 16)
++ {
++ /* What QXL calls 16 bit is actually x1r5g5b515 */
++ if (pScrn->depth == 15)
++ return i;
++ }
++ else if (m->bits == 32)
++ {
++ /* What QXL calls 32 bit is actually x8r8g8b8 */
++ if (pScrn->depth == 24)
++ return i;
++ }
++ }
+ }
++
++ return -1;
+}
+
-+static void
-+qxl_block_handler (pointer data, OSTimePtr pTimeout, pointer pRead)
++static ModeStatus
++qxl_valid_mode(int scrn, DisplayModePtr p, Bool flag, int pass)
+{
-+ qxl_screen_t *qxl = (qxl_screen_t *) data;
-+
-+ if (!qxl->pScrn->vtSema)
-+ return;
-+
-+ qxl_sanity_check(qxl);
++ ScrnInfoPtr pScrn = xf86Screens[scrn];
++ qxl_screen_t *qxl = pScrn->driverPrivate;
++ int bpp = pScrn->bitsPerPixel;
++ int mode_idx;
+
-+ accept_damage (qxl);
++ /* FIXME: I don't think this is necessary now that we report the
++ * correct amount of video ram?
++ */
++ if (p->HDisplay * p->VDisplay * (bpp/8) > qxl->draw_area_size)
++ return MODE_MEM;
+
-+ qxl_send_copies (qxl);
-+}
++ mode_idx = qxl_find_native_mode (pScrn, p);
++ if (mode_idx == -1)
++ return MODE_NOMODE;
+
-+static void
-+qxl_wakeup_handler (pointer data, int i, pointer LastSelectMask)
-+{
++ p->Private = (void *)(unsigned long)mode_idx;
++
++ return MODE_OK;
+}
+
-+/* Damage Handling
-+ *
-+ * When something is drawn, X first generates a damage callback, then
-+ * it calls the GC function to actually draw it. In most cases, we want
-+ * to simply draw into the shadow framebuffer, then submit a copy to the
-+ * device, but when the operation is hardware accelerated, we don't want
-+ * to submit the copy. So, damage is first accumulated into 'pending_copy',
-+ * then if we accelerated the operation, that damage is deleted.
-+ *
-+ * If we _didn't_ accelerate, we need to union the pending_copy damage
-+ * onto the to_be_sent damage, and then submit a copy command in the block
-+ * handler.
-+ *
-+ * This means that when new damage happens, if there is already pending
-+ * damage, that must first be unioned onto to_be_sent, and then the new
-+ * damage must be stored in pending_copy.
-+ *
-+ * The qxl_screen_t struct contains two regions, "pending_copy" and
-+ * "to_be_sent".
-+ *
-+ * Pending copy is
-+ *
-+ */
-+static void
-+qxl_on_damage (DamagePtr pDamage, RegionPtr pRegion, pointer closure)
++static void qxl_add_mode(ScrnInfoPtr pScrn, int width, int height, int type)
+{
-+ qxl_screen_t *qxl = closure;
++ DisplayModePtr mode;
+
-+/* print_region ("damage", pRegion); */
-+
-+/* print_region ("on_damage ", pRegion); */
++ /* Skip already present modes */
++ for (mode = pScrn->monitor->Modes; mode; mode = mode->next)
++ if (mode->HDisplay == width && mode->VDisplay == height)
++ return;
+
-+ accept_damage (qxl);
++ mode = xnfcalloc(1, sizeof(DisplayModeRec));
+
-+/* print_region ("accepting, qxl->to_be_sent is now", &qxl->to_be_sent); */
++ mode->status = MODE_OK;
++ mode->type = type;
++ mode->HDisplay = width;
++ mode->HSyncStart = (width * 105 / 100 + 7) & ~7;
++ mode->HSyncEnd = (width * 115 / 100 + 7) & ~7;
++ mode->HTotal = (width * 130 / 100 + 7) & ~7;
++ mode->VDisplay = height;
++ mode->VSyncStart = height + 1;
++ mode->VSyncEnd = height + 4;
++ mode->VTotal = height * 1035 / 1000;
++ mode->Clock = mode->HTotal * mode->VTotal * 60 / 1000;
++ mode->Flags = V_NHSYNC | V_PVSYNC;
+
-+ REGION_COPY (qxl->pScrn->pScreen, &(qxl->pending_copy), pRegion);
++ xf86SetModeDefaultName(mode);
++ xf86ModesAdd(pScrn->monitor->Modes, mode);
+}
+
-+
+static Bool
-+qxl_create_screen_resources(ScreenPtr pScreen)
++qxl_pre_init(ScrnInfoPtr pScrn, int flags)
+{
-+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ Bool ret;
-+ PixmapPtr pPixmap;
++ int i, scrnIndex = pScrn->scrnIndex;
++ qxl_screen_t *qxl = NULL;
++ ClockRangePtr clockRanges = NULL;
++ int *linePitches = NULL;
++ DisplayModePtr mode;
++ unsigned int max_x = 0, max_y = 0;
+
-+ pScreen->CreateScreenResources = qxl->create_screen_resources;
-+ ret = pScreen->CreateScreenResources (pScreen);
-+ pScreen->CreateScreenResources = qxl_create_screen_resources;
-+
-+ if (!ret)
++ CHECK_POINT();
++
++ /* zaphod mode is for suckers and i choose not to implement it */
++ if (xf86IsEntityShared(pScrn->entityList[0])) {
++ xf86DrvMsg(scrnIndex, X_ERROR, "No Zaphod mode for you\n");
+ return FALSE;
++ }
+
-+ qxl->damage = DamageCreate (qxl_on_damage, NULL,
-+ DamageReportRawRegion,
-+ TRUE, pScreen, qxl);
++ if (!pScrn->driverPrivate)
++ pScrn->driverPrivate = xnfcalloc(sizeof(qxl_screen_t), 1);
++ qxl = pScrn->driverPrivate;
++
++ qxl->entity = xf86GetEntityInfo(pScrn->entityList[0]);
++ qxl->pci = xf86GetPciInfoForEntity(qxl->entity->index);
++#ifndef XSERVER_LIBPCIACCESS
++ qxl->pci_tag = pciTag(qxl->pci->bus, qxl->pci->device, qxl->pci->func);
++#endif
+
++ pScrn->monitor = pScrn->confScreen->monitor;
+
-+ pPixmap = pScreen->GetScreenPixmap(pScreen);
++ if (!qxl_color_setup(pScrn))
++ goto out;
+
-+ if (!RegisterBlockAndWakeupHandlers(qxl_block_handler, qxl_wakeup_handler, qxl))
-+ return FALSE;
++ /* option parsing and card differentiation */
++ xf86CollectOptions(pScrn, NULL);
++
++ if (!qxl_map_memory(qxl, scrnIndex))
++ goto out;
+
-+ REGION_INIT (pScreen, &(qxl->pending_copy), NullBox, 0);
++ if (!qxl_check_device(pScrn, qxl))
++ goto out;
+
-+ REGION_INIT (pScreen, &(qxl->to_be_sent), NullBox, 0);
-+
-+ DamageRegister (&pPixmap->drawable, qxl->damage);
-+ return TRUE;
-+}
++ /* ddc stuff here */
+
-+static PixmapPtr
-+get_window_pixmap (DrawablePtr pDrawable, int *xoff, int *yoff)
-+{
-+ ScreenPtr pScreen = pDrawable->pScreen;
-+ PixmapPtr result;
++ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
++ clockRanges->next = NULL;
++ clockRanges->minClock = 10000;
++ clockRanges->maxClock = 400000;
++ clockRanges->clockIndex = -1;
++ clockRanges->interlaceAllowed = clockRanges->doubleScanAllowed = 0;
++ clockRanges->ClockMulFactor = clockRanges->ClockDivFactor = 1;
++ pScrn->progClock = TRUE;
+
-+ if (pDrawable->type != DRAWABLE_WINDOW)
-+ return NULL;
++ /* override QXL monitor stuff */
++ if (pScrn->monitor->nHsync <= 0) {
++ pScrn->monitor->hsync[0].lo = 29.0;
++ pScrn->monitor->hsync[0].hi = 160.0;
++ pScrn->monitor->nHsync = 1;
++ }
++ if (pScrn->monitor->nVrefresh <= 0) {
++ pScrn->monitor->vrefresh[0].lo = 50;
++ pScrn->monitor->vrefresh[0].hi = 75;
++ pScrn->monitor->nVrefresh = 1;
++ }
+
-+ result = pScreen->GetWindowPixmap ((WindowPtr)pDrawable);
++ /* Add any modes not in xorg's default mode list */
++ for (i = 0; i < qxl->num_modes; i++)
++ if (qxl->modes[i].orientation == 0) {
++ qxl_add_mode(pScrn, qxl->modes[i].x_res, qxl->modes[i].y_res,
++ M_T_DRIVER);
++ if (qxl->modes[i].x_res > max_x)
++ max_x = qxl->modes[i].x_res;
++ if (qxl->modes[i].y_res > max_y)
++ max_y = qxl->modes[i].y_res;
++ }
+
-+ *xoff = pDrawable->x;
-+ *yoff = pDrawable->y;
++ if (pScrn->display->virtualX == 0 && pScrn->display->virtualY == 0) {
++ /* It is possible for the largest x + largest y size combined leading
++ to a virtual size which will not fit into the framebuffer when this
++ happens we prefer max width and make height as large as possible */
++ if (max_x * max_y * (pScrn->bitsPerPixel / 8) > qxl->draw_area_size)
++ pScrn->display->virtualY = qxl->draw_area_size /
++ (max_x * (pScrn->bitsPerPixel / 8));
++ else
++ pScrn->display->virtualY = max_y;
+
-+ return result;
-+}
++ pScrn->display->virtualX = max_x;
++ }
+
-+static void
-+qxl_poly_fill_rect (DrawablePtr pDrawable,
-+ GCPtr pGC,
-+ int nrect,
-+ xRectangle *prect)
-+{
-+ ScrnInfoPtr pScrn = xf86Screens[pDrawable->pScreen->myNum];
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ PixmapPtr pPixmap;
-+ int xoff, yoff;
++ if (0 >= xf86ValidateModes(pScrn, pScrn->monitor->Modes,
++ pScrn->display->modes, clockRanges, linePitches,
++ 128, max_x, 128 * 4, 128, max_y,
++ pScrn->display->virtualX,
++ pScrn->display->virtualY,
++ 128 * 1024 * 1024, LOOKUP_BEST_REFRESH))
++ goto out;
+
-+ if ((pPixmap = get_window_pixmap (pDrawable, &xoff, &yoff)) &&
-+ pGC->fillStyle == FillSolid &&
-+ pGC->alu == GXcopy &&
-+ (unsigned int)pGC->planemask == FB_ALLONES)
-+ {
-+ RegionPtr pReg = RECTS_TO_REGION (pScreen, nrect, prect, CT_UNSORTED);
-+ RegionPtr pClip = fbGetCompositeClip (pGC);
-+ BoxPtr pBox;
-+ int nbox;
-+
-+ REGION_TRANSLATE(pScreen, pReg, xoff, yoff);
-+ REGION_INTERSECT(pScreen, pReg, pClip, pReg);
++ CHECK_POINT();
++
++ xf86PruneDriverModes(pScrn);
++ pScrn->currentMode = pScrn->modes;
++ /* If no modes are specified in xorg.conf, default to 1024x768 */
++ if (pScrn->display->modes == NULL || pScrn->display->modes[0] == NULL)
++ for (mode = pScrn->modes; mode; mode = mode->next)
++ if (mode->HDisplay == 1024 && mode->VDisplay == 768) {
++ pScrn->currentMode = mode;
++ break;
++ }
+
-+ pBox = REGION_RECTS (pReg);
-+ nbox = REGION_NUM_RECTS (pReg);
++ xf86PrintModes(pScrn);
++ xf86SetDpi(pScrn, 0, 0);
+
-+ while (nbox--)
-+ {
-+ struct qxl_rect qrect;
++ if (!xf86LoadSubModule(pScrn, "fb") ||
++ !xf86LoadSubModule(pScrn, "ramdac") ||
++ !xf86LoadSubModule(pScrn, "vgahw"))
++ {
++ goto out;
++ }
+
-+ qrect.left = pBox->x1;
-+ qrect.right = pBox->x2;
-+ qrect.top = pBox->y1;
-+ qrect.bottom = pBox->y2;
++ print_modes (qxl, scrnIndex);
+
-+ submit_fill (qxl, &qrect, pGC->fgPixel);
++ /* VGA hardware initialisation */
++ if (!vgaHWGetHWRec(pScrn))
++ return FALSE;
+
-+ pBox++;
-+ }
++ /* hate */
++ qxl_unmap_memory(qxl, scrnIndex);
+
-+ REGION_DESTROY (pScreen, pReg);
-+ }
++ CHECK_POINT();
+
-+ fbPolyFillRect (pDrawable, pGC, nrect, prect);
++ xf86DrvMsg(scrnIndex, X_INFO, "PreInit complete\n");
++ return TRUE;
++
++out:
++ if (clockRanges)
++ xfree(clockRanges);
++ if (qxl)
++ xfree(qxl);
++
++ return FALSE;
+}
+
-+static void
-+qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
-+ DrawablePtr pDstDrawable,
-+ GCPtr pGC,
-+ BoxPtr pbox,
-+ int nbox,
-+ int dx,
-+ int dy,
-+ Bool reverse,
-+ Bool upsidedown,
-+ Pixel bitplane,
-+ void *closure)
++#ifdef XSERVER_LIBPCIACCESS
++enum qxl_class
+{
-+ ScreenPtr pScreen = pSrcDrawable->pScreen;
-+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ int src_xoff, src_yoff;
-+ int dst_xoff, dst_yoff;
-+ PixmapPtr pSrcPixmap, pDstPixmap;
++ CHIP_QXL_1,
++};
+
-+ if ((pSrcPixmap = get_window_pixmap (pSrcDrawable, &src_xoff, &src_yoff)) &&
-+ (pDstPixmap = get_window_pixmap (pDstDrawable, &dst_xoff, &dst_yoff)))
++static const struct pci_id_match qxl_device_match[] = {
+ {
-+ int n = nbox;
-+ BoxPtr b = pbox;
-+
-+ assert (pSrcPixmap == pDstPixmap);
++ PCI_VENDOR_RED_HAT, PCI_CHIP_QXL_0100, PCI_MATCH_ANY, PCI_MATCH_ANY,
++ 0x00030000, 0x00ffffff, CHIP_QXL_1
++ },
+
-+/* ErrorF ("Accelerated copy: %d boxes\n", n); */
++ { 0 },
++};
++#endif
+
-+ /* At this point we know that any pending damage must
-+ * have been caused by whatever copy operation triggered us.
-+ *
-+ * Therefore we can clear it.
-+ *
-+ * We couldn't clear it at the toplevel function because
-+ * the copy might end up being empty, in which case no
-+ * damage would have been generated. Which means the
-+ * pending damage would have been caused by some
-+ * earlier operation.
-+ */
-+ if (n)
-+ {
-+/* ErrorF ("Clearing pending damage\n"); */
-+ clear_pending_damage (qxl);
-+
-+ /* We have to do this because the copy will cause the damage
-+ * to be sent to move.
-+ *
-+ * Instead of just sending the bits, we could also move
-+ * the existing damage around; however that's a bit more
-+ * complex, and the performance win is unlikely to be
-+ * very big.
-+ */
-+ qxl_send_copies (qxl);
-+ }
-+
-+ while (n--)
-+ {
-+ struct qxl_drawable *drawable;
-+ struct qxl_rect qrect;
-+
-+ qrect.top = b->y1;
-+ qrect.bottom = b->y2;
-+ qrect.left = b->x1;
-+ qrect.right = b->x2;
++static SymTabRec qxlChips[] =
++{
++ { PCI_CHIP_QXL_0100, "QXL 1", },
++ { -1, NULL }
++};
+
-+/* ErrorF (" Translate %d %d %d %d by %d %d (offsets %d %d)\n", */
-+/* b->x1, b->y1, b->x2, b->y2, */
-+/* dx, dy, dst_xoff, dst_yoff); */
-+
-+ drawable = make_drawable (qxl, QXL_COPY_BITS, &qrect);
-+ drawable->u.copy_bits.src_pos.x = b->x1 + dx;
-+ drawable->u.copy_bits.src_pos.y = b->y1 + dy;
++#ifndef XSERVER_LIBPCIACCESS
++static PciChipsets qxlPciChips[] =
++{
++ { PCI_CHIP_QXL_0100, PCI_CHIP_QXL_0100, RES_SHARED_VGA },
++ { -1, -1, RES_UNDEFINED }
++};
++#endif
+
-+ push_drawable (qxl, drawable);
++static void
++qxl_identify(int flags)
++{
++ xf86PrintChipsets("qxl", "Driver for QXL virtual graphics", qxlChips);
++}
+
-+#if 0
-+ if (closure)
-+ qxl_usleep (1000000);
++static void
++qxl_init_scrn(ScrnInfoPtr pScrn)
++{
++ pScrn->driverVersion = 0;
++ pScrn->driverName = pScrn->name = "qxl";
++ pScrn->PreInit = qxl_pre_init;
++ pScrn->ScreenInit = qxl_screen_init;
++ pScrn->SwitchMode = qxl_switch_mode;
++ pScrn->ValidMode = qxl_valid_mode;
++ pScrn->EnterVT = qxl_enter_vt;
++ pScrn->LeaveVT = qxl_leave_vt;
++}
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl.h.compat xf86-video-qxl-20130514/src/compat/compat-qxl.h
+--- xf86-video-qxl-20130514/src/compat/compat-qxl.h.compat 2013-07-03 14:18:57.094319233 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl.h 2013-07-03 14:18:57.094319233 +1000
+@@ -0,0 +1,610 @@
++/*
++ * Copyright 2008 Red Hat, Inc.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * on the rights to use, copy, modify, merge, publish, distribute, sub
++ * license, and/or sell copies of the Software, and to permit persons to whom
++ * the Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice (including the next
++ * paragraph) shall be included in all copies or substantial portions of the
++ * Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
++ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include "config.h"
++
++#include <stdint.h>
++
++#include "compiler.h"
++#include "xf86.h"
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
++#include "xf86Resources.h"
+#endif
-+
-+#if 0
-+ submit_fill (qxl, &qrect, rand());
++#include "xf86PciInfo.h"
++#include "xf86Cursor.h"
++#include "xf86_OSproc.h"
++#include "xf86xv.h"
++#include "shadow.h"
++#include "micmap.h"
++#ifdef XSERVER_PCIACCESS
++#include "pciaccess.h"
+#endif
++#include "fb.h"
++#include "vgaHW.h"
+
-+ b++;
-+ }
-+ }
-+/* else */
-+/* ErrorF ("Unaccelerated copy\n"); */
-+
-+ fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, pbox, nbox, dx, dy, reverse, upsidedown, bitplane, closure);
-+}
++#define hidden _X_HIDDEN
+
-+static RegionPtr
-+qxl_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
-+ int srcx, int srcy, int width, int height, int dstx, int dsty)
-+{
-+ if (pSrcDrawable->type == DRAWABLE_WINDOW &&
-+ pDstDrawable->type == DRAWABLE_WINDOW)
-+ {
-+ RegionPtr res;
++#define QXL_NAME "qxl"
++#define QXL_DRIVER_NAME "qxl"
++#define PCI_VENDOR_RED_HAT 0x1b36
+
-+/* ErrorF ("accelerated copy %d %d %d %d %d %d\n", */
-+/* srcx, srcy, width, height, dstx, dsty); */
++#define PCI_CHIP_QXL_0100 0x0100
+
-+ res = fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
-+ srcx, srcy, width, height, dstx, dsty,
-+ qxl_copy_n_to_n, 0, NULL);
++#pragma pack(push,1)
+
-+ return res;
-+ }
-+ else
-+ {
-+/* ErrorF ("Falling back %d %d %d %d %d %d\n", */
-+/* srcx, srcy, width, height, dstx, dsty); */
++/* I/O port definitions */
++enum {
++ QXL_IO_NOTIFY_CMD,
++ QXL_IO_NOTIFY_CURSOR,
++ QXL_IO_UPDATE_AREA,
++ QXL_IO_UPDATE_IRQ,
++ QXL_IO_NOTIFY_OOM,
++ QXL_IO_RESET,
++ QXL_IO_SET_MODE,
++ QXL_IO_LOG,
++};
+
-+ return fbCopyArea (pSrcDrawable, pDstDrawable, pGC,
-+ srcx, srcy, width, height, dstx, dsty);
-+ }
-+}
++struct qxl_mode {
++ uint32_t id;
++ uint32_t x_res;
++ uint32_t y_res;
++ uint32_t bits;
++ uint32_t stride;
++ uint32_t x_mili;
++ uint32_t y_mili;
++ uint32_t orientation;
++};
+
-+static void
-+qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel)
++typedef enum
+{
-+ ScreenPtr pScreen = pDrawable->pScreen;
-+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ PixmapPtr pPixmap;
-+ int xoff, yoff;
++ QXL_CMD_NOP,
++ QXL_CMD_DRAW,
++ QXL_CMD_UPDATE,
++ QXL_CMD_CURSOR,
++ QXL_CMD_MESSAGE
++} qxl_command_type;
+
-+ if ((pPixmap = get_window_pixmap (pDrawable, &xoff, &yoff)))
-+ {
-+ int nbox = REGION_NUM_RECTS (pRegion);
-+ BoxPtr pBox = REGION_RECTS (pRegion);
++struct qxl_command {
++ uint64_t data;
++ uint32_t type;
++ uint32_t pad;
++};
+
-+ while (nbox--)
-+ {
-+ struct qxl_rect qrect;
++struct qxl_rect {
++ uint32_t top;
++ uint32_t left;
++ uint32_t bottom;
++ uint32_t right;
++};
+
-+ qrect.left = pBox->x1;
-+ qrect.right = pBox->x2;
-+ qrect.top = pBox->y1;
-+ qrect.bottom = pBox->y2;
++union qxl_release_info {
++ uint64_t id;
++ uint64_t next;
++};
+
-+ submit_fill (qxl, &qrect, pixel);
++struct qxl_clip {
++ uint32_t type;
++ uint64_t address;
++};
+
-+ pBox++;
-+ }
-+ }
++struct qxl_point {
++ int x;
++ int y;
++};
+
-+ fbFillRegionSolid (pDrawable, pRegion, 0,
-+ fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
-+}
++struct qxl_pattern {
++ uint64_t pat;
++ struct qxl_point pos;
++};
+
-+static void
-+qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
++typedef enum
+{
-+ RegionRec rgnDst;
-+ int dx, dy;
-+
-+ dx = ptOldOrg.x - pWin->drawable.x;
-+ dy = ptOldOrg.y - pWin->drawable.y;
++ QXL_BRUSH_TYPE_NONE,
++ QXL_BRUSH_TYPE_SOLID,
++ QXL_BRUSH_TYPE_PATTERN
++} qxl_brush_type;
+
-+ REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
++struct qxl_brush {
++ uint32_t type;
++ union {
++ uint32_t color;
++ struct qxl_pattern pattern;
++ } u;
++};
+
-+ REGION_INIT (pScreen, &rgnDst, NullBox, 0);
++struct qxl_mask {
++ unsigned char flags;
++ struct qxl_point pos;
++ uint64_t bitmap;
++};
+
-+ REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
++typedef enum {
++ QXL_IMAGE_TYPE_BITMAP,
++ QXL_IMAGE_TYPE_QUIC,
++ QXL_IMAGE_TYPE_PNG,
++ QXL_IMAGE_TYPE_LZ_PLT = 100,
++ QXL_IMAGE_TYPE_LZ_RGB,
++ QXL_IMAGE_TYPE_GLZ_RGB,
++ QXL_IMAGE_TYPE_FROM_CACHE,
++} qxl_image_type;
+
-+ fbCopyRegion (&pWin->drawable, &pWin->drawable,
-+ NULL,
-+ &rgnDst, dx, dy, qxl_copy_n_to_n, 0, NULL);
++typedef enum {
++ QXL_IMAGE_CACHE = (1 << 0)
++} qxl_image_flags;
+
-+ REGION_UNINIT (pScreen, &rgnDst);
++struct qxl_image_descriptor
++{
++ uint64_t id;
++ uint8_t type;
++ uint8_t flags;
++ uint32_t width;
++ uint32_t height;
++};
+
-+/* REGION_TRANSLATE (pScreen, prgnSrc, dx, dy); */
-+
-+/* fbCopyWindow (pWin, ptOldOrg, prgnSrc); */
-+}
++struct qxl_data_chunk {
++ uint32_t data_size;
++ uint64_t prev_chunk;
++ uint64_t next_chunk;
++ uint8_t data[0];
++};
+
-+static int
-+qxl_create_gc (GCPtr pGC)
++typedef enum
+{
-+ static GCOps ops;
-+ static int initialized;
-+
-+ if (!fbCreateGC (pGC))
-+ return FALSE;
-+
-+ if (!initialized)
-+ {
-+ ops = *pGC->ops;
-+ ops.PolyFillRect = qxl_poly_fill_rect;
-+ ops.CopyArea = qxl_copy_area;
-+
-+ initialized = TRUE;
-+ }
-+
-+ pGC->ops = &ops;
-+ return TRUE;
-+}
-+
-+static Bool
-+qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
-+{
-+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ struct qxl_rom *rom;
-+ struct qxl_ram_header *ram_header;
-+ VisualPtr visual;
-+
-+ CHECK_POINT();
-+
-+ qxl->pScrn = pScrn;
-+
-+ if (!qxl_map_memory(qxl, scrnIndex))
-+ return FALSE;
-+
-+ rom = qxl->rom;
-+ ram_header = (void *)((unsigned long)qxl->ram + (unsigned long)qxl->rom->ram_header_offset);
-+
-+ qxl_save_state(pScrn);
-+ qxl_blank_screen(pScreen, SCREEN_SAVER_ON);
-+
-+ miClearVisualTypes();
-+ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
-+ pScrn->rgbBits, pScrn->defaultVisual))
-+ goto out;
-+ if (!miSetPixmapDepths())
-+ goto out;
++ QXL_BITMAP_FMT_INVALID,
++ QXL_BITMAP_FMT_1BIT_LE,
++ QXL_BITMAP_FMT_1BIT_BE,
++ QXL_BITMAP_FMT_4BIT_LE,
++ QXL_BITMAP_FMT_4BIT_BE,
++ QXL_BITMAP_FMT_8BIT,
++ QXL_BITMAP_FMT_16BIT,
++ QXL_BITMAP_FMT_24BIT,
++ QXL_BITMAP_FMT_32BIT,
++ QXL_BITMAP_FMT_RGBA,
++} qxl_bitmap_format;
+
-+ /* Note we do this before setting pScrn->virtualY to match our current
-+ mode, so as to allocate a buffer large enough for the largest mode.
-+ FIXME: add support for resizing the framebuffer on modeset. */
-+ qxl->fb = xcalloc(pScrn->virtualY * pScrn->displayWidth, 4);
-+ if (!qxl->fb)
-+ goto out;
++typedef enum {
++ QXL_BITMAP_PAL_CACHE_ME = (1 << 0),
++ QXL_BITMAP_PAL_FROM_CACHE = (1 << 1),
++ QXL_BITMAP_TOP_DOWN = (1 << 2),
++} qxl_bitmap_flags;
+
-+ pScrn->virtualX = pScrn->currentMode->HDisplay;
-+ pScrn->virtualY = pScrn->currentMode->VDisplay;
-+
-+ if (!fbScreenInit(pScreen, qxl->fb,
-+ pScrn->currentMode->HDisplay,
-+ pScrn->currentMode->VDisplay,
-+ pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
-+ pScrn->bitsPerPixel))
-+ {
-+ goto out;
-+ }
++struct qxl_bitmap {
++ uint8_t format;
++ uint8_t flags;
++ uint32_t x; /* actually width */
++ uint32_t y; /* actually height */
++ uint32_t stride; /* in bytes */
++ uint64_t palette; /* Can be NULL */
++ uint64_t data; /* A qxl_data_chunk that actually contains the data */
++};
+
-+ visual = pScreen->visuals + pScreen->numVisuals;
-+ while (--visual >= pScreen->visuals)
++struct qxl_image {
++ struct qxl_image_descriptor descriptor;
++ union
+ {
-+ if ((visual->class | DynamicClass) == DirectColor)
-+ {
-+ visual->offsetRed = pScrn->offset.red;
-+ visual->offsetGreen = pScrn->offset.green;
-+ visual->offsetBlue = pScrn->offset.blue;
-+ visual->redMask = pScrn->mask.red;
-+ visual->greenMask = pScrn->mask.green;
-+ visual->blueMask = pScrn->mask.blue;
-+ }
-+ }
++ struct qxl_bitmap bitmap;
++ } u;
++};
+
-+
-+ fbPictureInit(pScreen, 0, 0);
++struct qxl_fill {
++ struct qxl_brush brush;
++ unsigned short rop_descriptor;
++ struct qxl_mask mask;
++};
+
-+ qxl->create_screen_resources = pScreen->CreateScreenResources;
-+ pScreen->CreateScreenResources = qxl_create_screen_resources;
++struct qxl_opaque {
++ uint64_t src_bitmap;
++ struct qxl_rect src_area;
++ struct qxl_brush brush;
++ unsigned short rop_descriptor;
++ unsigned char scale_mode;
++ struct qxl_mask mask;
++};
+
-+ /* Set up resources */
-+ qxl->mem = qxl_mem_create ((void *)((unsigned long)qxl->ram + (unsigned long)rom->pages_offset),
-+ rom->num_io_pages * getpagesize());
-+ qxl->io_pages = (void *)((unsigned long)qxl->ram + (unsigned long)rom->pages_offset);
-+ qxl->io_pages_physical = (void *)((unsigned long)qxl->ram_physical + (unsigned long)rom->pages_offset);
++struct qxl_copy {
++ uint64_t src_bitmap;
++ struct qxl_rect src_area;
++ unsigned short rop_descriptor;
++ unsigned char scale_mode;
++ struct qxl_mask mask;
++};
+
-+ qxl->command_ring = qxl_ring_create (&(ram_header->cmd_ring_hdr),
-+ sizeof (struct qxl_command),
-+ 32, qxl->io_base + QXL_IO_NOTIFY_CMD);
-+ qxl->cursor_ring = qxl_ring_create (&(ram_header->cursor_ring_hdr),
-+ sizeof (struct qxl_command),
-+ 32, qxl->io_base + QXL_IO_NOTIFY_CURSOR);
-+ qxl->release_ring = qxl_ring_create (&(ram_header->release_ring_hdr),
-+ sizeof (uint64_t),
-+ 8, 0);
-+
-+ /* xf86DPMSInit(pScreen, xf86DPMSSet, 0); */
++struct qxl_transparent {
++ uint64_t src_bitmap;
++ struct qxl_rect src_area;
++ uint32_t src_color;
++ uint32_t true_color;
++};
+
-+#if 0 /* XV accel */
-+ qxlInitVideo(pScreen);
-+#endif
++struct qxl_alpha_blend {
++ unsigned char alpha;
++ uint64_t src_bitmap;
++ struct qxl_rect src_area;
++};
+
-+ pScreen->SaveScreen = qxl_blank_screen;
-+ qxl->close_screen = pScreen->CloseScreen;
-+ pScreen->CloseScreen = qxl_close_screen;
++struct qxl_copy_bits {
++ struct qxl_point src_pos;
++};
+
-+ qxl->create_gc = pScreen->CreateGC;
-+ pScreen->CreateGC = qxl_create_gc;
++struct qxl_blend { /* same as copy */
++ uint64_t src_bitmap;
++ struct qxl_rect src_area;
++ unsigned short rop_descriptor;
++ unsigned char scale_mode;
++ struct qxl_mask mask;
++};
+
-+#if 0
-+ qxl->paint_window_background = pScreen->PaintWindowBackground;
-+ qxl->paint_window_border = pScreen->PaintWindowBorder;
-+#endif
-+ qxl->copy_window = pScreen->CopyWindow;
-+#if 0
-+ pScreen->PaintWindowBackground = qxl_paint_window;
-+ pScreen->PaintWindowBorder = qxl_paint_window;
-+#endif
-+ pScreen->CopyWindow = qxl_copy_window;
++struct qxl_rop3 {
++ uint64_t src_bitmap;
++ struct qxl_rect src_area;
++ struct qxl_brush brush;
++ unsigned char rop3;
++ unsigned char scale_mode;
++ struct qxl_mask mask;
++};
+
-+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
++struct qxl_line_attr {
++ unsigned char flags;
++ unsigned char join_style;
++ unsigned char end_style;
++ unsigned char style_nseg;
++ int width;
++ int miter_limit;
++ uint64_t style;
++};
+
-+ if (!miCreateDefColormap(pScreen))
-+ goto out;
++struct qxl_stroke {
++ uint64_t path;
++ struct qxl_line_attr attr;
++ struct qxl_brush brush;
++ unsigned short fore_mode;
++ unsigned short back_mode;
++};
+
-+ qxl_cursor_init (pScreen);
-+
-+ CHECK_POINT();
++struct qxl_text {
++ uint64_t str;
++ struct qxl_rect back_area;
++ struct qxl_brush fore_brush;
++ struct qxl_brush back_brush;
++ unsigned short fore_mode;
++ unsigned short back_mode;
++};
+
-+ qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
++struct qxl_blackness {
++ struct qxl_mask mask;
++};
+
-+ CHECK_POINT();
-+
-+ return TRUE;
++struct qxl_inverse {
++ struct qxl_mask mask;
++};
+
-+out:
-+ return FALSE;
-+}
++struct qxl_whiteness {
++ struct qxl_mask mask;
++};
+
-+static Bool
-+qxl_enter_vt(int scrnIndex, int flags)
++/* Effects */
++typedef enum
+{
-+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+
-+ qxl_save_state(pScrn);
-+ qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
++ QXL_EFFECT_BLEND,
++ QXL_EFFECT_OPAQUE,
++ QXL_EFFECT_REVERT_ON_DUP,
++ QXL_EFFECT_BLACKNESS_ON_DUP,
++ QXL_EFFECT_WHITENESS_ON_DUP,
++ QXL_EFFECT_NOP_ON_DUP,
++ QXL_EFFECT_NOP,
++ QXL_EFFECT_OPAQUE_BRUSH
++} qxl_effect_type;
+
-+ return TRUE;
-+}
-+
-+static void
-+qxl_leave_vt(int scrnIndex, int flags)
-+{
-+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+
-+ qxl_restore_state(pScrn);
-+}
-+
-+static Bool
-+qxl_color_setup(ScrnInfoPtr pScrn)
-+{
-+ int scrnIndex = pScrn->scrnIndex;
-+ Gamma gzeros = { 0.0, 0.0, 0.0 };
-+ rgb rzeros = { 0, 0, 0 };
-+
-+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb))
-+ return FALSE;
-+
-+ if (pScrn->depth != 15 && pScrn->depth != 24)
-+ {
-+ xf86DrvMsg(scrnIndex, X_ERROR, "Depth %d is not supported\n",
-+ pScrn->depth);
-+ return FALSE;
-+ }
-+ xf86PrintDepthBpp(pScrn);
-+
-+ if (!xf86SetWeight(pScrn, rzeros, rzeros))
-+ return FALSE;
-+
-+ if (!xf86SetDefaultVisual(pScrn, -1))
-+ return FALSE;
-+
-+ if (!xf86SetGamma(pScrn, gzeros))
-+ return FALSE;
-+
-+ return TRUE;
-+}
-+
-+static void
-+print_modes (qxl_screen_t *qxl, int scrnIndex)
-+{
-+ int i;
-+
-+ for (i = 0; i < qxl->num_modes; ++i)
-+ {
-+ struct qxl_mode *m = qxl->modes + i;
-+
-+ xf86DrvMsg (scrnIndex, X_INFO,
-+ "%d: %dx%d, %d bits, stride %d, %dmm x %dmm, orientation %d\n",
-+ m->id, m->x_res, m->y_res, m->bits, m->stride, m->x_mili,
-+ m->y_mili, m->orientation);
-+ }
-+}
-+
-+static Bool
-+qxl_check_device(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
-+{
-+ int scrnIndex = pScrn->scrnIndex;
-+ struct qxl_rom *rom = qxl->rom;
-+ struct qxl_ram_header *ram_header = (void *)((unsigned long)qxl->ram + rom->ram_header_offset);
-+
-+ CHECK_POINT();
-+
-+ if (rom->magic != 0x4f525851) { /* "QXRO" little-endian */
-+ xf86DrvMsg(scrnIndex, X_ERROR, "Bad ROM signature %x\n", rom->magic);
-+ return FALSE;
-+ }
-+
-+ xf86DrvMsg(scrnIndex, X_INFO, "Device version %d.%d\n",
-+ rom->id, rom->update_id);
-+
-+ xf86DrvMsg(scrnIndex, X_INFO, "Compression level %d, log level %d\n",
-+ rom->compression_level,
-+ rom->log_level);
-+
-+ xf86DrvMsg(scrnIndex, X_INFO, "Currently using mode #%d, list at 0x%x\n",
-+ rom->mode, rom->modes_offset);
-+
-+ xf86DrvMsg(scrnIndex, X_INFO, "%d io pages at 0x%x\n",
-+ rom->num_io_pages, rom->pages_offset);
-+
-+ xf86DrvMsg(scrnIndex, X_INFO, "%d byte draw area at 0x%x\n",
-+ rom->draw_area_size, rom->draw_area_offset);
-+
-+ xf86DrvMsg(scrnIndex, X_INFO, "RAM header offset: 0x%x\n", rom->ram_header_offset);
-+
-+ if (ram_header->magic != 0x41525851) { /* "QXRA" little-endian */
-+ xf86DrvMsg(scrnIndex, X_ERROR, "Bad RAM signature %x at %p\n",
-+ ram_header->magic,
-+ &ram_header->magic);
-+ return FALSE;
-+ }
-+
-+ xf86DrvMsg(scrnIndex, X_INFO, "Correct RAM signature %x\n",
-+ ram_header->magic);
-+
-+ qxl->draw_area_offset = rom->draw_area_offset;
-+ qxl->draw_area_size = rom->draw_area_size;
-+ pScrn->videoRam = rom->draw_area_size / 1024;
-+
-+ return TRUE;
-+}
-+
-+static int
-+qxl_find_native_mode(ScrnInfoPtr pScrn, DisplayModePtr p)
-+{
-+ int i;
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+
-+ CHECK_POINT();
-+
-+ for (i = 0; i < qxl->num_modes; i++)
-+ {
-+ struct qxl_mode *m = qxl->modes + i;
-+
-+ if (m->x_res == p->HDisplay &&
-+ m->y_res == p->VDisplay &&
-+ m->bits == pScrn->bitsPerPixel)
-+ {
-+ if (m->bits == 16)
-+ {
-+ /* What QXL calls 16 bit is actually x1r5g5b515 */
-+ if (pScrn->depth == 15)
-+ return i;
-+ }
-+ else if (m->bits == 32)
-+ {
-+ /* What QXL calls 32 bit is actually x8r8g8b8 */
-+ if (pScrn->depth == 24)
-+ return i;
-+ }
-+ }
-+ }
-+
-+ return -1;
-+}
-+
-+static ModeStatus
-+qxl_valid_mode(int scrn, DisplayModePtr p, Bool flag, int pass)
++typedef enum
+{
-+ ScrnInfoPtr pScrn = xf86Screens[scrn];
-+ qxl_screen_t *qxl = pScrn->driverPrivate;
-+ int bpp = pScrn->bitsPerPixel;
-+ int mode_idx;
++ QXL_CLIP_TYPE_NONE,
++ QXL_CLIP_TYPE_RECTS,
++ QXL_CLIP_TYPE_PATH,
++} qxl_clip_type;
+
-+ /* FIXME: I don't think this is necessary now that we report the
-+ * correct amount of video ram?
-+ */
-+ if (p->HDisplay * p->VDisplay * (bpp/8) > qxl->draw_area_size)
-+ return MODE_MEM;
++typedef enum {
++ QXL_DRAW_NOP,
++ QXL_DRAW_FILL,
++ QXL_DRAW_OPAQUE,
++ QXL_DRAW_COPY,
++ QXL_COPY_BITS,
++ QXL_DRAW_BLEND,
++ QXL_DRAW_BLACKNESS,
++ QXL_DRAW_WHITENESS,
++ QXL_DRAW_INVERS,
++ QXL_DRAW_ROP3,
++ QXL_DRAW_STROKE,
++ QXL_DRAW_TEXT,
++ QXL_DRAW_TRANSPARENT,
++ QXL_DRAW_ALPHA_BLEND,
++} qxl_draw_type;
+
-+ mode_idx = qxl_find_native_mode (pScrn, p);
-+ if (mode_idx == -1)
-+ return MODE_NOMODE;
++struct qxl_drawable {
++ union qxl_release_info release_info;
++ unsigned char effect;
++ unsigned char type;
++ unsigned short bitmap_offset;
++ struct qxl_rect bitmap_area;
++ struct qxl_rect bbox;
++ struct qxl_clip clip;
++ uint32_t mm_time;
++ union {
++ struct qxl_fill fill;
++ struct qxl_opaque opaque;
++ struct qxl_copy copy;
++ struct qxl_transparent transparent;
++ struct qxl_alpha_blend alpha_blend;
++ struct qxl_copy_bits copy_bits;
++ struct qxl_blend blend;
++ struct qxl_rop3 rop3;
++ struct qxl_stroke stroke;
++ struct qxl_text text;
++ struct qxl_blackness blackness;
++ struct qxl_inverse inverse;
++ struct qxl_whiteness whiteness;
++ } u;
++};
+
-+ p->Private = (void *)(unsigned long)mode_idx;
-+
-+ return MODE_OK;
-+}
++struct qxl_update_cmd {
++ union qxl_release_info release_info;
++ struct qxl_rect area;
++ uint32_t update_id;
++};
+
-+static void qxl_add_mode(ScrnInfoPtr pScrn, int width, int height, int type)
-+{
-+ DisplayModePtr mode;
++struct qxl_point16 {
++ int16_t x;
++ int16_t y;
++};
+
-+ /* Skip already present modes */
-+ for (mode = pScrn->monitor->Modes; mode; mode = mode->next)
-+ if (mode->HDisplay == width && mode->VDisplay == height)
-+ return;
++enum {
++ QXL_CURSOR_SET,
++ QXL_CURSOR_MOVE,
++ QXL_CURSOR_HIDE,
++ QXL_CURSOR_TRAIL,
++};
+
-+ mode = xnfcalloc(1, sizeof(DisplayModeRec));
++#define QXL_CURSOR_DEVICE_DATA_SIZE 128
+
-+ mode->status = MODE_OK;
-+ mode->type = type;
-+ mode->HDisplay = width;
-+ mode->HSyncStart = (width * 105 / 100 + 7) & ~7;
-+ mode->HSyncEnd = (width * 115 / 100 + 7) & ~7;
-+ mode->HTotal = (width * 130 / 100 + 7) & ~7;
-+ mode->VDisplay = height;
-+ mode->VSyncStart = height + 1;
-+ mode->VSyncEnd = height + 4;
-+ mode->VTotal = height * 1035 / 1000;
-+ mode->Clock = mode->HTotal * mode->VTotal * 60 / 1000;
-+ mode->Flags = V_NHSYNC | V_PVSYNC;
++enum {
++ CURSOR_TYPE_ALPHA,
++ CURSOR_TYPE_MONO,
++ CURSOR_TYPE_COLOR4,
++ CURSOR_TYPE_COLOR8,
++ CURSOR_TYPE_COLOR16,
++ CURSOR_TYPE_COLOR24,
++ CURSOR_TYPE_COLOR32,
++};
+
-+ xf86SetModeDefaultName(mode);
-+ xf86ModesAdd(pScrn->monitor->Modes, mode);
-+}
++struct qxl_cursor_header {
++ uint64_t unique;
++ uint16_t type;
++ uint16_t width;
++ uint16_t height;
++ uint16_t hot_spot_x;
++ uint16_t hot_spot_y;
++};
+
-+static Bool
-+qxl_pre_init(ScrnInfoPtr pScrn, int flags)
++struct qxl_cursor
+{
-+ int i, scrnIndex = pScrn->scrnIndex;
-+ qxl_screen_t *qxl = NULL;
-+ ClockRangePtr clockRanges = NULL;
-+ int *linePitches = NULL;
-+ DisplayModePtr mode;
-+ unsigned int max_x = 0, max_y = 0;
-+
-+ CHECK_POINT();
-+
-+ /* zaphod mode is for suckers and i choose not to implement it */
-+ if (xf86IsEntityShared(pScrn->entityList[0])) {
-+ xf86DrvMsg(scrnIndex, X_ERROR, "No Zaphod mode for you\n");
-+ return FALSE;
-+ }
-+
-+ if (!pScrn->driverPrivate)
-+ pScrn->driverPrivate = xnfcalloc(sizeof(qxl_screen_t), 1);
-+ qxl = pScrn->driverPrivate;
-+
-+ qxl->entity = xf86GetEntityInfo(pScrn->entityList[0]);
-+ qxl->pci = xf86GetPciInfoForEntity(qxl->entity->index);
-+#ifndef XSERVER_LIBPCIACCESS
-+ qxl->pci_tag = pciTag(qxl->pci->bus, qxl->pci->device, qxl->pci->func);
-+#endif
-+
-+ pScrn->monitor = pScrn->confScreen->monitor;
-+
-+ if (!qxl_color_setup(pScrn))
-+ goto out;
-+
-+ /* option parsing and card differentiation */
-+ xf86CollectOptions(pScrn, NULL);
-+
-+ if (!qxl_map_memory(qxl, scrnIndex))
-+ goto out;
-+
-+ if (!qxl_check_device(pScrn, qxl))
-+ goto out;
-+
-+ /* ddc stuff here */
-+
-+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
-+ clockRanges->next = NULL;
-+ clockRanges->minClock = 10000;
-+ clockRanges->maxClock = 400000;
-+ clockRanges->clockIndex = -1;
-+ clockRanges->interlaceAllowed = clockRanges->doubleScanAllowed = 0;
-+ clockRanges->ClockMulFactor = clockRanges->ClockDivFactor = 1;
-+ pScrn->progClock = TRUE;
-+
-+ /* override QXL monitor stuff */
-+ if (pScrn->monitor->nHsync <= 0) {
-+ pScrn->monitor->hsync[0].lo = 29.0;
-+ pScrn->monitor->hsync[0].hi = 160.0;
-+ pScrn->monitor->nHsync = 1;
-+ }
-+ if (pScrn->monitor->nVrefresh <= 0) {
-+ pScrn->monitor->vrefresh[0].lo = 50;
-+ pScrn->monitor->vrefresh[0].hi = 75;
-+ pScrn->monitor->nVrefresh = 1;
-+ }
-+
-+ /* Add any modes not in xorg's default mode list */
-+ for (i = 0; i < qxl->num_modes; i++)
-+ if (qxl->modes[i].orientation == 0) {
-+ qxl_add_mode(pScrn, qxl->modes[i].x_res, qxl->modes[i].y_res,
-+ M_T_DRIVER);
-+ if (qxl->modes[i].x_res > max_x)
-+ max_x = qxl->modes[i].x_res;
-+ if (qxl->modes[i].y_res > max_y)
-+ max_y = qxl->modes[i].y_res;
-+ }
-+
-+ if (pScrn->display->virtualX == 0 && pScrn->display->virtualY == 0) {
-+ /* It is possible for the largest x + largest y size combined leading
-+ to a virtual size which will not fit into the framebuffer when this
-+ happens we prefer max width and make height as large as possible */
-+ if (max_x * max_y * (pScrn->bitsPerPixel / 8) > qxl->draw_area_size)
-+ pScrn->display->virtualY = qxl->draw_area_size /
-+ (max_x * (pScrn->bitsPerPixel / 8));
-+ else
-+ pScrn->display->virtualY = max_y;
-+
-+ pScrn->display->virtualX = max_x;
-+ }
++ struct qxl_cursor_header header;
++ uint32_t data_size;
++ struct qxl_data_chunk chunk;
++};
+
-+ if (0 >= xf86ValidateModes(pScrn, pScrn->monitor->Modes,
-+ pScrn->display->modes, clockRanges, linePitches,
-+ 128, max_x, 128 * 4, 128, max_y,
-+ pScrn->display->virtualX,
-+ pScrn->display->virtualY,
-+ 128 * 1024 * 1024, LOOKUP_BEST_REFRESH))
-+ goto out;
++struct qxl_cursor_cmd {
++ union qxl_release_info release_info;
++ uint8_t type;
++ union {
++ struct {
++ struct qxl_point16 position;
++ unsigned char visible;
++ uint64_t shape;
++ } set;
++ struct {
++ uint16_t length;
++ uint16_t frequency;
++ } trail;
++ struct qxl_point16 position;
++ } u;
++ uint8_t device_data[QXL_CURSOR_DEVICE_DATA_SIZE];
++};
+
-+ CHECK_POINT();
-+
-+ xf86PruneDriverModes(pScrn);
-+ pScrn->currentMode = pScrn->modes;
-+ /* If no modes are specified in xorg.conf, default to 1024x768 */
-+ if (pScrn->display->modes == NULL || pScrn->display->modes[0] == NULL)
-+ for (mode = pScrn->modes; mode; mode = mode->next)
-+ if (mode->HDisplay == 1024 && mode->VDisplay == 768) {
-+ pScrn->currentMode = mode;
-+ break;
-+ }
++struct qxl_rom {
++ uint32_t magic;
++ uint32_t id;
++ uint32_t update_id;
++ uint32_t compression_level;
++ uint32_t log_level;
++ uint32_t mode;
++ uint32_t modes_offset;
++ uint32_t num_io_pages;
++ uint32_t pages_offset;
++ uint32_t draw_area_offset;
++ uint32_t draw_area_size;
++ uint32_t ram_header_offset;
++ uint32_t mm_clock;
++};
+
-+ xf86PrintModes(pScrn);
-+ xf86SetDpi(pScrn, 0, 0);
++struct qxl_ring_header {
++ uint32_t num_items;
++ uint32_t prod;
++ uint32_t notify_on_prod;
++ uint32_t cons;
++ uint32_t notify_on_cons;
++};
+
-+ if (!xf86LoadSubModule(pScrn, "fb") ||
-+ !xf86LoadSubModule(pScrn, "ramdac") ||
-+ !xf86LoadSubModule(pScrn, "vgahw"))
-+ {
-+ goto out;
-+ }
++#define QXL_LOG_BUF_SIZE 4096
+
-+ print_modes (qxl, scrnIndex);
++struct qxl_ram_header {
++ uint32_t magic;
++ uint32_t int_pending;
++ uint32_t int_mask;
++ unsigned char log_buf[QXL_LOG_BUF_SIZE];
++ struct qxl_ring_header cmd_ring_hdr;
++ struct qxl_command cmd_ring[32];
++ struct qxl_ring_header cursor_ring_hdr;
++ struct qxl_command cursor_ring[32];
++ struct qxl_ring_header release_ring_hdr;
++ uint64_t release_ring[8];
++ struct qxl_rect update_area;
++};
+
-+ /* VGA hardware initialisation */
-+ if (!vgaHWGetHWRec(pScrn))
-+ return FALSE;
++#pragma pack(pop)
+
-+ /* hate */
-+ qxl_unmap_memory(qxl, scrnIndex);
++typedef struct _qxl_screen_t qxl_screen_t;
+
-+ CHECK_POINT();
++struct _qxl_screen_t
++{
++ /* These are the names QXL uses */
++ void * ram; /* Video RAM */
++ void * ram_physical;
++ void * vram; /* Command RAM */
++ struct qxl_rom * rom; /* Parameter RAM */
+
-+ xf86DrvMsg(scrnIndex, X_INFO, "PreInit complete\n");
-+ return TRUE;
++ struct qxl_ring * command_ring;
++ struct qxl_ring * cursor_ring;
++ struct qxl_ring * release_ring;
++
++ int num_modes;
++ struct qxl_mode * modes;
++ int io_base;
++ int draw_area_offset;
++ int draw_area_size;
+
-+out:
-+ if (clockRanges)
-+ xfree(clockRanges);
-+ if (qxl)
-+ xfree(qxl);
++ void * fb;
++ int bytes_per_pixel;
+
-+ return FALSE;
-+}
++ struct qxl_mem * mem; /* Context for qxl_alloc/free */
++
++ EntityInfoPtr entity;
+
++ void * io_pages;
++ void * io_pages_physical;
++
+#ifdef XSERVER_LIBPCIACCESS
-+enum qxl_class
-+{
-+ CHIP_QXL_1,
-+};
-+
-+static const struct pci_id_match qxl_device_match[] = {
-+ {
-+ PCI_VENDOR_RED_HAT, PCI_CHIP_QXL_0100, PCI_MATCH_ANY, PCI_MATCH_ANY,
-+ 0x00030000, 0x00ffffff, CHIP_QXL_1
-+ },
++ struct pci_device * pci;
++#else
++ pciVideoPtr pci;
++ PCITAG pci_tag;
++#endif
++ vgaRegRec vgaRegs;
+
-+ { 0 },
-+};
++ CreateScreenResourcesProcPtr create_screen_resources;
++ CloseScreenProcPtr close_screen;
++ CreateGCProcPtr create_gc;
++#if 0
++ PaintWindowProcPtr paint_window_background;
++ PaintWindowProcPtr paint_window_border;
+#endif
++ CopyWindowProcPtr copy_window;
++
++ DamagePtr damage;
++ RegionRec pending_copy;
++ RegionRec to_be_sent;
++
++ int16_t cur_x;
++ int16_t cur_y;
++ int16_t hot_x;
++ int16_t hot_y;
++
++ ScrnInfoPtr pScrn;
++};
+
-+static SymTabRec qxlChips[] =
++static inline uint64_t
++physical_address (qxl_screen_t *qxl, void *virtual)
+{
-+ { PCI_CHIP_QXL_0100, "QXL 1", },
-+ { -1, NULL }
-+};
++ return (uint64_t) ((unsigned long)virtual + (((unsigned long)qxl->ram_physical - (unsigned long)qxl->ram)));
++}
+
-+#ifndef XSERVER_LIBPCIACCESS
-+static PciChipsets qxlPciChips[] =
++static inline void *
++virtual_address (qxl_screen_t *qxl, void *physical)
+{
-+ { PCI_CHIP_QXL_0100, PCI_CHIP_QXL_0100, RES_SHARED_VGA },
-+ { -1, -1, RES_UNDEFINED }
-+};
-+#endif
++ return (void *) ((unsigned long)physical + ((unsigned long)qxl->ram - (unsigned long)qxl->ram_physical));
++}
+
-+static void
-+qxl_identify(int flags)
++static inline void *
++u64_to_pointer (uint64_t u)
+{
-+ xf86PrintChipsets("qxl", "Driver for QXL virtual graphics", qxlChips);
++ return (void *)(unsigned long)u;
+}
+
-+static void
-+qxl_init_scrn(ScrnInfoPtr pScrn)
++static inline uint64_t
++pointer_to_u64 (void *p)
+{
-+ pScrn->driverVersion = 0;
-+ pScrn->driverName = pScrn->name = "qxl";
-+ pScrn->PreInit = qxl_pre_init;
-+ pScrn->ScreenInit = qxl_screen_init;
-+ pScrn->SwitchMode = qxl_switch_mode;
-+ pScrn->ValidMode = qxl_valid_mode;
-+ pScrn->EnterVT = qxl_enter_vt;
-+ pScrn->LeaveVT = qxl_leave_vt;
++ return (uint64_t)(unsigned long)p;
+}
-diff --git a/src/compat/compat-qxl_image.c b/src/compat/compat-qxl_image.c
-new file mode 100644
-index 0000000..d2ac12d
---- /dev/null
-+++ b/src/compat/compat-qxl_image.c
++
++struct qxl_ring;
++
++/*
++ * HW cursor
++ */
++void qxl_cursor_init (ScreenPtr pScreen);
++
++
++
++/*
++ * Rings
++ */
++struct qxl_ring * qxl_ring_create (struct qxl_ring_header *header,
++ int element_size,
++ int n_elements,
++ int prod_notify);
++void qxl_ring_push (struct qxl_ring *ring,
++ const void *element);
++Bool qxl_ring_pop (struct qxl_ring *ring,
++ void *element);
++void qxl_ring_wait_idle (struct qxl_ring *ring);
++
++
++
++/*
++ * Images
++ */
++struct qxl_image *qxl_image_create (qxl_screen_t *qxl,
++ const uint8_t *data,
++ int x,
++ int y,
++ int width,
++ int height,
++ int stride);
++void qxl_image_destroy (qxl_screen_t *qxl,
++ struct qxl_image *image);
++void qxl_drop_image_cache (qxl_screen_t *qxl);
++
++
++/*
++ * Malloc
++ */
++struct qxl_mem * qxl_mem_create (void *base,
++ unsigned long n_bytes);
++void qxl_mem_dump_stats (struct qxl_mem *mem,
++ const char *header);
++void * qxl_alloc (struct qxl_mem *mem,
++ unsigned long n_bytes);
++void qxl_free (struct qxl_mem *mem,
++ void *d);
++void qxl_mem_free_all (struct qxl_mem *mem);
++void * qxl_allocnf (qxl_screen_t *qxl,
++ unsigned long size);
++
++
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_image.c.compat xf86-video-qxl-20130514/src/compat/compat-qxl_image.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_image.c.compat 2013-07-03 14:18:57.096319282 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_image.c 2013-07-03 14:18:57.096319282 +1000
@@ -0,0 +1,255 @@
+#include <string.h>
+#include <assert.h>
@@ -3444,11 +3343,9 @@ index 0000000..d2ac12d
+{
+ memset (image_table, 0, HASH_SIZE * sizeof (image_info_t *));
+}
-diff --git a/src/compat/compat-qxl_mem.c b/src/compat/compat-qxl_mem.c
-new file mode 100644
-index 0000000..2f6fa6a
---- /dev/null
-+++ b/src/compat/compat-qxl_mem.c
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_mem.c.compat xf86-video-qxl-20130514/src/compat/compat-qxl_mem.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_mem.c.compat 2013-07-03 14:18:57.096319282 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_mem.c 2013-07-03 14:18:57.096319282 +1000
@@ -0,0 +1,321 @@
+#include <assert.h>
+#include <stdio.h>
@@ -3771,11 +3668,9 @@ index 0000000..2f6fa6a
+ qxl_mem_dump_stats (mem, "after free");
+#endif
+}
-diff --git a/src/compat/compat-qxl_ring.c b/src/compat/compat-qxl_ring.c
-new file mode 100644
-index 0000000..9a34583
---- /dev/null
-+++ b/src/compat/compat-qxl_ring.c
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_ring.c.compat xf86-video-qxl-20130514/src/compat/compat-qxl_ring.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_ring.c.compat 2013-07-03 14:18:57.096319282 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_ring.c 2013-07-03 14:18:57.096319282 +1000
@@ -0,0 +1,97 @@
+#include <string.h>
+#include <unistd.h>
@@ -3874,6 +3769,60 @@ index 0000000..9a34583
+ mem_barrier();
+ }
+}
---
-1.8.2.1
-
+diff -up xf86-video-qxl-20130514/src/compat/Makefile.am.compat xf86-video-qxl-20130514/src/compat/Makefile.am
+--- xf86-video-qxl-20130514/src/compat/Makefile.am.compat 2013-07-03 14:18:57.093319209 +1000
++++ xf86-video-qxl-20130514/src/compat/Makefile.am 2013-07-03 14:18:57.093319209 +1000
+@@ -0,0 +1,41 @@
++# Copyright 2008 Red Hat, Inc.
++#
++# Permission is hereby granted, free of charge, to any person obtaining a
++# copy of this software and associated documentation files (the "Software"),
++# to deal in the Software without restriction, including without limitation
++# on the rights to use, copy, modify, merge, publish, distribute, sub
++# license, and/or sell copies of the Software, and to permit persons to whom
++# the Software is furnished to do so, subject to the following conditions:
++#
++# The above copyright notice and this permission notice (including the next
++# paragraph) shall be included in all copies or substantial portions of the
++# Software.
++#
++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
++# THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
++# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++
++# this is obnoxious:
++# -module lets us name the module exactly how we want
++# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
++# _ladir passes a dummy rpath to libtool so the thing will actually link
++# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
++qxl_drv_la_LTLIBRARIES = qxl_drv.la
++qxl_drv_la_LDFLAGS = -module -avoid-version
++qxl_drv_ladir = @moduledir@/drivers
++AM_CFLAGS = -g
++AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS)
++
++qxl_drv_la_SOURCES = \
++ compat-qxl.h \
++ compat-qxl_driver.c \
++ compat-qxl_image.c \
++ compat-qxl_ring.c \
++ compat-qxl_mem.c \
++ compat-lookup3.c \
++ compat-lookup3.h \
++ compat-qxl_cursor.c
+diff -up xf86-video-qxl-20130514/src/Makefile.am.compat xf86-video-qxl-20130514/src/Makefile.am
+--- xf86-video-qxl-20130514/src/Makefile.am.compat 2013-07-03 14:18:40.381914397 +1000
++++ xf86-video-qxl-20130514/src/Makefile.am 2013-07-03 14:18:57.093319209 +1000
+@@ -25,7 +25,7 @@
+ # _ladir passes a dummy rpath to libtool so the thing will actually link
+ # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
+
+-SUBDIRS=uxa
++SUBDIRS=uxa compat
+
+ AM_CFLAGS = $(SPICE_PROTOCOL_CFLAGS) $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(DRM_CFLAGS) @LIBUDEV_CFLAGS@
+
diff --git a/0003-Link-in-the-compat-driver-various-renamings.patch b/0003-Link-in-the-compat-driver-various-renamings.patch
index 88756f2..ab16375 100644
--- a/0003-Link-in-the-compat-driver-various-renamings.patch
+++ b/0003-Link-in-the-compat-driver-various-renamings.patch
@@ -1,62 +1,6 @@
-From ce0ed67104b8526f8416bad5494312f6715e01a6 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp at redhat.com>
-Date: Thu, 3 Feb 2011 06:40:29 -0500
-Subject: [PATCH 3/4] Link in the compat driver; various renamings
-
----
- src/Makefile.am | 2 +-
- src/compat/Makefile.am | 10 +-
- src/compat/compat-lookup3.c | 54 ++--
- src/compat/compat-lookup3.h | 2 +-
- src/compat/compat-qxl.h | 268 +++++++++----------
- src/compat/compat-qxl_cursor.c | 98 +++----
- src/compat/compat-qxl_driver.c | 592 ++++++++++++++++++++---------------------
- src/compat/compat-qxl_image.c | 50 ++--
- src/compat/compat-qxl_mem.c | 26 +-
- src/compat/compat-qxl_ring.c | 20 +-
- src/qxl_driver.c | 6 +-
- 11 files changed, 566 insertions(+), 562 deletions(-)
-
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 48814bc..2e8faca 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -34,7 +34,7 @@ qxl_drv_la_LTLIBRARIES = qxl_drv.la
- qxl_drv_la_LDFLAGS = -module -avoid-version
- qxl_drv_ladir = @moduledir@/drivers
-
--qxl_drv_la_LIBADD = uxa/libuxa.la
-+qxl_drv_la_LIBADD = uxa/libuxa.la compat/compatdriver.la
-
- qxl_drv_la_SOURCES = \
- qxl.h \
-diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am
-index 84a30f2..64de89d 100644
---- a/src/compat/Makefile.am
-+++ b/src/compat/Makefile.am
-@@ -24,13 +24,13 @@
- # -avoid-version prevents gratuitous .0.0.0 version numbers on the end
- # _ladir passes a dummy rpath to libtool so the thing will actually link
- # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
--qxl_drv_la_LTLIBRARIES = qxl_drv.la
--qxl_drv_la_LDFLAGS = -module -avoid-version
--qxl_drv_ladir = @moduledir@/drivers
--AM_CFLAGS = -g
-+
-+noinst_LTLIBRARIES = compatdriver.la
-+compatdriver_la_LDFLAGS = -module -avoid-version
-+
- AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS)
-
--qxl_drv_la_SOURCES = \
-+compatdriver_la_SOURCES = \
- compat-qxl.h \
- compat-qxl_driver.c \
- compat-qxl_image.c \
-diff --git a/src/compat/compat-lookup3.c b/src/compat/compat-lookup3.c
-index c301d85..a0608a9 100644
---- a/src/compat/compat-lookup3.c
-+++ b/src/compat/compat-lookup3.c
+diff -up xf86-video-qxl-20130514/src/compat/compat-lookup3.c.compat2 xf86-video-qxl-20130514/src/compat/compat-lookup3.c
+--- xf86-video-qxl-20130514/src/compat/compat-lookup3.c.compat2 2013-07-03 14:19:39.007334520 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-lookup3.c 2013-07-03 14:19:56.102748510 +1000
@@ -3,17 +3,17 @@
lookup3.c, by Bob Jenkins, May 2006, Public Domain.
@@ -81,7 +25,7 @@ index c301d85..a0608a9 100644
If you want to find a hash of, say, exactly 7 integers, do
a = i1; b = i2; c = i3;
-@@ -23,9 +23,9 @@ If you want to find a hash of, say, exactly 7 integers, do
+@@ -23,9 +23,9 @@ If you want to find a hash of, say, exac
a += i7;
final(a,b,c);
then use c as the hash value. If you have a variable length array of
@@ -131,7 +75,7 @@ index c301d85..a0608a9 100644
const uint32_t *k, /* the key, an array of uint32_t values */
size_t length, /* the length of the key, in uint32_ts */
uint32_t *pc, /* IN: seed OUT: primary hash value */
-@@ -252,7 +252,7 @@ uint32_t *pb) /* IN: more seed OUT: secondary hash value */
+@@ -252,7 +252,7 @@ uint32_t *pb) /* IN:
/*
-------------------------------------------------------------------------------
@@ -140,7 +84,7 @@ index c301d85..a0608a9 100644
k : the key (the unaligned variable-length array of bytes)
length : the length of the key, counting by bytes
initval : can be any 4-byte value
-@@ -267,7 +267,7 @@ use a bitmask. For example, if you need only 10 bits, do
+@@ -267,7 +267,7 @@ use a bitmask. For example, if you need
In which case, the hash table should have hashsize(10) elements.
If you are hashing n strings (uint8_t **)k, do it like this:
@@ -149,7 +93,7 @@ index c301d85..a0608a9 100644
By Bob Jenkins, 2006. bob_jenkins at burtleburtle.net. You may use this
code any way you wish, private, educational, or commercial. It's free.
-@@ -277,7 +277,7 @@ acceptable. Do NOT use for cryptographic purposes.
+@@ -277,7 +277,7 @@ acceptable. Do NOT use for cryptographi
-------------------------------------------------------------------------------
*/
@@ -158,7 +102,7 @@ index c301d85..a0608a9 100644
{
uint32_t a,b,c; /* internal state */
union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */
-@@ -450,16 +450,16 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval)
+@@ -450,16 +450,16 @@ uint32_t hashlittle( const void *key, si
/*
@@ -195,10 +139,9 @@ index c301d85..a0608a9 100644
{
uint32_t a,b,c;
union { const void *ptr; size_t i; } u; /* to cast key to (size_t) happily */
-diff --git a/src/compat/compat-lookup3.h b/src/compat/compat-lookup3.h
-index 50c1cf4..67658ad 100644
---- a/src/compat/compat-lookup3.h
-+++ b/src/compat/compat-lookup3.h
+diff -up xf86-video-qxl-20130514/src/compat/compat-lookup3.h.compat2 xf86-video-qxl-20130514/src/compat/compat-lookup3.h
+--- xf86-video-qxl-20130514/src/compat/compat-lookup3.h.compat2 2013-07-03 14:19:39.007334520 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-lookup3.h 2013-07-03 14:19:56.102748510 +1000
@@ -21,6 +21,6 @@ typedef UINT8 uint8_t;
#endif
@@ -207,2156 +150,2153 @@ index 50c1cf4..67658ad 100644
+uint32_t compat_hashlittle( const void *key, size_t length, uint32_t initval);
#endif
-diff --git a/src/compat/compat-qxl.h b/src/compat/compat-qxl.h
-index bec43b3..2c61699 100644
---- a/src/compat/compat-qxl.h
-+++ b/src/compat/compat-qxl.h
-@@ -43,8 +43,8 @@
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_cursor.c.compat2 xf86-video-qxl-20130514/src/compat/compat-qxl_cursor.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_cursor.c.compat2 2013-07-03 14:19:39.008334544 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_cursor.c 2013-07-03 14:19:56.103748552 +1000
+@@ -25,25 +25,25 @@
+ #include <cursorstr.h>
- #define hidden _X_HIDDEN
+ static void
+-push_cursor (qxl_screen_t *qxl, struct qxl_cursor_cmd *cursor)
++push_cursor (compat_qxl_screen_t *compat_qxl, struct compat_qxl_cursor_cmd *cursor)
+ {
+- struct qxl_command cmd;
++ struct compat_qxl_command cmd;
--#define QXL_NAME "qxl"
--#define QXL_DRIVER_NAME "qxl"
-+#define QXL_NAME "compat_qxl"
-+#define QXL_DRIVER_NAME "compat_qxl"
- #define PCI_VENDOR_RED_HAT 0x1b36
+- /* See comment on push_command() in qxl_driver.c */
+- if (qxl->rom->mode != ~0)
++ /* See comment on push_command() in compat_qxl_driver.c */
++ if (compat_qxl->rom->mode != ~0)
+ {
+ cmd.type = QXL_CMD_CURSOR;
+- cmd.data = physical_address (qxl, cursor);
++ cmd.data = physical_address (compat_qxl, cursor);
+
+- qxl_ring_push (qxl->cursor_ring, &cmd);
++ compat_qxl_ring_push (compat_qxl->cursor_ring, &cmd);
+ }
+ }
- #define PCI_CHIP_QXL_0100 0x0100
-@@ -63,7 +63,7 @@ enum {
- QXL_IO_LOG,
- };
+-static struct qxl_cursor_cmd *
+-qxl_alloc_cursor_cmd(qxl_screen_t *qxl)
++static struct compat_qxl_cursor_cmd *
++compat_qxl_alloc_cursor_cmd(compat_qxl_screen_t *compat_qxl)
+ {
+- struct qxl_cursor_cmd *cmd =
+- qxl_allocnf (qxl, sizeof(struct qxl_cursor_cmd));
++ struct compat_qxl_cursor_cmd *cmd =
++ compat_qxl_allocnf (compat_qxl, sizeof(struct compat_qxl_cursor_cmd));
--struct qxl_mode {
-+struct compat_qxl_mode {
- uint32_t id;
- uint32_t x_res;
- uint32_t y_res;
-@@ -81,39 +81,39 @@ typedef enum
- QXL_CMD_UPDATE,
- QXL_CMD_CURSOR,
- QXL_CMD_MESSAGE
--} qxl_command_type;
-+} compat_qxl_command_type;
+ cmd->release_info.id = pointer_to_u64 (cmd) | 1;
+
+@@ -51,43 +51,43 @@ qxl_alloc_cursor_cmd(qxl_screen_t *qxl)
+ }
--struct qxl_command {
-+struct compat_qxl_command {
- uint64_t data;
- uint32_t type;
- uint32_t pad;
- };
+ static void
+-qxl_set_cursor_position(ScrnInfoPtr pScrn, int x, int y)
++compat_qxl_set_cursor_position(ScrnInfoPtr pScrn, int x, int y)
+ {
+- qxl_screen_t *qxl = pScrn->driverPrivate;
+- struct qxl_cursor_cmd *cmd = qxl_alloc_cursor_cmd(qxl);
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
++ struct compat_qxl_cursor_cmd *cmd = compat_qxl_alloc_cursor_cmd(compat_qxl);
--struct qxl_rect {
-+struct compat_qxl_rect {
- uint32_t top;
- uint32_t left;
- uint32_t bottom;
- uint32_t right;
- };
+- qxl->cur_x = x;
+- qxl->cur_y = y;
++ compat_qxl->cur_x = x;
++ compat_qxl->cur_y = y;
+
+ cmd->type = QXL_CURSOR_MOVE;
+- cmd->u.position.x = qxl->cur_x + qxl->hot_x;
+- cmd->u.position.y = qxl->cur_y + qxl->hot_y;
++ cmd->u.position.x = compat_qxl->cur_x + compat_qxl->hot_x;
++ cmd->u.position.y = compat_qxl->cur_y + compat_qxl->hot_y;
--union qxl_release_info {
-+union compat_qxl_release_info {
- uint64_t id;
- uint64_t next;
- };
+- push_cursor(qxl, cmd);
++ push_cursor(compat_qxl, cmd);
+ }
--struct qxl_clip {
-+struct compat_qxl_clip {
- uint32_t type;
- uint64_t address;
- };
+ static void
+-qxl_load_cursor_image(ScrnInfoPtr pScrn, unsigned char *bits)
++compat_qxl_load_cursor_image(ScrnInfoPtr pScrn, unsigned char *bits)
+ {
+ }
--struct qxl_point {
-+struct compat_qxl_point {
- int x;
- int y;
- };
+ static void
+-qxl_set_cursor_colors(ScrnInfoPtr pScrn, int bg, int fg)
++compat_qxl_set_cursor_colors(ScrnInfoPtr pScrn, int bg, int fg)
+ {
+ /* Should not be called since UseHWCursor returned FALSE */
+ }
--struct qxl_pattern {
-+struct compat_qxl_pattern {
- uint64_t pat;
-- struct qxl_point pos;
-+ struct compat_qxl_point pos;
- };
+ static void
+-qxl_load_cursor_argb (ScrnInfoPtr pScrn, CursorPtr pCurs)
++compat_qxl_load_cursor_argb (ScrnInfoPtr pScrn, CursorPtr pCurs)
+ {
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+ int w = pCurs->bits->width;
+ int h = pCurs->bits->height;
+ int size = w * h * sizeof (CARD32);
- typedef enum
-@@ -121,19 +121,19 @@ typedef enum
- QXL_BRUSH_TYPE_NONE,
- QXL_BRUSH_TYPE_SOLID,
- QXL_BRUSH_TYPE_PATTERN
--} qxl_brush_type;
-+} compat_qxl_brush_type;
+- struct qxl_cursor_cmd *cmd = qxl_alloc_cursor_cmd (qxl);
+- struct qxl_cursor *cursor =
+- qxl_allocnf(qxl, sizeof(struct qxl_cursor) + size);
++ struct compat_qxl_cursor_cmd *cmd = compat_qxl_alloc_cursor_cmd (compat_qxl);
++ struct compat_qxl_cursor *cursor =
++ compat_qxl_allocnf(compat_qxl, sizeof(struct compat_qxl_cursor) + size);
--struct qxl_brush {
-+struct compat_qxl_brush {
- uint32_t type;
- union {
- uint32_t color;
-- struct qxl_pattern pattern;
-+ struct compat_qxl_pattern pattern;
- } u;
- };
+ cursor->header.unique = 0;
+ cursor->header.type = CURSOR_TYPE_ALPHA;
+@@ -121,20 +121,20 @@ qxl_load_cursor_argb (ScrnInfoPtr pScrn,
+ }
+ #endif
--struct qxl_mask {
-+struct compat_qxl_mask {
- unsigned char flags;
-- struct qxl_point pos;
-+ struct compat_qxl_point pos;
- uint64_t bitmap;
- };
+- qxl->hot_x = pCurs->bits->xhot;
+- qxl->hot_y = pCurs->bits->yhot;
++ compat_qxl->hot_x = pCurs->bits->xhot;
++ compat_qxl->hot_y = pCurs->bits->yhot;
+
+ cmd->type = QXL_CURSOR_SET;
+- cmd->u.set.position.x = qxl->cur_x + qxl->hot_x;
+- cmd->u.set.position.y = qxl->cur_y + qxl->hot_y;
+- cmd->u.set.shape = physical_address (qxl, cursor);
++ cmd->u.set.position.x = compat_qxl->cur_x + compat_qxl->hot_x;
++ cmd->u.set.position.y = compat_qxl->cur_y + compat_qxl->hot_y;
++ cmd->u.set.shape = physical_address (compat_qxl, cursor);
+ cmd->u.set.visible = TRUE;
-@@ -145,13 +145,13 @@ typedef enum {
- QXL_IMAGE_TYPE_LZ_RGB,
- QXL_IMAGE_TYPE_GLZ_RGB,
- QXL_IMAGE_TYPE_FROM_CACHE,
--} qxl_image_type;
-+} compat_qxl_image_type;
+- push_cursor(qxl, cmd);
++ push_cursor(compat_qxl, cmd);
+ }
- typedef enum {
- QXL_IMAGE_CACHE = (1 << 0)
--} qxl_image_flags;
-+} compat_qxl_image_flags;
+ static Bool
+-qxl_use_hw_cursor (ScreenPtr pScrn, CursorPtr pCurs)
++compat_qxl_use_hw_cursor (ScreenPtr pScrn, CursorPtr pCurs)
+ {
+ /* Old-school bitmap cursors are not
+ * hardware accelerated for now.
+@@ -143,36 +143,36 @@ qxl_use_hw_cursor (ScreenPtr pScrn, Curs
+ }
--struct qxl_image_descriptor
-+struct compat_qxl_image_descriptor
+ static Bool
+-qxl_use_hw_cursorARGB (ScreenPtr pScrn, CursorPtr pCurs)
++compat_qxl_use_hw_cursorARGB (ScreenPtr pScrn, CursorPtr pCurs)
{
- uint64_t id;
- uint8_t type;
-@@ -160,7 +160,7 @@ struct qxl_image_descriptor
- uint32_t height;
- };
+ return TRUE;
+ }
--struct qxl_data_chunk {
-+struct compat_qxl_data_chunk {
- uint32_t data_size;
- uint64_t prev_chunk;
- uint64_t next_chunk;
-@@ -179,90 +179,90 @@ typedef enum
- QXL_BITMAP_FMT_24BIT,
- QXL_BITMAP_FMT_32BIT,
- QXL_BITMAP_FMT_RGBA,
--} qxl_bitmap_format;
-+} compat_qxl_bitmap_format;
+ static void
+-qxl_hide_cursor(ScrnInfoPtr pScrn)
++compat_qxl_hide_cursor(ScrnInfoPtr pScrn)
+ {
+- qxl_screen_t *qxl = pScrn->driverPrivate;
+- struct qxl_cursor_cmd *cursor = qxl_alloc_cursor_cmd(qxl);
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
++ struct compat_qxl_cursor_cmd *cursor = compat_qxl_alloc_cursor_cmd(compat_qxl);
- typedef enum {
- QXL_BITMAP_PAL_CACHE_ME = (1 << 0),
- QXL_BITMAP_PAL_FROM_CACHE = (1 << 1),
- QXL_BITMAP_TOP_DOWN = (1 << 2),
--} qxl_bitmap_flags;
-+} compat_qxl_bitmap_flags;
+ cursor->type = QXL_CURSOR_HIDE;
--struct qxl_bitmap {
-+struct compat_qxl_bitmap {
- uint8_t format;
- uint8_t flags;
- uint32_t x; /* actually width */
- uint32_t y; /* actually height */
- uint32_t stride; /* in bytes */
- uint64_t palette; /* Can be NULL */
-- uint64_t data; /* A qxl_data_chunk that actually contains the data */
-+ uint64_t data; /* A compat_qxl_data_chunk that actually contains the data */
- };
+- push_cursor(qxl, cursor);
++ push_cursor(compat_qxl, cursor);
+ }
--struct qxl_image {
-- struct qxl_image_descriptor descriptor;
-+struct compat_qxl_image {
-+ struct compat_qxl_image_descriptor descriptor;
- union
- {
-- struct qxl_bitmap bitmap;
-+ struct compat_qxl_bitmap bitmap;
- } u;
- };
+ static void
+-qxl_show_cursor(ScrnInfoPtr pScrn)
++compat_qxl_show_cursor(ScrnInfoPtr pScrn)
+ {
+ /*
+ * slightly hacky, but there's no QXL_CURSOR_SHOW. Could maybe do
+ * QXL_CURSOR_SET?
+ */
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
--struct qxl_fill {
-- struct qxl_brush brush;
-+struct compat_qxl_fill {
-+ struct compat_qxl_brush brush;
- unsigned short rop_descriptor;
-- struct qxl_mask mask;
-+ struct compat_qxl_mask mask;
- };
+- qxl_set_cursor_position(pScrn, qxl->cur_x, qxl->cur_y);
++ compat_qxl_set_cursor_position(pScrn, compat_qxl->cur_x, compat_qxl->cur_y);
+ }
--struct qxl_opaque {
-+struct compat_qxl_opaque {
- uint64_t src_bitmap;
-- struct qxl_rect src_area;
-- struct qxl_brush brush;
-+ struct compat_qxl_rect src_area;
-+ struct compat_qxl_brush brush;
- unsigned short rop_descriptor;
- unsigned char scale_mode;
-- struct qxl_mask mask;
-+ struct compat_qxl_mask mask;
- };
+ hidden void
+-qxl_cursor_init(ScreenPtr pScreen)
++compat_qxl_cursor_init(ScreenPtr pScreen)
+ {
+ xf86CursorInfoPtr cursor;
--struct qxl_copy {
-+struct compat_qxl_copy {
- uint64_t src_bitmap;
-- struct qxl_rect src_area;
-+ struct compat_qxl_rect src_area;
- unsigned short rop_descriptor;
- unsigned char scale_mode;
-- struct qxl_mask mask;
-+ struct compat_qxl_mask mask;
- };
+@@ -182,14 +182,14 @@ qxl_cursor_init(ScreenPtr pScreen)
--struct qxl_transparent {
-+struct compat_qxl_transparent {
- uint64_t src_bitmap;
-- struct qxl_rect src_area;
-+ struct compat_qxl_rect src_area;
- uint32_t src_color;
- uint32_t true_color;
- };
+ cursor->MaxWidth = cursor->MaxHeight = 64;
+ /* cursor->Flags; */
+- cursor->SetCursorPosition = qxl_set_cursor_position;
+- cursor->LoadCursorARGB = qxl_load_cursor_argb;
+- cursor->UseHWCursor = qxl_use_hw_cursor;
+- cursor->UseHWCursorARGB = qxl_use_hw_cursorARGB;
+- cursor->LoadCursorImage = qxl_load_cursor_image;
+- cursor->SetCursorColors = qxl_set_cursor_colors;
+- cursor->HideCursor = qxl_hide_cursor;
+- cursor->ShowCursor = qxl_show_cursor;
++ cursor->SetCursorPosition = compat_qxl_set_cursor_position;
++ cursor->LoadCursorARGB = compat_qxl_load_cursor_argb;
++ cursor->UseHWCursor = compat_qxl_use_hw_cursor;
++ cursor->UseHWCursorARGB = compat_qxl_use_hw_cursorARGB;
++ cursor->LoadCursorImage = compat_qxl_load_cursor_image;
++ cursor->SetCursorColors = compat_qxl_set_cursor_colors;
++ cursor->HideCursor = compat_qxl_hide_cursor;
++ cursor->ShowCursor = compat_qxl_show_cursor;
--struct qxl_alpha_blend {
-+struct compat_qxl_alpha_blend {
- unsigned char alpha;
- uint64_t src_bitmap;
-- struct qxl_rect src_area;
-+ struct compat_qxl_rect src_area;
- };
+ if (!xf86InitCursor(pScreen, cursor))
+ xfree(cursor);
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_driver.c.compat2 xf86-video-qxl-20130514/src/compat/compat-qxl_driver.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_driver.c.compat2 2013-07-03 14:19:39.009334569 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_driver.c 2013-07-03 14:19:56.103748552 +1000
+@@ -20,10 +20,10 @@
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
--struct qxl_copy_bits {
-- struct qxl_point src_pos;
-+struct compat_qxl_copy_bits {
-+ struct compat_qxl_point src_pos;
- };
+-/** \file qxl_driver.c
++/** \file compat_qxl_driver.c
+ * \author Adam Jackson <ajax at redhat.com>
+ *
+- * This is qxl, a driver for the Qumranet paravirtualized graphics device
++ * This is compat_qxl, a driver for the Qumranet paravirtualized graphics device
+ * in qemu.
+ */
--struct qxl_blend { /* same as copy */
-+struct compat_qxl_blend { /* same as copy */
- uint64_t src_bitmap;
-- struct qxl_rect src_area;
-+ struct compat_qxl_rect src_area;
- unsigned short rop_descriptor;
- unsigned char scale_mode;
-- struct qxl_mask mask;
-+ struct compat_qxl_mask mask;
- };
+@@ -39,12 +39,12 @@
+ #define CHECK_POINT()
--struct qxl_rop3 {
-+struct compat_qxl_rop3 {
- uint64_t src_bitmap;
-- struct qxl_rect src_area;
-- struct qxl_brush brush;
-+ struct compat_qxl_rect src_area;
-+ struct compat_qxl_brush brush;
- unsigned char rop3;
- unsigned char scale_mode;
-- struct qxl_mask mask;
-+ struct compat_qxl_mask mask;
- };
+ static int
+-garbage_collect (qxl_screen_t *qxl)
++garbage_collect (compat_qxl_screen_t *compat_qxl)
+ {
+ uint64_t id;
+ int i = 0;
+
+- while (qxl_ring_pop (qxl->release_ring, &id))
++ while (compat_qxl_ring_pop (compat_qxl->release_ring, &id))
+ {
+ while (id)
+ {
+@@ -54,9 +54,9 @@ garbage_collect (qxl_screen_t *qxl)
+ */
+ #define POINTER_MASK ((1 << 2) - 1)
+
+- union qxl_release_info *info = u64_to_pointer (id & ~POINTER_MASK);
+- struct qxl_cursor_cmd *cmd = (struct qxl_cursor_cmd *)info;
+- struct qxl_drawable *drawable = (struct qxl_drawable *)info;
++ union compat_qxl_release_info *info = u64_to_pointer (id & ~POINTER_MASK);
++ struct compat_qxl_cursor_cmd *cmd = (struct compat_qxl_cursor_cmd *)info;
++ struct compat_qxl_drawable *drawable = (struct compat_qxl_drawable *)info;
+ int is_cursor = FALSE;
--struct qxl_line_attr {
-+struct compat_qxl_line_attr {
- unsigned char flags;
- unsigned char join_style;
- unsigned char end_style;
-@@ -272,33 +272,33 @@ struct qxl_line_attr {
- uint64_t style;
- };
+ if ((id & POINTER_MASK) == 1)
+@@ -64,22 +64,22 @@ garbage_collect (qxl_screen_t *qxl)
--struct qxl_stroke {
-+struct compat_qxl_stroke {
- uint64_t path;
-- struct qxl_line_attr attr;
-- struct qxl_brush brush;
-+ struct compat_qxl_line_attr attr;
-+ struct compat_qxl_brush brush;
- unsigned short fore_mode;
- unsigned short back_mode;
- };
+ if (is_cursor && cmd->type == QXL_CURSOR_SET)
+ {
+- struct qxl_cursor *cursor = (void *)virtual_address (
+- qxl, u64_to_pointer (cmd->u.set.shape));
++ struct compat_qxl_cursor *cursor = (void *)virtual_address (
++ compat_qxl, u64_to_pointer (cmd->u.set.shape));
--struct qxl_text {
-+struct compat_qxl_text {
- uint64_t str;
-- struct qxl_rect back_area;
-- struct qxl_brush fore_brush;
-- struct qxl_brush back_brush;
-+ struct compat_qxl_rect back_area;
-+ struct compat_qxl_brush fore_brush;
-+ struct compat_qxl_brush back_brush;
- unsigned short fore_mode;
- unsigned short back_mode;
- };
+- qxl_free (qxl->mem, cursor);
++ compat_qxl_free (compat_qxl->mem, cursor);
+ }
+ else if (!is_cursor && drawable->type == QXL_DRAW_COPY)
+ {
+- struct qxl_image *image = virtual_address (
+- qxl, u64_to_pointer (drawable->u.copy.src_bitmap));
++ struct compat_qxl_image *image = virtual_address (
++ compat_qxl, u64_to_pointer (drawable->u.copy.src_bitmap));
--struct qxl_blackness {
-- struct qxl_mask mask;
-+struct compat_qxl_blackness {
-+ struct compat_qxl_mask mask;
- };
+- qxl_image_destroy (qxl, image);
++ compat_qxl_image_destroy (compat_qxl, image);
+ }
+
+ id = info->next;
+
+- qxl_free (qxl->mem, info);
++ compat_qxl_free (compat_qxl->mem, info);
+ }
+ }
--struct qxl_inverse {
-- struct qxl_mask mask;
-+struct compat_qxl_inverse {
-+ struct compat_qxl_mask mask;
- };
+@@ -87,7 +87,7 @@ garbage_collect (qxl_screen_t *qxl)
+ }
--struct qxl_whiteness {
-- struct qxl_mask mask;
-+struct compat_qxl_whiteness {
-+ struct compat_qxl_mask mask;
- };
+ static void
+-qxl_usleep (int useconds)
++compat_qxl_usleep (int useconds)
+ {
+ struct timespec t;
- /* Effects */
-@@ -312,14 +312,14 @@ typedef enum
- QXL_EFFECT_NOP_ON_DUP,
- QXL_EFFECT_NOP,
- QXL_EFFECT_OPAQUE_BRUSH
--} qxl_effect_type;
-+} compat_qxl_effect_type;
+@@ -102,35 +102,35 @@ qxl_usleep (int useconds)
- typedef enum
+ #if 0
+ static void
+-push_update_area (qxl_screen_t *qxl, const struct qxl_rect *area)
++push_update_area (compat_qxl_screen_t *compat_qxl, const struct compat_qxl_rect *area)
{
- QXL_CLIP_TYPE_NONE,
- QXL_CLIP_TYPE_RECTS,
- QXL_CLIP_TYPE_PATH,
--} qxl_clip_type;
-+} compat_qxl_clip_type;
+- struct qxl_update_cmd *update = qxl_allocnf (qxl, sizeof *update);
+- struct qxl_command cmd;
++ struct compat_qxl_update_cmd *update = compat_qxl_allocnf (compat_qxl, sizeof *update);
++ struct compat_qxl_command cmd;
- typedef enum {
- QXL_DRAW_NOP,
-@@ -336,41 +336,41 @@ typedef enum {
- QXL_DRAW_TEXT,
- QXL_DRAW_TRANSPARENT,
- QXL_DRAW_ALPHA_BLEND,
--} qxl_draw_type;
-+} compat_qxl_draw_type;
+ update->release_info.id = (uint64_t)update;
+ update->area = *area;
+ update->update_id = 0;
--struct qxl_drawable {
-- union qxl_release_info release_info;
-+struct compat_qxl_drawable {
-+ union compat_qxl_release_info release_info;
- unsigned char effect;
- unsigned char type;
- unsigned short bitmap_offset;
-- struct qxl_rect bitmap_area;
-- struct qxl_rect bbox;
-- struct qxl_clip clip;
-+ struct compat_qxl_rect bitmap_area;
-+ struct compat_qxl_rect bbox;
-+ struct compat_qxl_clip clip;
- uint32_t mm_time;
- union {
-- struct qxl_fill fill;
-- struct qxl_opaque opaque;
-- struct qxl_copy copy;
-- struct qxl_transparent transparent;
-- struct qxl_alpha_blend alpha_blend;
-- struct qxl_copy_bits copy_bits;
-- struct qxl_blend blend;
-- struct qxl_rop3 rop3;
-- struct qxl_stroke stroke;
-- struct qxl_text text;
-- struct qxl_blackness blackness;
-- struct qxl_inverse inverse;
-- struct qxl_whiteness whiteness;
-+ struct compat_qxl_fill fill;
-+ struct compat_qxl_opaque opaque;
-+ struct compat_qxl_copy copy;
-+ struct compat_qxl_transparent transparent;
-+ struct compat_qxl_alpha_blend alpha_blend;
-+ struct compat_qxl_copy_bits copy_bits;
-+ struct compat_qxl_blend blend;
-+ struct compat_qxl_rop3 rop3;
-+ struct compat_qxl_stroke stroke;
-+ struct compat_qxl_text text;
-+ struct compat_qxl_blackness blackness;
-+ struct compat_qxl_inverse inverse;
-+ struct compat_qxl_whiteness whiteness;
- } u;
- };
+ cmd.type = QXL_CMD_UDPATE;
+- cmd.data = physical_address (qxl, update);
++ cmd.data = physical_address (compat_qxl, update);
--struct qxl_update_cmd {
-- union qxl_release_info release_info;
-- struct qxl_rect area;
-+struct compat_qxl_update_cmd {
-+ union compat_qxl_release_info release_info;
-+ struct compat_qxl_rect area;
- uint32_t update_id;
- };
+- qxl_ring_push (qxl->command_ring, &cmd);
++ compat_qxl_ring_push (compat_qxl->command_ring, &cmd);
+ }
+ #endif
--struct qxl_point16 {
-+struct compat_qxl_point16 {
- int16_t x;
- int16_t y;
- };
-@@ -394,7 +394,7 @@ enum {
- CURSOR_TYPE_COLOR32,
- };
+ void *
+-qxl_allocnf (qxl_screen_t *qxl, unsigned long size)
++compat_qxl_allocnf (compat_qxl_screen_t *compat_qxl, unsigned long size)
+ {
+ void *result;
+ int n_attempts = 0;
+ static int nth_oom = 1;
--struct qxl_cursor_header {
-+struct compat_qxl_cursor_header {
- uint64_t unique;
- uint16_t type;
- uint16_t width;
-@@ -403,19 +403,19 @@ struct qxl_cursor_header {
- uint16_t hot_spot_y;
- };
+- garbage_collect (qxl);
++ garbage_collect (compat_qxl);
+
+- while (!(result = qxl_alloc (qxl->mem, size)))
++ while (!(result = compat_qxl_alloc (compat_qxl->mem, size)))
+ {
+- struct qxl_ram_header *ram_header = (void *)((unsigned long)qxl->ram +
+- qxl->rom->ram_header_offset);
++ struct compat_qxl_ram_header *ram_header = (void *)((unsigned long)compat_qxl->ram +
++ compat_qxl->rom->ram_header_offset);
+
+ /* Rather than go out of memory, we simply tell the
+ * device to dump everything
+@@ -140,21 +140,21 @@ qxl_allocnf (qxl_screen_t *qxl, unsigned
+ ram_header->update_area.left = 0;
+ ram_header->update_area.right = 800;
+
+- outb (qxl->io_base + QXL_IO_UPDATE_AREA, 0);
++ outb (compat_qxl->io_base + QXL_IO_UPDATE_AREA, 0);
+
+ ErrorF ("eliminated memory (%d)\n", nth_oom++);
--struct qxl_cursor
-+struct compat_qxl_cursor
- {
-- struct qxl_cursor_header header;
-+ struct compat_qxl_cursor_header header;
- uint32_t data_size;
-- struct qxl_data_chunk chunk;
-+ struct compat_qxl_data_chunk chunk;
- };
+- outb (qxl->io_base + QXL_IO_NOTIFY_OOM, 0);
++ outb (compat_qxl->io_base + QXL_IO_NOTIFY_OOM, 0);
--struct qxl_cursor_cmd {
-- union qxl_release_info release_info;
-+struct compat_qxl_cursor_cmd {
-+ union compat_qxl_release_info release_info;
- uint8_t type;
- union {
- struct {
-- struct qxl_point16 position;
-+ struct compat_qxl_point16 position;
- unsigned char visible;
- uint64_t shape;
- } set;
-@@ -423,12 +423,12 @@ struct qxl_cursor_cmd {
- uint16_t length;
- uint16_t frequency;
- } trail;
-- struct qxl_point16 position;
-+ struct compat_qxl_point16 position;
- } u;
- uint8_t device_data[QXL_CURSOR_DEVICE_DATA_SIZE];
- };
+- qxl_usleep (10000);
++ compat_qxl_usleep (10000);
+
+- if (garbage_collect (qxl))
++ if (garbage_collect (compat_qxl))
+ {
+ n_attempts = 0;
+ }
+ else if (++n_attempts == 1000)
+ {
+- qxl_mem_dump_stats (qxl->mem, "Out of mem - stats\n");
++ compat_qxl_mem_dump_stats (compat_qxl->mem, "Out of mem - stats\n");
+
+ fprintf (stderr, "Out of memory\n");
+ exit (1);
+@@ -165,127 +165,127 @@ qxl_allocnf (qxl_screen_t *qxl, unsigned
+ }
--struct qxl_rom {
-+struct compat_qxl_rom {
- uint32_t magic;
- uint32_t id;
- uint32_t update_id;
-@@ -444,7 +444,7 @@ struct qxl_rom {
- uint32_t mm_clock;
- };
+ static Bool
+-qxl_blank_screen(ScreenPtr pScreen, int mode)
++compat_qxl_blank_screen(ScreenPtr pScreen, int mode)
+ {
+ return TRUE;
+ }
+
+ static void
+-qxl_unmap_memory(qxl_screen_t *qxl, int scrnIndex)
++compat_qxl_unmap_memory(compat_qxl_screen_t *compat_qxl, int scrnIndex)
+ {
+ #ifdef XSERVER_LIBPCIACCESS
+- if (qxl->ram)
+- pci_device_unmap_range(qxl->pci, qxl->ram, qxl->pci->regions[0].size);
+- if (qxl->vram)
+- pci_device_unmap_range(qxl->pci, qxl->vram, qxl->pci->regions[1].size);
+- if (qxl->rom)
+- pci_device_unmap_range(qxl->pci, qxl->rom, qxl->pci->regions[2].size);
++ if (compat_qxl->ram)
++ pci_device_unmap_range(compat_qxl->pci, compat_qxl->ram, compat_qxl->pci->regions[0].size);
++ if (compat_qxl->vram)
++ pci_device_unmap_range(compat_qxl->pci, compat_qxl->vram, compat_qxl->pci->regions[1].size);
++ if (compat_qxl->rom)
++ pci_device_unmap_range(compat_qxl->pci, compat_qxl->rom, compat_qxl->pci->regions[2].size);
+ #else
+- if (qxl->ram)
+- xf86UnMapVidMem(scrnIndex, qxl->ram, (1 << qxl->pci->size[0]));
+- if (qxl->vram)
+- xf86UnMapVidMem(scrnIndex, qxl->vram, (1 << qxl->pci->size[1]));
+- if (qxl->rom)
+- xf86UnMapVidMem(scrnIndex, qxl->rom, (1 << qxl->pci->size[2]));
++ if (compat_qxl->ram)
++ xf86UnMapVidMem(scrnIndex, compat_qxl->ram, (1 << compat_qxl->pci->size[0]));
++ if (compat_qxl->vram)
++ xf86UnMapVidMem(scrnIndex, compat_qxl->vram, (1 << compat_qxl->pci->size[1]));
++ if (compat_qxl->rom)
++ xf86UnMapVidMem(scrnIndex, compat_qxl->rom, (1 << compat_qxl->pci->size[2]));
+ #endif
--struct qxl_ring_header {
-+struct compat_qxl_ring_header {
- uint32_t num_items;
- uint32_t prod;
- uint32_t notify_on_prod;
-@@ -454,38 +454,38 @@ struct qxl_ring_header {
+- qxl->ram = qxl->ram_physical = qxl->vram = qxl->rom = NULL;
++ compat_qxl->ram = compat_qxl->ram_physical = compat_qxl->vram = compat_qxl->rom = NULL;
- #define QXL_LOG_BUF_SIZE 4096
+- qxl->num_modes = 0;
+- qxl->modes = NULL;
++ compat_qxl->num_modes = 0;
++ compat_qxl->modes = NULL;
+ }
--struct qxl_ram_header {
-+struct compat_qxl_ram_header {
- uint32_t magic;
- uint32_t int_pending;
- uint32_t int_mask;
- unsigned char log_buf[QXL_LOG_BUF_SIZE];
-- struct qxl_ring_header cmd_ring_hdr;
-- struct qxl_command cmd_ring[32];
-- struct qxl_ring_header cursor_ring_hdr;
-- struct qxl_command cursor_ring[32];
-- struct qxl_ring_header release_ring_hdr;
-+ struct compat_qxl_ring_header cmd_ring_hdr;
-+ struct compat_qxl_command cmd_ring[32];
-+ struct compat_qxl_ring_header cursor_ring_hdr;
-+ struct compat_qxl_command cursor_ring[32];
-+ struct compat_qxl_ring_header release_ring_hdr;
- uint64_t release_ring[8];
-- struct qxl_rect update_area;
-+ struct compat_qxl_rect update_area;
- };
+ static Bool
+-qxl_map_memory(qxl_screen_t *qxl, int scrnIndex)
++compat_qxl_map_memory(compat_qxl_screen_t *compat_qxl, int scrnIndex)
+ {
+ #ifdef XSERVER_LIBPCIACCESS
+- pci_device_map_range(qxl->pci, qxl->pci->regions[0].base_addr,
+- qxl->pci->regions[0].size,
++ pci_device_map_range(compat_qxl->pci, compat_qxl->pci->regions[0].base_addr,
++ compat_qxl->pci->regions[0].size,
+ PCI_DEV_MAP_FLAG_WRITABLE | PCI_DEV_MAP_FLAG_WRITE_COMBINE,
+- &qxl->ram);
+- qxl->ram_physical = u64_to_pointer (qxl->pci->regions[0].base_addr);
++ &compat_qxl->ram);
++ compat_qxl->ram_physical = u64_to_pointer (compat_qxl->pci->regions[0].base_addr);
- #pragma pack(pop)
+- pci_device_map_range(qxl->pci, qxl->pci->regions[1].base_addr,
+- qxl->pci->regions[1].size,
++ pci_device_map_range(compat_qxl->pci, compat_qxl->pci->regions[1].base_addr,
++ compat_qxl->pci->regions[1].size,
+ PCI_DEV_MAP_FLAG_WRITABLE,
+- &qxl->vram);
++ &compat_qxl->vram);
--typedef struct _qxl_screen_t qxl_screen_t;
-+typedef struct _compat_qxl_screen_t compat_qxl_screen_t;
+- pci_device_map_range(qxl->pci, qxl->pci->regions[2].base_addr,
+- qxl->pci->regions[2].size, 0,
+- (void **)&qxl->rom);
++ pci_device_map_range(compat_qxl->pci, compat_qxl->pci->regions[2].base_addr,
++ compat_qxl->pci->regions[2].size, 0,
++ (void **)&compat_qxl->rom);
--struct _qxl_screen_t
-+struct _compat_qxl_screen_t
- {
- /* These are the names QXL uses */
- void * ram; /* Video RAM */
- void * ram_physical;
- void * vram; /* Command RAM */
-- struct qxl_rom * rom; /* Parameter RAM */
-+ struct compat_qxl_rom * rom; /* Parameter RAM */
-
-- struct qxl_ring * command_ring;
-- struct qxl_ring * cursor_ring;
-- struct qxl_ring * release_ring;
-+ struct compat_qxl_ring * command_ring;
-+ struct compat_qxl_ring * cursor_ring;
-+ struct compat_qxl_ring * release_ring;
+- qxl->io_base = qxl->pci->regions[3].base_addr;
++ compat_qxl->io_base = compat_qxl->pci->regions[3].base_addr;
+ #else
+- qxl->ram = xf86MapPciMem(scrnIndex, VIDMEM_FRAMEBUFFER,
+- qxl->pci_tag, qxl->pci->memBase[0],
+- (1 << qxl->pci->size[0]));
+- qxl->ram_physical = (void *)qxl->pci->memBase[0];
+-
+- qxl->vram = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
+- qxl->pci_tag, qxl->pci->memBase[1],
+- (1 << qxl->pci->size[1]));
+-
+- qxl->rom = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
+- qxl->pci_tag, qxl->pci->memBase[2],
+- (1 << qxl->pci->size[2]));
++ compat_qxl->ram = xf86MapPciMem(scrnIndex, VIDMEM_FRAMEBUFFER,
++ compat_qxl->pci_tag, compat_qxl->pci->memBase[0],
++ (1 << compat_qxl->pci->size[0]));
++ compat_qxl->ram_physical = (void *)compat_qxl->pci->memBase[0];
++
++ compat_qxl->vram = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
++ compat_qxl->pci_tag, compat_qxl->pci->memBase[1],
++ (1 << compat_qxl->pci->size[1]));
++
++ compat_qxl->rom = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
++ compat_qxl->pci_tag, compat_qxl->pci->memBase[2],
++ (1 << compat_qxl->pci->size[2]));
- int num_modes;
-- struct qxl_mode * modes;
-+ struct compat_qxl_mode * modes;
- int io_base;
- int draw_area_offset;
- int draw_area_size;
-@@ -493,7 +493,7 @@ struct _qxl_screen_t
- void * fb;
- int bytes_per_pixel;
+- qxl->io_base = qxl->pci->ioBase[3];
++ compat_qxl->io_base = compat_qxl->pci->ioBase[3];
+ #endif
+- if (!qxl->ram || !qxl->vram || !qxl->rom)
++ if (!compat_qxl->ram || !compat_qxl->vram || !compat_qxl->rom)
+ return FALSE;
-- struct qxl_mem * mem; /* Context for qxl_alloc/free */
-+ struct compat_qxl_mem * mem; /* Context for compat_qxl_alloc/free */
-
- EntityInfoPtr entity;
+ xf86DrvMsg(scrnIndex, X_INFO, "ram at %p; vram at %p; rom at %p\n",
+- qxl->ram, qxl->vram, qxl->rom);
++ compat_qxl->ram, compat_qxl->vram, compat_qxl->rom);
-@@ -530,15 +530,15 @@ struct _qxl_screen_t
- };
+- qxl->num_modes = *(uint32_t *)((uint8_t *)qxl->rom + qxl->rom->modes_offset);
+- qxl->modes = (struct qxl_mode *)(((uint8_t *)qxl->rom) + qxl->rom->modes_offset + 4);
++ compat_qxl->num_modes = *(uint32_t *)((uint8_t *)compat_qxl->rom + compat_qxl->rom->modes_offset);
++ compat_qxl->modes = (struct compat_qxl_mode *)(((uint8_t *)compat_qxl->rom) + compat_qxl->rom->modes_offset + 4);
- static inline uint64_t
--physical_address (qxl_screen_t *qxl, void *virtual)
-+physical_address (compat_qxl_screen_t *compat_qxl, void *virtual)
- {
-- return (uint64_t) ((unsigned long)virtual + (((unsigned long)qxl->ram_physical - (unsigned long)qxl->ram)));
-+ return (uint64_t) ((unsigned long)virtual + (((unsigned long)compat_qxl->ram_physical - (unsigned long)compat_qxl->ram)));
+ return TRUE;
}
- static inline void *
--virtual_address (qxl_screen_t *qxl, void *physical)
-+virtual_address (compat_qxl_screen_t *compat_qxl, void *physical)
+ static void
+-qxl_save_state(ScrnInfoPtr pScrn)
++compat_qxl_save_state(ScrnInfoPtr pScrn)
{
-- return (void *) ((unsigned long)physical + ((unsigned long)qxl->ram - (unsigned long)qxl->ram_physical));
-+ return (void *) ((unsigned long)physical + ((unsigned long)compat_qxl->ram - (unsigned long)compat_qxl->ram_physical));
- }
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- static inline void *
-@@ -553,58 +553,58 @@ pointer_to_u64 (void *p)
- return (uint64_t)(unsigned long)p;
+- vgaHWSaveFonts(pScrn, &qxl->vgaRegs);
++ vgaHWSaveFonts(pScrn, &compat_qxl->vgaRegs);
}
--struct qxl_ring;
-+struct compat_qxl_ring;
+ static void
+-qxl_restore_state(ScrnInfoPtr pScrn)
++compat_qxl_restore_state(ScrnInfoPtr pScrn)
+ {
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- /*
- * HW cursor
- */
--void qxl_cursor_init (ScreenPtr pScreen);
-+void compat_qxl_cursor_init (ScreenPtr pScreen);
+- vgaHWRestoreFonts(pScrn, &qxl->vgaRegs);
++ vgaHWRestoreFonts(pScrn, &compat_qxl->vgaRegs);
+ }
+ static Bool
+-qxl_close_screen(int scrnIndex, ScreenPtr pScreen)
++compat_qxl_close_screen(int scrnIndex, ScreenPtr pScreen)
+ {
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+ if (pScrn->vtSema) {
+- qxl_restore_state(pScrn);
+- qxl_unmap_memory(qxl, scrnIndex);
++ compat_qxl_restore_state(pScrn);
++ compat_qxl_unmap_memory(compat_qxl, scrnIndex);
+ }
+ pScrn->vtSema = FALSE;
- /*
- * Rings
- */
--struct qxl_ring * qxl_ring_create (struct qxl_ring_header *header,
-+struct compat_qxl_ring * compat_qxl_ring_create (struct compat_qxl_ring_header *header,
- int element_size,
- int n_elements,
- int prod_notify);
--void qxl_ring_push (struct qxl_ring *ring,
-+void compat_qxl_ring_push (struct compat_qxl_ring *ring,
- const void *element);
--Bool qxl_ring_pop (struct qxl_ring *ring,
-+Bool compat_qxl_ring_pop (struct compat_qxl_ring *ring,
- void *element);
--void qxl_ring_wait_idle (struct qxl_ring *ring);
-+void compat_qxl_ring_wait_idle (struct compat_qxl_ring *ring);
+- xfree(qxl->fb);
++ xfree(compat_qxl->fb);
+- pScreen->CreateScreenResources = qxl->create_screen_resources;
+- pScreen->CloseScreen = qxl->close_screen;
++ pScreen->CreateScreenResources = compat_qxl->create_screen_resources;
++ pScreen->CloseScreen = compat_qxl->close_screen;
+ return pScreen->CloseScreen(scrnIndex, pScreen);
+ }
- /*
- * Images
- */
--struct qxl_image *qxl_image_create (qxl_screen_t *qxl,
-+struct compat_qxl_image *compat_qxl_image_create (compat_qxl_screen_t *compat_qxl,
- const uint8_t *data,
- int x,
- int y,
- int width,
- int height,
- int stride);
--void qxl_image_destroy (qxl_screen_t *qxl,
-- struct qxl_image *image);
--void qxl_drop_image_cache (qxl_screen_t *qxl);
-+void compat_qxl_image_destroy (compat_qxl_screen_t *compat_qxl,
-+ struct compat_qxl_image *image);
-+void compat_qxl_drop_image_cache (compat_qxl_screen_t *compat_qxl);
+ static Bool
+-qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
++compat_qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
+ {
+- qxl_screen_t *qxl = xf86Screens[scrnIndex]->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = xf86Screens[scrnIndex]->driverPrivate;
+ int mode_index = (int)(unsigned long)p->Private;
+- struct qxl_mode *m = qxl->modes + mode_index;
+- ScreenPtr pScreen = qxl->pScrn->pScreen;
++ struct compat_qxl_mode *m = compat_qxl->modes + mode_index;
++ ScreenPtr pScreen = compat_qxl->pScrn->pScreen;
+ if (!m)
+ return FALSE;
+@@ -294,11 +294,11 @@ qxl_switch_mode(int scrnIndex, DisplayMo
+ xf86DrvMsg (scrnIndex, X_INFO, "Setting mode %d (%d x %d) (%d x %d) %p\n",
+ m->id, m->x_res, m->y_res, p->HDisplay, p->VDisplay, p);
- /*
- * Malloc
- */
--struct qxl_mem * qxl_mem_create (void *base,
-+struct compat_qxl_mem * compat_qxl_mem_create (void *base,
- unsigned long n_bytes);
--void qxl_mem_dump_stats (struct qxl_mem *mem,
-+void compat_qxl_mem_dump_stats (struct compat_qxl_mem *mem,
- const char *header);
--void * qxl_alloc (struct qxl_mem *mem,
-+void * compat_qxl_alloc (struct compat_qxl_mem *mem,
- unsigned long n_bytes);
--void qxl_free (struct qxl_mem *mem,
-+void compat_qxl_free (struct compat_qxl_mem *mem,
- void *d);
--void qxl_mem_free_all (struct qxl_mem *mem);
--void * qxl_allocnf (qxl_screen_t *qxl,
-+void compat_qxl_mem_free_all (struct compat_qxl_mem *mem);
-+void * compat_qxl_allocnf (compat_qxl_screen_t *compat_qxl,
- unsigned long size);
+- outb(qxl->io_base + QXL_IO_RESET, 0);
++ outb(compat_qxl->io_base + QXL_IO_RESET, 0);
+
+- outb(qxl->io_base + QXL_IO_SET_MODE, m->id);
++ outb(compat_qxl->io_base + QXL_IO_SET_MODE, m->id);
+- qxl->bytes_per_pixel = (qxl->pScrn->bitsPerPixel + 7) / 8;
++ compat_qxl->bytes_per_pixel = (compat_qxl->pScrn->bitsPerPixel + 7) / 8;
-diff --git a/src/compat/compat-qxl_cursor.c b/src/compat/compat-qxl_cursor.c
-index bb5387e..e94eb6a 100644
---- a/src/compat/compat-qxl_cursor.c
-+++ b/src/compat/compat-qxl_cursor.c
-@@ -25,25 +25,25 @@
- #include <cursorstr.h>
+ /* If this happens out of ScreenInit, we won't have a screen yet. In that
+ * case createScreenResources will make things right.
+@@ -313,15 +313,15 @@ qxl_switch_mode(int scrnIndex, DisplayMo
+ pPixmap,
+ m->x_res, m->y_res,
+ -1, -1,
+- qxl->pScrn->displayWidth * qxl->bytes_per_pixel,
++ compat_qxl->pScrn->displayWidth * compat_qxl->bytes_per_pixel,
+ NULL);
+ }
+ }
+
+- if (qxl->mem)
++ if (compat_qxl->mem)
+ {
+- qxl_mem_free_all (qxl->mem);
+- qxl_drop_image_cache (qxl);
++ compat_qxl_mem_free_all (compat_qxl->mem);
++ compat_qxl_drop_image_cache (compat_qxl);
+ }
+
+
+@@ -329,9 +329,9 @@ qxl_switch_mode(int scrnIndex, DisplayMo
+ }
static void
--push_cursor (qxl_screen_t *qxl, struct qxl_cursor_cmd *cursor)
-+push_cursor (compat_qxl_screen_t *compat_qxl, struct compat_qxl_cursor_cmd *cursor)
+-push_drawable (qxl_screen_t *qxl, struct qxl_drawable *drawable)
++push_drawable (compat_qxl_screen_t *compat_qxl, struct compat_qxl_drawable *drawable)
{
- struct qxl_command cmd;
+ struct compat_qxl_command cmd;
-- /* See comment on push_command() in qxl_driver.c */
+ /* When someone runs "init 3", the device will be
+ * switched into VGA mode and there is nothing we
+@@ -345,25 +345,25 @@ push_drawable (qxl_screen_t *qxl, struct
+ * The author of the QXL device is opposed to this
+ * for reasons I don't understand.
+ */
- if (qxl->rom->mode != ~0)
-+ /* See comment on push_command() in compat_qxl_driver.c */
+ if (compat_qxl->rom->mode != ~0)
{
- cmd.type = QXL_CMD_CURSOR;
-- cmd.data = physical_address (qxl, cursor);
-+ cmd.data = physical_address (compat_qxl, cursor);
-
-- qxl_ring_push (qxl->cursor_ring, &cmd);
-+ compat_qxl_ring_push (compat_qxl->cursor_ring, &cmd);
+ cmd.type = QXL_CMD_DRAW;
+- cmd.data = physical_address (qxl, drawable);
++ cmd.data = physical_address (compat_qxl, drawable);
+
+- qxl_ring_push (qxl->command_ring, &cmd);
++ compat_qxl_ring_push (compat_qxl->command_ring, &cmd);
}
}
--static struct qxl_cursor_cmd *
--qxl_alloc_cursor_cmd(qxl_screen_t *qxl)
-+static struct compat_qxl_cursor_cmd *
-+compat_qxl_alloc_cursor_cmd(compat_qxl_screen_t *compat_qxl)
+-static struct qxl_drawable *
+-make_drawable (qxl_screen_t *qxl, uint8_t type,
+- const struct qxl_rect *rect
++static struct compat_qxl_drawable *
++make_drawable (compat_qxl_screen_t *compat_qxl, uint8_t type,
++ const struct compat_qxl_rect *rect
+ /* , pRegion clip */)
{
-- struct qxl_cursor_cmd *cmd =
-- qxl_allocnf (qxl, sizeof(struct qxl_cursor_cmd));
-+ struct compat_qxl_cursor_cmd *cmd =
-+ compat_qxl_allocnf (compat_qxl, sizeof(struct compat_qxl_cursor_cmd));
+- struct qxl_drawable *drawable;
++ struct compat_qxl_drawable *drawable;
- cmd->release_info.id = pointer_to_u64 (cmd) | 1;
+ CHECK_POINT();
-@@ -51,43 +51,43 @@ qxl_alloc_cursor_cmd(qxl_screen_t *qxl)
- }
+- drawable = qxl_allocnf (qxl, sizeof *drawable);
++ drawable = compat_qxl_allocnf (compat_qxl, sizeof *drawable);
- static void
--qxl_set_cursor_position(ScrnInfoPtr pScrn, int x, int y)
-+compat_qxl_set_cursor_position(ScrnInfoPtr pScrn, int x, int y)
- {
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-- struct qxl_cursor_cmd *cmd = qxl_alloc_cursor_cmd(qxl);
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
-+ struct compat_qxl_cursor_cmd *cmd = compat_qxl_alloc_cursor_cmd(compat_qxl);
+ CHECK_POINT();
-- qxl->cur_x = x;
-- qxl->cur_y = y;
-+ compat_qxl->cur_x = x;
-+ compat_qxl->cur_y = y;
-
- cmd->type = QXL_CURSOR_MOVE;
-- cmd->u.position.x = qxl->cur_x + qxl->hot_x;
-- cmd->u.position.y = qxl->cur_y + qxl->hot_y;
-+ cmd->u.position.x = compat_qxl->cur_x + compat_qxl->hot_x;
-+ cmd->u.position.y = compat_qxl->cur_y + compat_qxl->hot_y;
+@@ -383,7 +383,7 @@ make_drawable (qxl_screen_t *qxl, uint8_
+ if (rect)
+ drawable->bbox = *rect;
-- push_cursor(qxl, cmd);
-+ push_cursor(compat_qxl, cmd);
- }
+- drawable->mm_time = qxl->rom->mm_clock;
++ drawable->mm_time = compat_qxl->rom->mm_clock;
+
+ CHECK_POINT();
+
+@@ -405,7 +405,7 @@ enum ROPDescriptor {
+ };
static void
--qxl_load_cursor_image(ScrnInfoPtr pScrn, unsigned char *bits)
-+compat_qxl_load_cursor_image(ScrnInfoPtr pScrn, unsigned char *bits)
+-undamage_box (qxl_screen_t *qxl, const struct qxl_rect *rect)
++undamage_box (compat_qxl_screen_t *compat_qxl, const struct compat_qxl_rect *rect)
{
+ RegionRec region;
+ BoxRec box;
+@@ -415,27 +415,27 @@ undamage_box (qxl_screen_t *qxl, const s
+ box.x2 = rect->right;
+ box.y2 = rect->bottom;
+
+- REGION_INIT (qxl->pScrn->pScreen, ®ion, &box, 0);
++ REGION_INIT (compat_qxl->pScrn->pScreen, ®ion, &box, 0);
+
+- REGION_SUBTRACT (qxl->pScrn->pScreen, &(qxl->pending_copy), &(qxl->pending_copy), ®ion);
++ REGION_SUBTRACT (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy), &(compat_qxl->pending_copy), ®ion);
+
+- REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
++ REGION_EMPTY (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy));
}
static void
--qxl_set_cursor_colors(ScrnInfoPtr pScrn, int bg, int fg)
-+compat_qxl_set_cursor_colors(ScrnInfoPtr pScrn, int bg, int fg)
+-clear_pending_damage (qxl_screen_t *qxl)
++clear_pending_damage (compat_qxl_screen_t *compat_qxl)
{
- /* Should not be called since UseHWCursor returned FALSE */
+- REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
++ REGION_EMPTY (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy));
}
static void
--qxl_load_cursor_argb (ScrnInfoPtr pScrn, CursorPtr pCurs)
-+compat_qxl_load_cursor_argb (ScrnInfoPtr pScrn, CursorPtr pCurs)
+-submit_fill (qxl_screen_t *qxl, const struct qxl_rect *rect, uint32_t color)
++submit_fill (compat_qxl_screen_t *compat_qxl, const struct compat_qxl_rect *rect, uint32_t color)
{
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- int w = pCurs->bits->width;
- int h = pCurs->bits->height;
- int size = w * h * sizeof (CARD32);
+- struct qxl_drawable *drawable;
++ struct compat_qxl_drawable *drawable;
-- struct qxl_cursor_cmd *cmd = qxl_alloc_cursor_cmd (qxl);
-- struct qxl_cursor *cursor =
-- qxl_allocnf(qxl, sizeof(struct qxl_cursor) + size);
-+ struct compat_qxl_cursor_cmd *cmd = compat_qxl_alloc_cursor_cmd (compat_qxl);
-+ struct compat_qxl_cursor *cursor =
-+ compat_qxl_allocnf(compat_qxl, sizeof(struct compat_qxl_cursor) + size);
+ CHECK_POINT();
+
+- drawable = make_drawable (qxl, QXL_DRAW_FILL, rect);
++ drawable = make_drawable (compat_qxl, QXL_DRAW_FILL, rect);
- cursor->header.unique = 0;
- cursor->header.type = CURSOR_TYPE_ALPHA;
-@@ -121,20 +121,20 @@ qxl_load_cursor_argb (ScrnInfoPtr pScrn, CursorPtr pCurs)
- }
- #endif
+ CHECK_POINT();
-- qxl->hot_x = pCurs->bits->xhot;
-- qxl->hot_y = pCurs->bits->yhot;
-+ compat_qxl->hot_x = pCurs->bits->xhot;
-+ compat_qxl->hot_y = pCurs->bits->yhot;
-
- cmd->type = QXL_CURSOR_SET;
-- cmd->u.set.position.x = qxl->cur_x + qxl->hot_x;
-- cmd->u.set.position.y = qxl->cur_y + qxl->hot_y;
-- cmd->u.set.shape = physical_address (qxl, cursor);
-+ cmd->u.set.position.x = compat_qxl->cur_x + compat_qxl->hot_x;
-+ cmd->u.set.position.y = compat_qxl->cur_y + compat_qxl->hot_y;
-+ cmd->u.set.shape = physical_address (compat_qxl, cursor);
- cmd->u.set.visible = TRUE;
+@@ -447,13 +447,13 @@ submit_fill (qxl_screen_t *qxl, const st
+ drawable->u.fill.mask.pos.y = 0;
+ drawable->u.fill.mask.bitmap = 0;
-- push_cursor(qxl, cmd);
-+ push_cursor(compat_qxl, cmd);
- }
+- push_drawable (qxl, drawable);
++ push_drawable (compat_qxl, drawable);
- static Bool
--qxl_use_hw_cursor (ScreenPtr pScrn, CursorPtr pCurs)
-+compat_qxl_use_hw_cursor (ScreenPtr pScrn, CursorPtr pCurs)
- {
- /* Old-school bitmap cursors are not
- * hardware accelerated for now.
-@@ -143,36 +143,36 @@ qxl_use_hw_cursor (ScreenPtr pScrn, CursorPtr pCurs)
+- undamage_box (qxl, rect);
++ undamage_box (compat_qxl, rect);
}
- static Bool
--qxl_use_hw_cursorARGB (ScreenPtr pScrn, CursorPtr pCurs)
-+compat_qxl_use_hw_cursorARGB (ScreenPtr pScrn, CursorPtr pCurs)
+ static void
+-translate_rect (struct qxl_rect *rect)
++translate_rect (struct compat_qxl_rect *rect)
{
- return TRUE;
+ rect->right -= rect->left;
+ rect->bottom -= rect->top;
+@@ -461,10 +461,10 @@ translate_rect (struct qxl_rect *rect)
}
static void
--qxl_hide_cursor(ScrnInfoPtr pScrn)
-+compat_qxl_hide_cursor(ScrnInfoPtr pScrn)
+-submit_copy (qxl_screen_t *qxl, const struct qxl_rect *rect)
++submit_copy (compat_qxl_screen_t *compat_qxl, const struct compat_qxl_rect *rect)
{
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-- struct qxl_cursor_cmd *cursor = qxl_alloc_cursor_cmd(qxl);
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
-+ struct compat_qxl_cursor_cmd *cursor = compat_qxl_alloc_cursor_cmd(compat_qxl);
+- struct qxl_drawable *drawable;
+- ScrnInfoPtr pScrn = qxl->pScrn;
++ struct compat_qxl_drawable *drawable;
++ ScrnInfoPtr pScrn = compat_qxl->pScrn;
+
+ if (rect->left == rect->right ||
+ rect->top == rect->bottom)
+@@ -473,13 +473,13 @@ submit_copy (qxl_screen_t *qxl, const st
+ return ;
+ }
+
+- drawable = make_drawable (qxl, QXL_DRAW_COPY, rect);
++ drawable = make_drawable (compat_qxl, QXL_DRAW_COPY, rect);
+
+ drawable->u.copy.src_bitmap = physical_address (
+- qxl, qxl_image_create (qxl, qxl->fb, rect->left, rect->top,
++ compat_qxl, compat_qxl_image_create (compat_qxl, compat_qxl->fb, rect->left, rect->top,
+ rect->right - rect->left,
+ rect->bottom - rect->top,
+- pScrn->displayWidth * qxl->bytes_per_pixel));
++ pScrn->displayWidth * compat_qxl->bytes_per_pixel));
+ drawable->u.copy.src_area = *rect;
+ translate_rect (&drawable->u.copy.src_area);
+ drawable->u.copy.rop_descriptor = ROPD_OP_PUT;
+@@ -489,7 +489,7 @@ submit_copy (qxl_screen_t *qxl, const st
+ drawable->u.copy.mask.pos.y = 0;
+ drawable->u.copy.mask.bitmap = 0;
- cursor->type = QXL_CURSOR_HIDE;
+- push_drawable (qxl, drawable);
++ push_drawable (compat_qxl, drawable);
+ }
-- push_cursor(qxl, cursor);
-+ push_cursor(compat_qxl, cursor);
+ static void
+@@ -511,87 +511,87 @@ print_region (const char *header, Region
}
static void
--qxl_show_cursor(ScrnInfoPtr pScrn)
-+compat_qxl_show_cursor(ScrnInfoPtr pScrn)
+-accept_damage (qxl_screen_t *qxl)
++accept_damage (compat_qxl_screen_t *compat_qxl)
{
- /*
- * slightly hacky, but there's no QXL_CURSOR_SHOW. Could maybe do
- * QXL_CURSOR_SET?
- */
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+- REGION_UNION (qxl->pScrn->pScreen, &(qxl->to_be_sent), &(qxl->to_be_sent),
+- &(qxl->pending_copy));
++ REGION_UNION (compat_qxl->pScrn->pScreen, &(compat_qxl->to_be_sent), &(compat_qxl->to_be_sent),
++ &(compat_qxl->pending_copy));
-- qxl_set_cursor_position(pScrn, qxl->cur_x, qxl->cur_y);
-+ compat_qxl_set_cursor_position(pScrn, compat_qxl->cur_x, compat_qxl->cur_y);
+- REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
++ REGION_EMPTY (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy));
}
- hidden void
--qxl_cursor_init(ScreenPtr pScreen)
-+compat_qxl_cursor_init(ScreenPtr pScreen)
+ static void
+-qxl_send_copies (qxl_screen_t *qxl)
++compat_qxl_send_copies (compat_qxl_screen_t *compat_qxl)
{
- xf86CursorInfoPtr cursor;
+ BoxPtr pBox;
+ int nbox;
-@@ -182,14 +182,14 @@ qxl_cursor_init(ScreenPtr pScreen)
+- nbox = REGION_NUM_RECTS (&qxl->to_be_sent);
+- pBox = REGION_RECTS (&qxl->to_be_sent);
++ nbox = REGION_NUM_RECTS (&compat_qxl->to_be_sent);
++ pBox = REGION_RECTS (&compat_qxl->to_be_sent);
- cursor->MaxWidth = cursor->MaxHeight = 64;
- /* cursor->Flags; */
-- cursor->SetCursorPosition = qxl_set_cursor_position;
-- cursor->LoadCursorARGB = qxl_load_cursor_argb;
-- cursor->UseHWCursor = qxl_use_hw_cursor;
-- cursor->UseHWCursorARGB = qxl_use_hw_cursorARGB;
-- cursor->LoadCursorImage = qxl_load_cursor_image;
-- cursor->SetCursorColors = qxl_set_cursor_colors;
-- cursor->HideCursor = qxl_hide_cursor;
-- cursor->ShowCursor = qxl_show_cursor;
-+ cursor->SetCursorPosition = compat_qxl_set_cursor_position;
-+ cursor->LoadCursorARGB = compat_qxl_load_cursor_argb;
-+ cursor->UseHWCursor = compat_qxl_use_hw_cursor;
-+ cursor->UseHWCursorARGB = compat_qxl_use_hw_cursorARGB;
-+ cursor->LoadCursorImage = compat_qxl_load_cursor_image;
-+ cursor->SetCursorColors = compat_qxl_set_cursor_colors;
-+ cursor->HideCursor = compat_qxl_hide_cursor;
-+ cursor->ShowCursor = compat_qxl_show_cursor;
+-/* if (REGION_NUM_RECTS (&qxl->to_be_sent) > 0) */
+-/* print_region ("send bits", &qxl->to_be_sent); */
++/* if (REGION_NUM_RECTS (&compat_qxl->to_be_sent) > 0) */
++/* print_region ("send bits", &compat_qxl->to_be_sent); */
+
+ while (nbox--)
+ {
+- struct qxl_rect qrect;
++ struct compat_qxl_rect qrect;
- if (!xf86InitCursor(pScreen, cursor))
- xfree(cursor);
-diff --git a/src/compat/compat-qxl_driver.c b/src/compat/compat-qxl_driver.c
-index 7cd5f40..758ee24 100644
---- a/src/compat/compat-qxl_driver.c
-+++ b/src/compat/compat-qxl_driver.c
-@@ -20,10 +20,10 @@
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
+ qrect.top = pBox->y1;
+ qrect.left = pBox->x1;
+ qrect.bottom = pBox->y2;
+ qrect.right = pBox->x2;
+
+- submit_copy (qxl, &qrect);
++ submit_copy (compat_qxl, &qrect);
--/** \file qxl_driver.c
-+/** \file compat_qxl_driver.c
- * \author Adam Jackson <ajax at redhat.com>
- *
-- * This is qxl, a driver for the Qumranet paravirtualized graphics device
-+ * This is compat_qxl, a driver for the Qumranet paravirtualized graphics device
- * in qemu.
- */
+ pBox++;
+ }
-@@ -39,12 +39,12 @@
- #define CHECK_POINT()
+- REGION_EMPTY(qxl->pScrn->pScreen, &qxl->to_be_sent);
++ REGION_EMPTY(compat_qxl->pScrn->pScreen, &compat_qxl->to_be_sent);
+ }
- static int
--garbage_collect (qxl_screen_t *qxl)
-+garbage_collect (compat_qxl_screen_t *compat_qxl)
+ static void
+-paint_shadow (qxl_screen_t *qxl)
++paint_shadow (compat_qxl_screen_t *compat_qxl)
{
- uint64_t id;
- int i = 0;
-
-- while (qxl_ring_pop (qxl->release_ring, &id))
-+ while (compat_qxl_ring_pop (compat_qxl->release_ring, &id))
- {
- while (id)
- {
-@@ -54,9 +54,9 @@ garbage_collect (qxl_screen_t *qxl)
- */
- #define POINTER_MASK ((1 << 2) - 1)
-
-- union qxl_release_info *info = u64_to_pointer (id & ~POINTER_MASK);
-- struct qxl_cursor_cmd *cmd = (struct qxl_cursor_cmd *)info;
-- struct qxl_drawable *drawable = (struct qxl_drawable *)info;
-+ union compat_qxl_release_info *info = u64_to_pointer (id & ~POINTER_MASK);
-+ struct compat_qxl_cursor_cmd *cmd = (struct compat_qxl_cursor_cmd *)info;
-+ struct compat_qxl_drawable *drawable = (struct compat_qxl_drawable *)info;
- int is_cursor = FALSE;
+- struct qxl_rect qrect;
++ struct compat_qxl_rect qrect;
- if ((id & POINTER_MASK) == 1)
-@@ -64,22 +64,22 @@ garbage_collect (qxl_screen_t *qxl)
+ qrect.top = 0;
+ qrect.bottom = 1200;
+ qrect.left = 0;
+ qrect.right = 1600;
- if (is_cursor && cmd->type == QXL_CURSOR_SET)
- {
-- struct qxl_cursor *cursor = (void *)virtual_address (
-- qxl, u64_to_pointer (cmd->u.set.shape));
-+ struct compat_qxl_cursor *cursor = (void *)virtual_address (
-+ compat_qxl, u64_to_pointer (cmd->u.set.shape));
+- submit_copy (qxl, &qrect);
++ submit_copy (compat_qxl, &qrect);
+ }
-- qxl_free (qxl->mem, cursor);
-+ compat_qxl_free (compat_qxl->mem, cursor);
- }
- else if (!is_cursor && drawable->type == QXL_DRAW_COPY)
- {
-- struct qxl_image *image = virtual_address (
-- qxl, u64_to_pointer (drawable->u.copy.src_bitmap));
-+ struct compat_qxl_image *image = virtual_address (
-+ compat_qxl, u64_to_pointer (drawable->u.copy.src_bitmap));
+ static void
+-qxl_sanity_check (qxl_screen_t *qxl)
++compat_qxl_sanity_check (compat_qxl_screen_t *compat_qxl)
+ {
+ /* read the mode back from the rom */
+- if (!qxl->rom || !qxl->pScrn)
++ if (!compat_qxl->rom || !compat_qxl->pScrn)
+ return;
-- qxl_image_destroy (qxl, image);
-+ compat_qxl_image_destroy (compat_qxl, image);
- }
-
- id = info->next;
-
-- qxl_free (qxl->mem, info);
-+ compat_qxl_free (compat_qxl->mem, info);
- }
+- if (qxl->rom->mode == ~0)
++ if (compat_qxl->rom->mode == ~0)
+ {
+ ErrorF("QXL device jumped back to VGA mode - resetting mode\n");
+- qxl_switch_mode(qxl->pScrn->scrnIndex, qxl->pScrn->currentMode, 0);
++ compat_qxl_switch_mode(compat_qxl->pScrn->scrnIndex, compat_qxl->pScrn->currentMode, 0);
}
-
-@@ -87,7 +87,7 @@ garbage_collect (qxl_screen_t *qxl)
}
static void
--qxl_usleep (int useconds)
-+compat_qxl_usleep (int useconds)
+-qxl_block_handler (pointer data, OSTimePtr pTimeout, pointer pRead)
++compat_qxl_block_handler (pointer data, OSTimePtr pTimeout, pointer pRead)
{
- struct timespec t;
+- qxl_screen_t *qxl = (qxl_screen_t *) data;
++ compat_qxl_screen_t *compat_qxl = (compat_qxl_screen_t *) data;
-@@ -102,35 +102,35 @@ qxl_usleep (int useconds)
+- if (!qxl->pScrn->vtSema)
++ if (!compat_qxl->pScrn->vtSema)
+ return;
- #if 0
- static void
--push_update_area (qxl_screen_t *qxl, const struct qxl_rect *area)
-+push_update_area (compat_qxl_screen_t *compat_qxl, const struct compat_qxl_rect *area)
- {
-- struct qxl_update_cmd *update = qxl_allocnf (qxl, sizeof *update);
-- struct qxl_command cmd;
-+ struct compat_qxl_update_cmd *update = compat_qxl_allocnf (compat_qxl, sizeof *update);
-+ struct compat_qxl_command cmd;
+- qxl_sanity_check(qxl);
++ compat_qxl_sanity_check(compat_qxl);
- update->release_info.id = (uint64_t)update;
- update->area = *area;
- update->update_id = 0;
+- accept_damage (qxl);
++ accept_damage (compat_qxl);
- cmd.type = QXL_CMD_UDPATE;
-- cmd.data = physical_address (qxl, update);
-+ cmd.data = physical_address (compat_qxl, update);
+- qxl_send_copies (qxl);
++ compat_qxl_send_copies (compat_qxl);
+ }
-- qxl_ring_push (qxl->command_ring, &cmd);
-+ compat_qxl_ring_push (compat_qxl->command_ring, &cmd);
+ static void
+-qxl_wakeup_handler (pointer data, int i, pointer LastSelectMask)
++compat_qxl_wakeup_handler (pointer data, int i, pointer LastSelectMask)
+ {
}
- #endif
- void *
--qxl_allocnf (qxl_screen_t *qxl, unsigned long size)
-+compat_qxl_allocnf (compat_qxl_screen_t *compat_qxl, unsigned long size)
+@@ -612,59 +612,59 @@ qxl_wakeup_handler (pointer data, int i,
+ * damage, that must first be unioned onto to_be_sent, and then the new
+ * damage must be stored in pending_copy.
+ *
+- * The qxl_screen_t struct contains two regions, "pending_copy" and
++ * The compat_qxl_screen_t struct contains two regions, "pending_copy" and
+ * "to_be_sent".
+ *
+ * Pending copy is
+ *
+ */
+ static void
+-qxl_on_damage (DamagePtr pDamage, RegionPtr pRegion, pointer closure)
++compat_qxl_on_damage (DamagePtr pDamage, RegionPtr pRegion, pointer closure)
{
- void *result;
- int n_attempts = 0;
- static int nth_oom = 1;
+- qxl_screen_t *qxl = closure;
++ compat_qxl_screen_t *compat_qxl = closure;
-- garbage_collect (qxl);
-+ garbage_collect (compat_qxl);
+ /* print_region ("damage", pRegion); */
-- while (!(result = qxl_alloc (qxl->mem, size)))
-+ while (!(result = compat_qxl_alloc (compat_qxl->mem, size)))
- {
-- struct qxl_ram_header *ram_header = (void *)((unsigned long)qxl->ram +
-- qxl->rom->ram_header_offset);
-+ struct compat_qxl_ram_header *ram_header = (void *)((unsigned long)compat_qxl->ram +
-+ compat_qxl->rom->ram_header_offset);
-
- /* Rather than go out of memory, we simply tell the
- * device to dump everything
-@@ -140,21 +140,21 @@ qxl_allocnf (qxl_screen_t *qxl, unsigned long size)
- ram_header->update_area.left = 0;
- ram_header->update_area.right = 800;
-
-- outb (qxl->io_base + QXL_IO_UPDATE_AREA, 0);
-+ outb (compat_qxl->io_base + QXL_IO_UPDATE_AREA, 0);
-
- ErrorF ("eliminated memory (%d)\n", nth_oom++);
+ /* print_region ("on_damage ", pRegion); */
-- outb (qxl->io_base + QXL_IO_NOTIFY_OOM, 0);
-+ outb (compat_qxl->io_base + QXL_IO_NOTIFY_OOM, 0);
+- accept_damage (qxl);
++ accept_damage (compat_qxl);
-- qxl_usleep (10000);
-+ compat_qxl_usleep (10000);
-
-- if (garbage_collect (qxl))
-+ if (garbage_collect (compat_qxl))
- {
- n_attempts = 0;
- }
- else if (++n_attempts == 1000)
- {
-- qxl_mem_dump_stats (qxl->mem, "Out of mem - stats\n");
-+ compat_qxl_mem_dump_stats (compat_qxl->mem, "Out of mem - stats\n");
-
- fprintf (stderr, "Out of memory\n");
- exit (1);
-@@ -165,127 +165,127 @@ qxl_allocnf (qxl_screen_t *qxl, unsigned long size)
+-/* print_region ("accepting, qxl->to_be_sent is now", &qxl->to_be_sent); */
++/* print_region ("accepting, compat_qxl->to_be_sent is now", &compat_qxl->to_be_sent); */
+
+- REGION_COPY (qxl->pScrn->pScreen, &(qxl->pending_copy), pRegion);
++ REGION_COPY (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy), pRegion);
}
+
static Bool
--qxl_blank_screen(ScreenPtr pScreen, int mode)
-+compat_qxl_blank_screen(ScreenPtr pScreen, int mode)
+-qxl_create_screen_resources(ScreenPtr pScreen)
++compat_qxl_create_screen_resources(ScreenPtr pScreen)
{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+ Bool ret;
+ PixmapPtr pPixmap;
+
+- pScreen->CreateScreenResources = qxl->create_screen_resources;
++ pScreen->CreateScreenResources = compat_qxl->create_screen_resources;
+ ret = pScreen->CreateScreenResources (pScreen);
+- pScreen->CreateScreenResources = qxl_create_screen_resources;
++ pScreen->CreateScreenResources = compat_qxl_create_screen_resources;
+
+ if (!ret)
+ return FALSE;
+
+- qxl->damage = DamageCreate (qxl_on_damage, NULL,
++ compat_qxl->damage = DamageCreate (compat_qxl_on_damage, NULL,
+ DamageReportRawRegion,
+- TRUE, pScreen, qxl);
++ TRUE, pScreen, compat_qxl);
+
+
+ pPixmap = pScreen->GetScreenPixmap(pScreen);
+
+- if (!RegisterBlockAndWakeupHandlers(qxl_block_handler, qxl_wakeup_handler, qxl))
++ if (!RegisterBlockAndWakeupHandlers(compat_qxl_block_handler, compat_qxl_wakeup_handler, compat_qxl))
+ return FALSE;
+
+- REGION_INIT (pScreen, &(qxl->pending_copy), NullBox, 0);
++ REGION_INIT (pScreen, &(compat_qxl->pending_copy), NullBox, 0);
+
+- REGION_INIT (pScreen, &(qxl->to_be_sent), NullBox, 0);
++ REGION_INIT (pScreen, &(compat_qxl->to_be_sent), NullBox, 0);
+
+- DamageRegister (&pPixmap->drawable, qxl->damage);
++ DamageRegister (&pPixmap->drawable, compat_qxl->damage);
return TRUE;
}
+@@ -686,13 +686,13 @@ get_window_pixmap (DrawablePtr pDrawable
+ }
+
static void
--qxl_unmap_memory(qxl_screen_t *qxl, int scrnIndex)
-+compat_qxl_unmap_memory(compat_qxl_screen_t *compat_qxl, int scrnIndex)
+-qxl_poly_fill_rect (DrawablePtr pDrawable,
++compat_qxl_poly_fill_rect (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrect,
+ xRectangle *prect)
{
- #ifdef XSERVER_LIBPCIACCESS
-- if (qxl->ram)
-- pci_device_unmap_range(qxl->pci, qxl->ram, qxl->pci->regions[0].size);
-- if (qxl->vram)
-- pci_device_unmap_range(qxl->pci, qxl->vram, qxl->pci->regions[1].size);
-- if (qxl->rom)
-- pci_device_unmap_range(qxl->pci, qxl->rom, qxl->pci->regions[2].size);
-+ if (compat_qxl->ram)
-+ pci_device_unmap_range(compat_qxl->pci, compat_qxl->ram, compat_qxl->pci->regions[0].size);
-+ if (compat_qxl->vram)
-+ pci_device_unmap_range(compat_qxl->pci, compat_qxl->vram, compat_qxl->pci->regions[1].size);
-+ if (compat_qxl->rom)
-+ pci_device_unmap_range(compat_qxl->pci, compat_qxl->rom, compat_qxl->pci->regions[2].size);
- #else
-- if (qxl->ram)
-- xf86UnMapVidMem(scrnIndex, qxl->ram, (1 << qxl->pci->size[0]));
-- if (qxl->vram)
-- xf86UnMapVidMem(scrnIndex, qxl->vram, (1 << qxl->pci->size[1]));
-- if (qxl->rom)
-- xf86UnMapVidMem(scrnIndex, qxl->rom, (1 << qxl->pci->size[2]));
-+ if (compat_qxl->ram)
-+ xf86UnMapVidMem(scrnIndex, compat_qxl->ram, (1 << compat_qxl->pci->size[0]));
-+ if (compat_qxl->vram)
-+ xf86UnMapVidMem(scrnIndex, compat_qxl->vram, (1 << compat_qxl->pci->size[1]));
-+ if (compat_qxl->rom)
-+ xf86UnMapVidMem(scrnIndex, compat_qxl->rom, (1 << compat_qxl->pci->size[2]));
- #endif
+ ScrnInfoPtr pScrn = xf86Screens[pDrawable->pScreen->myNum];
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+ PixmapPtr pPixmap;
+ int xoff, yoff;
-- qxl->ram = qxl->ram_physical = qxl->vram = qxl->rom = NULL;
-+ compat_qxl->ram = compat_qxl->ram_physical = compat_qxl->vram = compat_qxl->rom = NULL;
+@@ -714,14 +714,14 @@ qxl_poly_fill_rect (DrawablePtr pDrawabl
-- qxl->num_modes = 0;
-- qxl->modes = NULL;
-+ compat_qxl->num_modes = 0;
-+ compat_qxl->modes = NULL;
- }
+ while (nbox--)
+ {
+- struct qxl_rect qrect;
++ struct compat_qxl_rect qrect;
- static Bool
--qxl_map_memory(qxl_screen_t *qxl, int scrnIndex)
-+compat_qxl_map_memory(compat_qxl_screen_t *compat_qxl, int scrnIndex)
- {
- #ifdef XSERVER_LIBPCIACCESS
-- pci_device_map_range(qxl->pci, qxl->pci->regions[0].base_addr,
-- qxl->pci->regions[0].size,
-+ pci_device_map_range(compat_qxl->pci, compat_qxl->pci->regions[0].base_addr,
-+ compat_qxl->pci->regions[0].size,
- PCI_DEV_MAP_FLAG_WRITABLE | PCI_DEV_MAP_FLAG_WRITE_COMBINE,
-- &qxl->ram);
-- qxl->ram_physical = u64_to_pointer (qxl->pci->regions[0].base_addr);
-+ &compat_qxl->ram);
-+ compat_qxl->ram_physical = u64_to_pointer (compat_qxl->pci->regions[0].base_addr);
+ qrect.left = pBox->x1;
+ qrect.right = pBox->x2;
+ qrect.top = pBox->y1;
+ qrect.bottom = pBox->y2;
-- pci_device_map_range(qxl->pci, qxl->pci->regions[1].base_addr,
-- qxl->pci->regions[1].size,
-+ pci_device_map_range(compat_qxl->pci, compat_qxl->pci->regions[1].base_addr,
-+ compat_qxl->pci->regions[1].size,
- PCI_DEV_MAP_FLAG_WRITABLE,
-- &qxl->vram);
-+ &compat_qxl->vram);
+- submit_fill (qxl, &qrect, pGC->fgPixel);
++ submit_fill (compat_qxl, &qrect, pGC->fgPixel);
-- pci_device_map_range(qxl->pci, qxl->pci->regions[2].base_addr,
-- qxl->pci->regions[2].size, 0,
-- (void **)&qxl->rom);
-+ pci_device_map_range(compat_qxl->pci, compat_qxl->pci->regions[2].base_addr,
-+ compat_qxl->pci->regions[2].size, 0,
-+ (void **)&compat_qxl->rom);
+ pBox++;
+ }
+@@ -733,7 +733,7 @@ qxl_poly_fill_rect (DrawablePtr pDrawabl
+ }
-- qxl->io_base = qxl->pci->regions[3].base_addr;
-+ compat_qxl->io_base = compat_qxl->pci->regions[3].base_addr;
- #else
-- qxl->ram = xf86MapPciMem(scrnIndex, VIDMEM_FRAMEBUFFER,
-- qxl->pci_tag, qxl->pci->memBase[0],
-- (1 << qxl->pci->size[0]));
-- qxl->ram_physical = (void *)qxl->pci->memBase[0];
-+ compat_qxl->ram = xf86MapPciMem(scrnIndex, VIDMEM_FRAMEBUFFER,
-+ compat_qxl->pci_tag, compat_qxl->pci->memBase[0],
-+ (1 << compat_qxl->pci->size[0]));
-+ compat_qxl->ram_physical = (void *)compat_qxl->pci->memBase[0];
-
-- qxl->vram = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
-- qxl->pci_tag, qxl->pci->memBase[1],
-- (1 << qxl->pci->size[1]));
-+ compat_qxl->vram = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
-+ compat_qxl->pci_tag, compat_qxl->pci->memBase[1],
-+ (1 << compat_qxl->pci->size[1]));
-
-- qxl->rom = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
-- qxl->pci_tag, qxl->pci->memBase[2],
-- (1 << qxl->pci->size[2]));
-+ compat_qxl->rom = xf86MapPciMem(scrnIndex, VIDMEM_MMIO | VIDMEM_MMIO_32BIT,
-+ compat_qxl->pci_tag, compat_qxl->pci->memBase[2],
-+ (1 << compat_qxl->pci->size[2]));
+ static void
+-qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
++compat_qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+@@ -747,7 +747,7 @@ qxl_copy_n_to_n (DrawablePtr pSrcDraw
+ {
+ ScreenPtr pScreen = pSrcDrawable->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+ int src_xoff, src_yoff;
+ int dst_xoff, dst_yoff;
+ PixmapPtr pSrcPixmap, pDstPixmap;
+@@ -776,7 +776,7 @@ qxl_copy_n_to_n (DrawablePtr pSrcDraw
+ if (n)
+ {
+ /* ErrorF ("Clearing pending damage\n"); */
+- clear_pending_damage (qxl);
++ clear_pending_damage (compat_qxl);
+
+ /* We have to do this because the copy will cause the damage
+ * to be sent to move.
+@@ -786,13 +786,13 @@ qxl_copy_n_to_n (DrawablePtr pSrcDraw
+ * complex, and the performance win is unlikely to be
+ * very big.
+ */
+- qxl_send_copies (qxl);
++ compat_qxl_send_copies (compat_qxl);
+ }
-- qxl->io_base = qxl->pci->ioBase[3];
-+ compat_qxl->io_base = compat_qxl->pci->ioBase[3];
- #endif
-- if (!qxl->ram || !qxl->vram || !qxl->rom)
-+ if (!compat_qxl->ram || !compat_qxl->vram || !compat_qxl->rom)
- return FALSE;
+ while (n--)
+ {
+- struct qxl_drawable *drawable;
+- struct qxl_rect qrect;
++ struct compat_qxl_drawable *drawable;
++ struct compat_qxl_rect qrect;
+
+ qrect.top = b->y1;
+ qrect.bottom = b->y2;
+@@ -803,19 +803,19 @@ qxl_copy_n_to_n (DrawablePtr pSrcDraw
+ /* b->x1, b->y1, b->x2, b->y2, */
+ /* dx, dy, dst_xoff, dst_yoff); */
+
+- drawable = make_drawable (qxl, QXL_COPY_BITS, &qrect);
++ drawable = make_drawable (compat_qxl, QXL_COPY_BITS, &qrect);
+ drawable->u.copy_bits.src_pos.x = b->x1 + dx;
+ drawable->u.copy_bits.src_pos.y = b->y1 + dy;
- xf86DrvMsg(scrnIndex, X_INFO, "ram at %p; vram at %p; rom at %p\n",
-- qxl->ram, qxl->vram, qxl->rom);
-+ compat_qxl->ram, compat_qxl->vram, compat_qxl->rom);
+- push_drawable (qxl, drawable);
++ push_drawable (compat_qxl, drawable);
-- qxl->num_modes = *(uint32_t *)((uint8_t *)qxl->rom + qxl->rom->modes_offset);
-- qxl->modes = (struct qxl_mode *)(((uint8_t *)qxl->rom) + qxl->rom->modes_offset + 4);
-+ compat_qxl->num_modes = *(uint32_t *)((uint8_t *)compat_qxl->rom + compat_qxl->rom->modes_offset);
-+ compat_qxl->modes = (struct compat_qxl_mode *)(((uint8_t *)compat_qxl->rom) + compat_qxl->rom->modes_offset + 4);
+ #if 0
+ if (closure)
+- qxl_usleep (1000000);
++ compat_qxl_usleep (1000000);
+ #endif
+
+ #if 0
+- submit_fill (qxl, &qrect, rand());
++ submit_fill (compat_qxl, &qrect, rand());
+ #endif
- return TRUE;
+ b++;
+@@ -828,7 +828,7 @@ qxl_copy_n_to_n (DrawablePtr pSrcDraw
}
- static void
--qxl_save_state(ScrnInfoPtr pScrn)
-+compat_qxl_save_state(ScrnInfoPtr pScrn)
+ static RegionPtr
+-qxl_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
++compat_qxl_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
{
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+ if (pSrcDrawable->type == DRAWABLE_WINDOW &&
+@@ -841,7 +841,7 @@ qxl_copy_area(DrawablePtr pSrcDrawable,
+
+ res = fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty,
+- qxl_copy_n_to_n, 0, NULL);
++ compat_qxl_copy_n_to_n, 0, NULL);
-- vgaHWSaveFonts(pScrn, &qxl->vgaRegs);
-+ vgaHWSaveFonts(pScrn, &compat_qxl->vgaRegs);
+ return res;
+ }
+@@ -856,11 +856,11 @@ qxl_copy_area(DrawablePtr pSrcDrawable,
}
static void
--qxl_restore_state(ScrnInfoPtr pScrn)
-+compat_qxl_restore_state(ScrnInfoPtr pScrn)
+-qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel)
++compat_qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel)
{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- qxl_screen_t *qxl = pScrn->driverPrivate;
+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+ PixmapPtr pPixmap;
+ int xoff, yoff;
-- vgaHWRestoreFonts(pScrn, &qxl->vgaRegs);
-+ vgaHWRestoreFonts(pScrn, &compat_qxl->vgaRegs);
- }
-
- static Bool
--qxl_close_screen(int scrnIndex, ScreenPtr pScreen)
-+compat_qxl_close_screen(int scrnIndex, ScreenPtr pScreen)
- {
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+@@ -871,14 +871,14 @@ qxl_fill_region_solid (DrawablePtr pDraw
- if (pScrn->vtSema) {
-- qxl_restore_state(pScrn);
-- qxl_unmap_memory(qxl, scrnIndex);
-+ compat_qxl_restore_state(pScrn);
-+ compat_qxl_unmap_memory(compat_qxl, scrnIndex);
- }
- pScrn->vtSema = FALSE;
+ while (nbox--)
+ {
+- struct qxl_rect qrect;
++ struct compat_qxl_rect qrect;
-- xfree(qxl->fb);
-+ xfree(compat_qxl->fb);
+ qrect.left = pBox->x1;
+ qrect.right = pBox->x2;
+ qrect.top = pBox->y1;
+ qrect.bottom = pBox->y2;
-- pScreen->CreateScreenResources = qxl->create_screen_resources;
-- pScreen->CloseScreen = qxl->close_screen;
-+ pScreen->CreateScreenResources = compat_qxl->create_screen_resources;
-+ pScreen->CloseScreen = compat_qxl->close_screen;
+- submit_fill (qxl, &qrect, pixel);
++ submit_fill (compat_qxl, &qrect, pixel);
- return pScreen->CloseScreen(scrnIndex, pScreen);
+ pBox++;
+ }
+@@ -889,7 +889,7 @@ qxl_fill_region_solid (DrawablePtr pDraw
}
- static Bool
--qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
-+compat_qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
+ static void
+-qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
++compat_qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
-- qxl_screen_t *qxl = xf86Screens[scrnIndex]->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = xf86Screens[scrnIndex]->driverPrivate;
- int mode_index = (int)(unsigned long)p->Private;
-- struct qxl_mode *m = qxl->modes + mode_index;
-- ScreenPtr pScreen = qxl->pScrn->pScreen;
-+ struct compat_qxl_mode *m = compat_qxl->modes + mode_index;
-+ ScreenPtr pScreen = compat_qxl->pScrn->pScreen;
-
- if (!m)
- return FALSE;
-@@ -294,11 +294,11 @@ qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
- xf86DrvMsg (scrnIndex, X_INFO, "Setting mode %d (%d x %d) (%d x %d) %p\n",
- m->id, m->x_res, m->y_res, p->HDisplay, p->VDisplay, p);
-
-- outb(qxl->io_base + QXL_IO_RESET, 0);
-+ outb(compat_qxl->io_base + QXL_IO_RESET, 0);
-
-- outb(qxl->io_base + QXL_IO_SET_MODE, m->id);
-+ outb(compat_qxl->io_base + QXL_IO_SET_MODE, m->id);
+ RegionRec rgnDst;
+ int dx, dy;
+@@ -905,7 +905,7 @@ qxl_copy_window (WindowPtr pWin, DDXPoin
-- qxl->bytes_per_pixel = (qxl->pScrn->bitsPerPixel + 7) / 8;
-+ compat_qxl->bytes_per_pixel = (compat_qxl->pScrn->bitsPerPixel + 7) / 8;
+ fbCopyRegion (&pWin->drawable, &pWin->drawable,
+ NULL,
+- &rgnDst, dx, dy, qxl_copy_n_to_n, 0, NULL);
++ &rgnDst, dx, dy, compat_qxl_copy_n_to_n, 0, NULL);
- /* If this happens out of ScreenInit, we won't have a screen yet. In that
- * case createScreenResources will make things right.
-@@ -313,15 +313,15 @@ qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
- pPixmap,
- m->x_res, m->y_res,
- -1, -1,
-- qxl->pScrn->displayWidth * qxl->bytes_per_pixel,
-+ compat_qxl->pScrn->displayWidth * compat_qxl->bytes_per_pixel,
- NULL);
- }
- }
-
-- if (qxl->mem)
-+ if (compat_qxl->mem)
- {
-- qxl_mem_free_all (qxl->mem);
-- qxl_drop_image_cache (qxl);
-+ compat_qxl_mem_free_all (compat_qxl->mem);
-+ compat_qxl_drop_image_cache (compat_qxl);
- }
+ REGION_UNINIT (pScreen, &rgnDst);
-
-@@ -329,9 +329,9 @@ qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
+@@ -915,7 +915,7 @@ qxl_copy_window (WindowPtr pWin, DDXPoin
}
- static void
--push_drawable (qxl_screen_t *qxl, struct qxl_drawable *drawable)
-+push_drawable (compat_qxl_screen_t *compat_qxl, struct compat_qxl_drawable *drawable)
+ static int
+-qxl_create_gc (GCPtr pGC)
++compat_qxl_create_gc (GCPtr pGC)
{
-- struct qxl_command cmd;
-+ struct compat_qxl_command cmd;
-
- /* When someone runs "init 3", the device will be
- * switched into VGA mode and there is nothing we
-@@ -345,25 +345,25 @@ push_drawable (qxl_screen_t *qxl, struct qxl_drawable *drawable)
- * The author of the QXL device is opposed to this
- * for reasons I don't understand.
- */
-- if (qxl->rom->mode != ~0)
-+ if (compat_qxl->rom->mode != ~0)
+ static GCOps ops;
+ static int initialized;
+@@ -926,8 +926,8 @@ qxl_create_gc (GCPtr pGC)
+ if (!initialized)
{
- cmd.type = QXL_CMD_DRAW;
-- cmd.data = physical_address (qxl, drawable);
-+ cmd.data = physical_address (compat_qxl, drawable);
-
-- qxl_ring_push (qxl->command_ring, &cmd);
-+ compat_qxl_ring_push (compat_qxl->command_ring, &cmd);
+ ops = *pGC->ops;
+- ops.PolyFillRect = qxl_poly_fill_rect;
+- ops.CopyArea = qxl_copy_area;
++ ops.PolyFillRect = compat_qxl_poly_fill_rect;
++ ops.CopyArea = compat_qxl_copy_area;
+
+ initialized = TRUE;
}
+@@ -937,26 +937,26 @@ qxl_create_gc (GCPtr pGC)
}
--static struct qxl_drawable *
--make_drawable (qxl_screen_t *qxl, uint8_t type,
-- const struct qxl_rect *rect
-+static struct compat_qxl_drawable *
-+make_drawable (compat_qxl_screen_t *compat_qxl, uint8_t type,
-+ const struct compat_qxl_rect *rect
- /* , pRegion clip */)
+ static Bool
+-qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
++compat_qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
{
-- struct qxl_drawable *drawable;
-+ struct compat_qxl_drawable *drawable;
-
- CHECK_POINT();
-
-- drawable = qxl_allocnf (qxl, sizeof *drawable);
-+ drawable = compat_qxl_allocnf (compat_qxl, sizeof *drawable);
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+- qxl_screen_t *qxl = pScrn->driverPrivate;
+- struct qxl_rom *rom;
+- struct qxl_ram_header *ram_header;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
++ struct compat_qxl_rom *rom;
++ struct compat_qxl_ram_header *ram_header;
+ VisualPtr visual;
CHECK_POINT();
-@@ -383,7 +383,7 @@ make_drawable (qxl_screen_t *qxl, uint8_t type,
- if (rect)
- drawable->bbox = *rect;
-
-- drawable->mm_time = qxl->rom->mm_clock;
-+ drawable->mm_time = compat_qxl->rom->mm_clock;
-
- CHECK_POINT();
+- qxl->pScrn = pScrn;
++ compat_qxl->pScrn = pScrn;
-@@ -405,7 +405,7 @@ enum ROPDescriptor {
- };
-
- static void
--undamage_box (qxl_screen_t *qxl, const struct qxl_rect *rect)
-+undamage_box (compat_qxl_screen_t *compat_qxl, const struct compat_qxl_rect *rect)
- {
- RegionRec region;
- BoxRec box;
-@@ -415,27 +415,27 @@ undamage_box (qxl_screen_t *qxl, const struct qxl_rect *rect)
- box.x2 = rect->right;
- box.y2 = rect->bottom;
+- if (!qxl_map_memory(qxl, scrnIndex))
++ if (!compat_qxl_map_memory(compat_qxl, scrnIndex))
+ return FALSE;
-- REGION_INIT (qxl->pScrn->pScreen, ®ion, &box, 0);
-+ REGION_INIT (compat_qxl->pScrn->pScreen, ®ion, &box, 0);
+- rom = qxl->rom;
+- ram_header = (void *)((unsigned long)qxl->ram + (unsigned long)qxl->rom->ram_header_offset);
++ rom = compat_qxl->rom;
++ ram_header = (void *)((unsigned long)compat_qxl->ram + (unsigned long)compat_qxl->rom->ram_header_offset);
-- REGION_SUBTRACT (qxl->pScrn->pScreen, &(qxl->pending_copy), &(qxl->pending_copy), ®ion);
-+ REGION_SUBTRACT (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy), &(compat_qxl->pending_copy), ®ion);
+- qxl_save_state(pScrn);
+- qxl_blank_screen(pScreen, SCREEN_SAVER_ON);
++ compat_qxl_save_state(pScrn);
++ compat_qxl_blank_screen(pScreen, SCREEN_SAVER_ON);
+
+ miClearVisualTypes();
+ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
+@@ -968,14 +968,14 @@ qxl_screen_init(int scrnIndex, ScreenPtr
+ /* Note we do this before setting pScrn->virtualY to match our current
+ mode, so as to allocate a buffer large enough for the largest mode.
+ FIXME: add support for resizing the framebuffer on modeset. */
+- qxl->fb = xcalloc(pScrn->virtualY * pScrn->displayWidth, 4);
+- if (!qxl->fb)
++ compat_qxl->fb = xcalloc(pScrn->virtualY * pScrn->displayWidth, 4);
++ if (!compat_qxl->fb)
+ goto out;
-- REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
-+ REGION_EMPTY (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy));
- }
+ pScrn->virtualX = pScrn->currentMode->HDisplay;
+ pScrn->virtualY = pScrn->currentMode->VDisplay;
+
+- if (!fbScreenInit(pScreen, qxl->fb,
++ if (!fbScreenInit(pScreen, compat_qxl->fb,
+ pScrn->currentMode->HDisplay,
+ pScrn->currentMode->VDisplay,
+ pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
+@@ -1001,59 +1001,59 @@ qxl_screen_init(int scrnIndex, ScreenPtr
+
+ fbPictureInit(pScreen, 0, 0);
- static void
--clear_pending_damage (qxl_screen_t *qxl)
-+clear_pending_damage (compat_qxl_screen_t *compat_qxl)
- {
-- REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
-+ REGION_EMPTY (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy));
- }
+- qxl->create_screen_resources = pScreen->CreateScreenResources;
+- pScreen->CreateScreenResources = qxl_create_screen_resources;
++ compat_qxl->create_screen_resources = pScreen->CreateScreenResources;
++ pScreen->CreateScreenResources = compat_qxl_create_screen_resources;
- static void
--submit_fill (qxl_screen_t *qxl, const struct qxl_rect *rect, uint32_t color)
-+submit_fill (compat_qxl_screen_t *compat_qxl, const struct compat_qxl_rect *rect, uint32_t color)
- {
-- struct qxl_drawable *drawable;
-+ struct compat_qxl_drawable *drawable;
+ /* Set up resources */
+- qxl->mem = qxl_mem_create ((void *)((unsigned long)qxl->ram + (unsigned long)rom->pages_offset),
++ compat_qxl->mem = compat_qxl_mem_create ((void *)((unsigned long)compat_qxl->ram + (unsigned long)rom->pages_offset),
+ rom->num_io_pages * getpagesize());
+- qxl->io_pages = (void *)((unsigned long)qxl->ram + (unsigned long)rom->pages_offset);
+- qxl->io_pages_physical = (void *)((unsigned long)qxl->ram_physical + (unsigned long)rom->pages_offset);
++ compat_qxl->io_pages = (void *)((unsigned long)compat_qxl->ram + (unsigned long)rom->pages_offset);
++ compat_qxl->io_pages_physical = (void *)((unsigned long)compat_qxl->ram_physical + (unsigned long)rom->pages_offset);
- CHECK_POINT();
-
-- drawable = make_drawable (qxl, QXL_DRAW_FILL, rect);
-+ drawable = make_drawable (compat_qxl, QXL_DRAW_FILL, rect);
+- qxl->command_ring = qxl_ring_create (&(ram_header->cmd_ring_hdr),
+- sizeof (struct qxl_command),
+- 32, qxl->io_base + QXL_IO_NOTIFY_CMD);
+- qxl->cursor_ring = qxl_ring_create (&(ram_header->cursor_ring_hdr),
+- sizeof (struct qxl_command),
+- 32, qxl->io_base + QXL_IO_NOTIFY_CURSOR);
+- qxl->release_ring = qxl_ring_create (&(ram_header->release_ring_hdr),
++ compat_qxl->command_ring = compat_qxl_ring_create (&(ram_header->cmd_ring_hdr),
++ sizeof (struct compat_qxl_command),
++ 32, compat_qxl->io_base + QXL_IO_NOTIFY_CMD);
++ compat_qxl->cursor_ring = compat_qxl_ring_create (&(ram_header->cursor_ring_hdr),
++ sizeof (struct compat_qxl_command),
++ 32, compat_qxl->io_base + QXL_IO_NOTIFY_CURSOR);
++ compat_qxl->release_ring = compat_qxl_ring_create (&(ram_header->release_ring_hdr),
+ sizeof (uint64_t),
+ 8, 0);
+
+ /* xf86DPMSInit(pScreen, xf86DPMSSet, 0); */
- CHECK_POINT();
+ #if 0 /* XV accel */
+- qxlInitVideo(pScreen);
++ compat_qxlInitVideo(pScreen);
+ #endif
-@@ -447,13 +447,13 @@ submit_fill (qxl_screen_t *qxl, const struct qxl_rect *rect, uint32_t color)
- drawable->u.fill.mask.pos.y = 0;
- drawable->u.fill.mask.bitmap = 0;
+- pScreen->SaveScreen = qxl_blank_screen;
+- qxl->close_screen = pScreen->CloseScreen;
+- pScreen->CloseScreen = qxl_close_screen;
++ pScreen->SaveScreen = compat_qxl_blank_screen;
++ compat_qxl->close_screen = pScreen->CloseScreen;
++ pScreen->CloseScreen = compat_qxl_close_screen;
-- push_drawable (qxl, drawable);
-+ push_drawable (compat_qxl, drawable);
+- qxl->create_gc = pScreen->CreateGC;
+- pScreen->CreateGC = qxl_create_gc;
++ compat_qxl->create_gc = pScreen->CreateGC;
++ pScreen->CreateGC = compat_qxl_create_gc;
-- undamage_box (qxl, rect);
-+ undamage_box (compat_qxl, rect);
- }
+ #if 0
+- qxl->paint_window_background = pScreen->PaintWindowBackground;
+- qxl->paint_window_border = pScreen->PaintWindowBorder;
++ compat_qxl->paint_window_background = pScreen->PaintWindowBackground;
++ compat_qxl->paint_window_border = pScreen->PaintWindowBorder;
+ #endif
+- qxl->copy_window = pScreen->CopyWindow;
++ compat_qxl->copy_window = pScreen->CopyWindow;
+ #if 0
+- pScreen->PaintWindowBackground = qxl_paint_window;
+- pScreen->PaintWindowBorder = qxl_paint_window;
++ pScreen->PaintWindowBackground = compat_qxl_paint_window;
++ pScreen->PaintWindowBorder = compat_qxl_paint_window;
+ #endif
+- pScreen->CopyWindow = qxl_copy_window;
++ pScreen->CopyWindow = compat_qxl_copy_window;
- static void
--translate_rect (struct qxl_rect *rect)
-+translate_rect (struct compat_qxl_rect *rect)
- {
- rect->right -= rect->left;
- rect->bottom -= rect->top;
-@@ -461,10 +461,10 @@ translate_rect (struct qxl_rect *rect)
- }
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
- static void
--submit_copy (qxl_screen_t *qxl, const struct qxl_rect *rect)
-+submit_copy (compat_qxl_screen_t *compat_qxl, const struct compat_qxl_rect *rect)
- {
-- struct qxl_drawable *drawable;
-- ScrnInfoPtr pScrn = qxl->pScrn;
-+ struct compat_qxl_drawable *drawable;
-+ ScrnInfoPtr pScrn = compat_qxl->pScrn;
+ if (!miCreateDefColormap(pScreen))
+ goto out;
- if (rect->left == rect->right ||
- rect->top == rect->bottom)
-@@ -473,13 +473,13 @@ submit_copy (qxl_screen_t *qxl, const struct qxl_rect *rect)
- return ;
- }
+- qxl_cursor_init (pScreen);
++ compat_qxl_cursor_init (pScreen);
-- drawable = make_drawable (qxl, QXL_DRAW_COPY, rect);
-+ drawable = make_drawable (compat_qxl, QXL_DRAW_COPY, rect);
-
- drawable->u.copy.src_bitmap = physical_address (
-- qxl, qxl_image_create (qxl, qxl->fb, rect->left, rect->top,
-+ compat_qxl, compat_qxl_image_create (compat_qxl, compat_qxl->fb, rect->left, rect->top,
- rect->right - rect->left,
- rect->bottom - rect->top,
-- pScrn->displayWidth * qxl->bytes_per_pixel));
-+ pScrn->displayWidth * compat_qxl->bytes_per_pixel));
- drawable->u.copy.src_area = *rect;
- translate_rect (&drawable->u.copy.src_area);
- drawable->u.copy.rop_descriptor = ROPD_OP_PUT;
-@@ -489,7 +489,7 @@ submit_copy (qxl_screen_t *qxl, const struct qxl_rect *rect)
- drawable->u.copy.mask.pos.y = 0;
- drawable->u.copy.mask.bitmap = 0;
+ CHECK_POINT();
-- push_drawable (qxl, drawable);
-+ push_drawable (compat_qxl, drawable);
- }
+- qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
++ compat_qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
- static void
-@@ -511,87 +511,87 @@ print_region (const char *header, RegionPtr pRegion)
+ CHECK_POINT();
+
+@@ -1064,26 +1064,26 @@ out:
}
- static void
--accept_damage (qxl_screen_t *qxl)
-+accept_damage (compat_qxl_screen_t *compat_qxl)
+ static Bool
+-qxl_enter_vt(int scrnIndex, int flags)
++compat_qxl_enter_vt(int scrnIndex, int flags)
{
-- REGION_UNION (qxl->pScrn->pScreen, &(qxl->to_be_sent), &(qxl->to_be_sent),
-- &(qxl->pending_copy));
-+ REGION_UNION (compat_qxl->pScrn->pScreen, &(compat_qxl->to_be_sent), &(compat_qxl->to_be_sent),
-+ &(compat_qxl->pending_copy));
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-- REGION_EMPTY (qxl->pScrn->pScreen, &(qxl->pending_copy));
-+ REGION_EMPTY (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy));
+- qxl_save_state(pScrn);
+- qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
++ compat_qxl_save_state(pScrn);
++ compat_qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
+
+ return TRUE;
}
static void
--qxl_send_copies (qxl_screen_t *qxl)
-+compat_qxl_send_copies (compat_qxl_screen_t *compat_qxl)
+-qxl_leave_vt(int scrnIndex, int flags)
++compat_qxl_leave_vt(int scrnIndex, int flags)
{
- BoxPtr pBox;
- int nbox;
-
-- nbox = REGION_NUM_RECTS (&qxl->to_be_sent);
-- pBox = REGION_RECTS (&qxl->to_be_sent);
-+ nbox = REGION_NUM_RECTS (&compat_qxl->to_be_sent);
-+ pBox = REGION_RECTS (&compat_qxl->to_be_sent);
-
--/* if (REGION_NUM_RECTS (&qxl->to_be_sent) > 0) */
--/* print_region ("send bits", &qxl->to_be_sent); */
-+/* if (REGION_NUM_RECTS (&compat_qxl->to_be_sent) > 0) */
-+/* print_region ("send bits", &compat_qxl->to_be_sent); */
-
- while (nbox--)
- {
-- struct qxl_rect qrect;
-+ struct compat_qxl_rect qrect;
-
- qrect.top = pBox->y1;
- qrect.left = pBox->x1;
- qrect.bottom = pBox->y2;
- qrect.right = pBox->x2;
-
-- submit_copy (qxl, &qrect);
-+ submit_copy (compat_qxl, &qrect);
-
- pBox++;
- }
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-- REGION_EMPTY(qxl->pScrn->pScreen, &qxl->to_be_sent);
-+ REGION_EMPTY(compat_qxl->pScrn->pScreen, &compat_qxl->to_be_sent);
+- qxl_restore_state(pScrn);
++ compat_qxl_restore_state(pScrn);
}
- static void
--paint_shadow (qxl_screen_t *qxl)
-+paint_shadow (compat_qxl_screen_t *compat_qxl)
+ static Bool
+-qxl_color_setup(ScrnInfoPtr pScrn)
++compat_qxl_color_setup(ScrnInfoPtr pScrn)
{
-- struct qxl_rect qrect;
-+ struct compat_qxl_rect qrect;
-
- qrect.top = 0;
- qrect.bottom = 1200;
- qrect.left = 0;
- qrect.right = 1600;
-
-- submit_copy (qxl, &qrect);
-+ submit_copy (compat_qxl, &qrect);
+ int scrnIndex = pScrn->scrnIndex;
+ Gamma gzeros = { 0.0, 0.0, 0.0 };
+@@ -1113,13 +1113,13 @@ qxl_color_setup(ScrnInfoPtr pScrn)
}
static void
--qxl_sanity_check (qxl_screen_t *qxl)
-+compat_qxl_sanity_check (compat_qxl_screen_t *compat_qxl)
+-print_modes (qxl_screen_t *qxl, int scrnIndex)
++print_modes (compat_qxl_screen_t *compat_qxl, int scrnIndex)
{
- /* read the mode back from the rom */
-- if (!qxl->rom || !qxl->pScrn)
-+ if (!compat_qxl->rom || !compat_qxl->pScrn)
- return;
+ int i;
-- if (qxl->rom->mode == ~0)
-+ if (compat_qxl->rom->mode == ~0)
+- for (i = 0; i < qxl->num_modes; ++i)
++ for (i = 0; i < compat_qxl->num_modes; ++i)
{
- ErrorF("QXL device jumped back to VGA mode - resetting mode\n");
-- qxl_switch_mode(qxl->pScrn->scrnIndex, qxl->pScrn->currentMode, 0);
-+ compat_qxl_switch_mode(compat_qxl->pScrn->scrnIndex, compat_qxl->pScrn->currentMode, 0);
- }
+- struct qxl_mode *m = qxl->modes + i;
++ struct compat_qxl_mode *m = compat_qxl->modes + i;
+
+ xf86DrvMsg (scrnIndex, X_INFO,
+ "%d: %dx%d, %d bits, stride %d, %dmm x %dmm, orientation %d\n",
+@@ -1129,11 +1129,11 @@ print_modes (qxl_screen_t *qxl, int scrn
}
- static void
--qxl_block_handler (pointer data, OSTimePtr pTimeout, pointer pRead)
-+compat_qxl_block_handler (pointer data, OSTimePtr pTimeout, pointer pRead)
+ static Bool
+-qxl_check_device(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
++compat_qxl_check_device(ScrnInfoPtr pScrn, compat_qxl_screen_t *compat_qxl)
{
-- qxl_screen_t *qxl = (qxl_screen_t *) data;
-+ compat_qxl_screen_t *compat_qxl = (compat_qxl_screen_t *) data;
-
-- if (!qxl->pScrn->vtSema)
-+ if (!compat_qxl->pScrn->vtSema)
- return;
-
-- qxl_sanity_check(qxl);
-+ compat_qxl_sanity_check(compat_qxl);
-
-- accept_damage (qxl);
-+ accept_damage (compat_qxl);
+ int scrnIndex = pScrn->scrnIndex;
+- struct qxl_rom *rom = qxl->rom;
+- struct qxl_ram_header *ram_header = (void *)((unsigned long)qxl->ram + rom->ram_header_offset);
++ struct compat_qxl_rom *rom = compat_qxl->rom;
++ struct compat_qxl_ram_header *ram_header = (void *)((unsigned long)compat_qxl->ram + rom->ram_header_offset);
-- qxl_send_copies (qxl);
-+ compat_qxl_send_copies (compat_qxl);
- }
+ CHECK_POINT();
+
+@@ -1170,24 +1170,24 @@ qxl_check_device(ScrnInfoPtr pScrn, qxl_
+ xf86DrvMsg(scrnIndex, X_INFO, "Correct RAM signature %x\n",
+ ram_header->magic);
- static void
--qxl_wakeup_handler (pointer data, int i, pointer LastSelectMask)
-+compat_qxl_wakeup_handler (pointer data, int i, pointer LastSelectMask)
- {
+- qxl->draw_area_offset = rom->draw_area_offset;
+- qxl->draw_area_size = rom->draw_area_size;
++ compat_qxl->draw_area_offset = rom->draw_area_offset;
++ compat_qxl->draw_area_size = rom->draw_area_size;
+ pScrn->videoRam = rom->draw_area_size / 1024;
+
+ return TRUE;
}
-@@ -612,59 +612,59 @@ qxl_wakeup_handler (pointer data, int i, pointer LastSelectMask)
- * damage, that must first be unioned onto to_be_sent, and then the new
- * damage must be stored in pending_copy.
- *
-- * The qxl_screen_t struct contains two regions, "pending_copy" and
-+ * The compat_qxl_screen_t struct contains two regions, "pending_copy" and
- * "to_be_sent".
- *
- * Pending copy is
- *
- */
- static void
--qxl_on_damage (DamagePtr pDamage, RegionPtr pRegion, pointer closure)
-+compat_qxl_on_damage (DamagePtr pDamage, RegionPtr pRegion, pointer closure)
+ static int
+-qxl_find_native_mode(ScrnInfoPtr pScrn, DisplayModePtr p)
++compat_qxl_find_native_mode(ScrnInfoPtr pScrn, DisplayModePtr p)
{
-- qxl_screen_t *qxl = closure;
-+ compat_qxl_screen_t *compat_qxl = closure;
+ int i;
+- qxl_screen_t *qxl = pScrn->driverPrivate;
++ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- /* print_region ("damage", pRegion); */
+ CHECK_POINT();
- /* print_region ("on_damage ", pRegion); */
-
-- accept_damage (qxl);
-+ accept_damage (compat_qxl);
-
--/* print_region ("accepting, qxl->to_be_sent is now", &qxl->to_be_sent); */
-+/* print_region ("accepting, compat_qxl->to_be_sent is now", &compat_qxl->to_be_sent); */
+- for (i = 0; i < qxl->num_modes; i++)
++ for (i = 0; i < compat_qxl->num_modes; i++)
+ {
+- struct qxl_mode *m = qxl->modes + i;
++ struct compat_qxl_mode *m = compat_qxl->modes + i;
-- REGION_COPY (qxl->pScrn->pScreen, &(qxl->pending_copy), pRegion);
-+ REGION_COPY (compat_qxl->pScrn->pScreen, &(compat_qxl->pending_copy), pRegion);
+ if (m->x_res == p->HDisplay &&
+ m->y_res == p->VDisplay &&
+@@ -1212,20 +1212,20 @@ qxl_find_native_mode(ScrnInfoPtr pScrn,
}
-
- static Bool
--qxl_create_screen_resources(ScreenPtr pScreen)
-+compat_qxl_create_screen_resources(ScreenPtr pScreen)
+ static ModeStatus
+-qxl_valid_mode(int scrn, DisplayModePtr p, Bool flag, int pass)
++compat_qxl_valid_mode(int scrn, DisplayModePtr p, Bool flag, int pass)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ScrnInfoPtr pScrn = xf86Screens[scrn];
- qxl_screen_t *qxl = pScrn->driverPrivate;
+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- Bool ret;
- PixmapPtr pPixmap;
+ int bpp = pScrn->bitsPerPixel;
+ int mode_idx;
-- pScreen->CreateScreenResources = qxl->create_screen_resources;
-+ pScreen->CreateScreenResources = compat_qxl->create_screen_resources;
- ret = pScreen->CreateScreenResources (pScreen);
-- pScreen->CreateScreenResources = qxl_create_screen_resources;
-+ pScreen->CreateScreenResources = compat_qxl_create_screen_resources;
+ /* FIXME: I don't think this is necessary now that we report the
+ * correct amount of video ram?
+ */
+- if (p->HDisplay * p->VDisplay * (bpp/8) > qxl->draw_area_size)
++ if (p->HDisplay * p->VDisplay * (bpp/8) > compat_qxl->draw_area_size)
+ return MODE_MEM;
- if (!ret)
- return FALSE;
+- mode_idx = qxl_find_native_mode (pScrn, p);
++ mode_idx = compat_qxl_find_native_mode (pScrn, p);
+ if (mode_idx == -1)
+ return MODE_NOMODE;
-- qxl->damage = DamageCreate (qxl_on_damage, NULL,
-+ compat_qxl->damage = DamageCreate (compat_qxl_on_damage, NULL,
- DamageReportRawRegion,
-- TRUE, pScreen, qxl);
-+ TRUE, pScreen, compat_qxl);
+@@ -1234,7 +1234,7 @@ qxl_valid_mode(int scrn, DisplayModePtr
+ return MODE_OK;
+ }
+
+-static void qxl_add_mode(ScrnInfoPtr pScrn, int width, int height, int type)
++static void compat_qxl_add_mode(ScrnInfoPtr pScrn, int width, int height, int type)
+ {
+ DisplayModePtr mode;
+@@ -1263,10 +1263,10 @@ static void qxl_add_mode(ScrnInfoPtr pSc
+ }
- pPixmap = pScreen->GetScreenPixmap(pScreen);
+ static Bool
+-qxl_pre_init(ScrnInfoPtr pScrn, int flags)
++compat_qxl_pre_init(ScrnInfoPtr pScrn, int flags)
+ {
+ int i, scrnIndex = pScrn->scrnIndex;
+- qxl_screen_t *qxl = NULL;
++ compat_qxl_screen_t *compat_qxl = NULL;
+ ClockRangePtr clockRanges = NULL;
+ int *linePitches = NULL;
+ DisplayModePtr mode;
+@@ -1281,27 +1281,27 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flag
+ }
-- if (!RegisterBlockAndWakeupHandlers(qxl_block_handler, qxl_wakeup_handler, qxl))
-+ if (!RegisterBlockAndWakeupHandlers(compat_qxl_block_handler, compat_qxl_wakeup_handler, compat_qxl))
- return FALSE;
+ if (!pScrn->driverPrivate)
+- pScrn->driverPrivate = xnfcalloc(sizeof(qxl_screen_t), 1);
+- qxl = pScrn->driverPrivate;
++ pScrn->driverPrivate = xnfcalloc(sizeof(compat_qxl_screen_t), 1);
++ compat_qxl = pScrn->driverPrivate;
+
+- qxl->entity = xf86GetEntityInfo(pScrn->entityList[0]);
+- qxl->pci = xf86GetPciInfoForEntity(qxl->entity->index);
++ compat_qxl->entity = xf86GetEntityInfo(pScrn->entityList[0]);
++ compat_qxl->pci = xf86GetPciInfoForEntity(compat_qxl->entity->index);
+ #ifndef XSERVER_LIBPCIACCESS
+- qxl->pci_tag = pciTag(qxl->pci->bus, qxl->pci->device, qxl->pci->func);
++ compat_qxl->pci_tag = pciTag(compat_qxl->pci->bus, compat_qxl->pci->device, compat_qxl->pci->func);
+ #endif
-- REGION_INIT (pScreen, &(qxl->pending_copy), NullBox, 0);
-+ REGION_INIT (pScreen, &(compat_qxl->pending_copy), NullBox, 0);
+ pScrn->monitor = pScrn->confScreen->monitor;
-- REGION_INIT (pScreen, &(qxl->to_be_sent), NullBox, 0);
-+ REGION_INIT (pScreen, &(compat_qxl->to_be_sent), NullBox, 0);
-
-- DamageRegister (&pPixmap->drawable, qxl->damage);
-+ DamageRegister (&pPixmap->drawable, compat_qxl->damage);
- return TRUE;
- }
+- if (!qxl_color_setup(pScrn))
++ if (!compat_qxl_color_setup(pScrn))
+ goto out;
-@@ -686,13 +686,13 @@ get_window_pixmap (DrawablePtr pDrawable, int *xoff, int *yoff)
- }
+ /* option parsing and card differentiation */
+ xf86CollectOptions(pScrn, NULL);
+
+- if (!qxl_map_memory(qxl, scrnIndex))
++ if (!compat_qxl_map_memory(compat_qxl, scrnIndex))
+ goto out;
- static void
--qxl_poly_fill_rect (DrawablePtr pDrawable,
-+compat_qxl_poly_fill_rect (DrawablePtr pDrawable,
- GCPtr pGC,
- int nrect,
- xRectangle *prect)
- {
- ScrnInfoPtr pScrn = xf86Screens[pDrawable->pScreen->myNum];
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- PixmapPtr pPixmap;
- int xoff, yoff;
+- if (!qxl_check_device(pScrn, qxl))
++ if (!compat_qxl_check_device(pScrn, compat_qxl))
+ goto out;
-@@ -714,14 +714,14 @@ qxl_poly_fill_rect (DrawablePtr pDrawable,
+ /* ddc stuff here */
+@@ -1328,22 +1328,22 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flag
+ }
- while (nbox--)
- {
-- struct qxl_rect qrect;
-+ struct compat_qxl_rect qrect;
+ /* Add any modes not in xorg's default mode list */
+- for (i = 0; i < qxl->num_modes; i++)
+- if (qxl->modes[i].orientation == 0) {
+- qxl_add_mode(pScrn, qxl->modes[i].x_res, qxl->modes[i].y_res,
++ for (i = 0; i < compat_qxl->num_modes; i++)
++ if (compat_qxl->modes[i].orientation == 0) {
++ compat_qxl_add_mode(pScrn, compat_qxl->modes[i].x_res, compat_qxl->modes[i].y_res,
+ M_T_DRIVER);
+- if (qxl->modes[i].x_res > max_x)
+- max_x = qxl->modes[i].x_res;
+- if (qxl->modes[i].y_res > max_y)
+- max_y = qxl->modes[i].y_res;
++ if (compat_qxl->modes[i].x_res > max_x)
++ max_x = compat_qxl->modes[i].x_res;
++ if (compat_qxl->modes[i].y_res > max_y)
++ max_y = compat_qxl->modes[i].y_res;
+ }
- qrect.left = pBox->x1;
- qrect.right = pBox->x2;
- qrect.top = pBox->y1;
- qrect.bottom = pBox->y2;
+ if (pScrn->display->virtualX == 0 && pScrn->display->virtualY == 0) {
+ /* It is possible for the largest x + largest y size combined leading
+ to a virtual size which will not fit into the framebuffer when this
+ happens we prefer max width and make height as large as possible */
+- if (max_x * max_y * (pScrn->bitsPerPixel / 8) > qxl->draw_area_size)
+- pScrn->display->virtualY = qxl->draw_area_size /
++ if (max_x * max_y * (pScrn->bitsPerPixel / 8) > compat_qxl->draw_area_size)
++ pScrn->display->virtualY = compat_qxl->draw_area_size /
+ (max_x * (pScrn->bitsPerPixel / 8));
+ else
+ pScrn->display->virtualY = max_y;
+@@ -1381,14 +1381,14 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flag
+ goto out;
+ }
-- submit_fill (qxl, &qrect, pGC->fgPixel);
-+ submit_fill (compat_qxl, &qrect, pGC->fgPixel);
+- print_modes (qxl, scrnIndex);
++ print_modes (compat_qxl, scrnIndex);
- pBox++;
- }
-@@ -733,7 +733,7 @@ qxl_poly_fill_rect (DrawablePtr pDrawable,
- }
+ /* VGA hardware initialisation */
+ if (!vgaHWGetHWRec(pScrn))
+ return FALSE;
- static void
--qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
-+compat_qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GCPtr pGC,
- BoxPtr pbox,
-@@ -747,7 +747,7 @@ qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
- {
- ScreenPtr pScreen = pSrcDrawable->pScreen;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- int src_xoff, src_yoff;
- int dst_xoff, dst_yoff;
- PixmapPtr pSrcPixmap, pDstPixmap;
-@@ -776,7 +776,7 @@ qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
- if (n)
- {
- /* ErrorF ("Clearing pending damage\n"); */
-- clear_pending_damage (qxl);
-+ clear_pending_damage (compat_qxl);
-
- /* We have to do this because the copy will cause the damage
- * to be sent to move.
-@@ -786,13 +786,13 @@ qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
- * complex, and the performance win is unlikely to be
- * very big.
- */
-- qxl_send_copies (qxl);
-+ compat_qxl_send_copies (compat_qxl);
- }
+ /* hate */
+- qxl_unmap_memory(qxl, scrnIndex);
++ compat_qxl_unmap_memory(compat_qxl, scrnIndex);
+
+ CHECK_POINT();
- while (n--)
- {
-- struct qxl_drawable *drawable;
-- struct qxl_rect qrect;
-+ struct compat_qxl_drawable *drawable;
-+ struct compat_qxl_rect qrect;
-
- qrect.top = b->y1;
- qrect.bottom = b->y2;
-@@ -803,19 +803,19 @@ qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
- /* b->x1, b->y1, b->x2, b->y2, */
- /* dx, dy, dst_xoff, dst_yoff); */
-
-- drawable = make_drawable (qxl, QXL_COPY_BITS, &qrect);
-+ drawable = make_drawable (compat_qxl, QXL_COPY_BITS, &qrect);
- drawable->u.copy_bits.src_pos.x = b->x1 + dx;
- drawable->u.copy_bits.src_pos.y = b->y1 + dy;
+@@ -1398,19 +1398,19 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flag
+ out:
+ if (clockRanges)
+ xfree(clockRanges);
+- if (qxl)
+- xfree(qxl);
++ if (compat_qxl)
++ xfree(compat_qxl);
-- push_drawable (qxl, drawable);
-+ push_drawable (compat_qxl, drawable);
+ return FALSE;
+ }
- #if 0
- if (closure)
-- qxl_usleep (1000000);
-+ compat_qxl_usleep (1000000);
- #endif
-
- #if 0
-- submit_fill (qxl, &qrect, rand());
-+ submit_fill (compat_qxl, &qrect, rand());
- #endif
+ #ifdef XSERVER_LIBPCIACCESS
+-enum qxl_class
++enum compat_qxl_class
+ {
+ CHIP_QXL_1,
+ };
- b++;
-@@ -828,7 +828,7 @@ qxl_copy_n_to_n (DrawablePtr pSrcDrawable,
- }
+-static const struct pci_id_match qxl_device_match[] = {
++static const struct pci_id_match compat_qxl_device_match[] = {
+ {
+ PCI_VENDOR_RED_HAT, PCI_CHIP_QXL_0100, PCI_MATCH_ANY, PCI_MATCH_ANY,
+ 0x00030000, 0x00ffffff, CHIP_QXL_1
+@@ -1420,14 +1420,14 @@ static const struct pci_id_match qxl_dev
+ };
+ #endif
- static RegionPtr
--qxl_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
-+compat_qxl_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
- int srcx, int srcy, int width, int height, int dstx, int dsty)
+-static SymTabRec qxlChips[] =
++static SymTabRec compat_qxlChips[] =
{
- if (pSrcDrawable->type == DRAWABLE_WINDOW &&
-@@ -841,7 +841,7 @@ qxl_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
-
- res = fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
- srcx, srcy, width, height, dstx, dsty,
-- qxl_copy_n_to_n, 0, NULL);
-+ compat_qxl_copy_n_to_n, 0, NULL);
+ { PCI_CHIP_QXL_0100, "QXL 1", },
+ { -1, NULL }
+ };
- return res;
- }
-@@ -856,11 +856,11 @@ qxl_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
- }
+ #ifndef XSERVER_LIBPCIACCESS
+-static PciChipsets qxlPciChips[] =
++static PciChipsets compat_qxlPciChips[] =
+ {
+ { PCI_CHIP_QXL_0100, PCI_CHIP_QXL_0100, RES_SHARED_VGA },
+ { -1, -1, RES_UNDEFINED }
+@@ -1435,20 +1435,20 @@ static PciChipsets qxlPciChips[] =
+ #endif
static void
--qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel)
-+compat_qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel)
+-qxl_identify(int flags)
++compat_qxl_identify(int flags)
{
- ScreenPtr pScreen = pDrawable->pScreen;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- PixmapPtr pPixmap;
- int xoff, yoff;
-
-@@ -871,14 +871,14 @@ qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel)
+- xf86PrintChipsets("qxl", "Driver for QXL virtual graphics", qxlChips);
++ xf86PrintChipsets("compat_qxl", "Driver for QXL virtual graphics", compat_qxlChips);
+ }
- while (nbox--)
- {
-- struct qxl_rect qrect;
-+ struct compat_qxl_rect qrect;
+-static void
+-qxl_init_scrn(ScrnInfoPtr pScrn)
++void
++compat_init_scrn(ScrnInfoPtr pScrn)
+ {
+ pScrn->driverVersion = 0;
+- pScrn->driverName = pScrn->name = "qxl";
+- pScrn->PreInit = qxl_pre_init;
+- pScrn->ScreenInit = qxl_screen_init;
+- pScrn->SwitchMode = qxl_switch_mode;
+- pScrn->ValidMode = qxl_valid_mode;
+- pScrn->EnterVT = qxl_enter_vt;
+- pScrn->LeaveVT = qxl_leave_vt;
++ pScrn->driverName = pScrn->name = "compat_qxl";
++ pScrn->PreInit = compat_qxl_pre_init;
++ pScrn->ScreenInit = compat_qxl_screen_init;
++ pScrn->SwitchMode = compat_qxl_switch_mode;
++ pScrn->ValidMode = compat_qxl_valid_mode;
++ pScrn->EnterVT = compat_qxl_enter_vt;
++ pScrn->LeaveVT = compat_qxl_leave_vt;
+ }
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl.h.compat2 xf86-video-qxl-20130514/src/compat/compat-qxl.h
+--- xf86-video-qxl-20130514/src/compat/compat-qxl.h.compat2 2013-07-03 14:19:39.009334569 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl.h 2013-07-03 14:19:56.102748510 +1000
+@@ -43,8 +43,8 @@
- qrect.left = pBox->x1;
- qrect.right = pBox->x2;
- qrect.top = pBox->y1;
- qrect.bottom = pBox->y2;
+ #define hidden _X_HIDDEN
-- submit_fill (qxl, &qrect, pixel);
-+ submit_fill (compat_qxl, &qrect, pixel);
+-#define QXL_NAME "qxl"
+-#define QXL_DRIVER_NAME "qxl"
++#define QXL_NAME "compat_qxl"
++#define QXL_DRIVER_NAME "compat_qxl"
+ #define PCI_VENDOR_RED_HAT 0x1b36
- pBox++;
- }
-@@ -889,7 +889,7 @@ qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel)
- }
+ #define PCI_CHIP_QXL_0100 0x0100
+@@ -63,7 +63,7 @@ enum {
+ QXL_IO_LOG,
+ };
- static void
--qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-+compat_qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
- {
- RegionRec rgnDst;
- int dx, dy;
-@@ -905,7 +905,7 @@ qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+-struct qxl_mode {
++struct compat_qxl_mode {
+ uint32_t id;
+ uint32_t x_res;
+ uint32_t y_res;
+@@ -81,39 +81,39 @@ typedef enum
+ QXL_CMD_UPDATE,
+ QXL_CMD_CURSOR,
+ QXL_CMD_MESSAGE
+-} qxl_command_type;
++} compat_qxl_command_type;
- fbCopyRegion (&pWin->drawable, &pWin->drawable,
- NULL,
-- &rgnDst, dx, dy, qxl_copy_n_to_n, 0, NULL);
-+ &rgnDst, dx, dy, compat_qxl_copy_n_to_n, 0, NULL);
+-struct qxl_command {
++struct compat_qxl_command {
+ uint64_t data;
+ uint32_t type;
+ uint32_t pad;
+ };
- REGION_UNINIT (pScreen, &rgnDst);
+-struct qxl_rect {
++struct compat_qxl_rect {
+ uint32_t top;
+ uint32_t left;
+ uint32_t bottom;
+ uint32_t right;
+ };
-@@ -915,7 +915,7 @@ qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
- }
+-union qxl_release_info {
++union compat_qxl_release_info {
+ uint64_t id;
+ uint64_t next;
+ };
- static int
--qxl_create_gc (GCPtr pGC)
-+compat_qxl_create_gc (GCPtr pGC)
- {
- static GCOps ops;
- static int initialized;
-@@ -926,8 +926,8 @@ qxl_create_gc (GCPtr pGC)
- if (!initialized)
- {
- ops = *pGC->ops;
-- ops.PolyFillRect = qxl_poly_fill_rect;
-- ops.CopyArea = qxl_copy_area;
-+ ops.PolyFillRect = compat_qxl_poly_fill_rect;
-+ ops.CopyArea = compat_qxl_copy_area;
+-struct qxl_clip {
++struct compat_qxl_clip {
+ uint32_t type;
+ uint64_t address;
+ };
- initialized = TRUE;
- }
-@@ -937,26 +937,26 @@ qxl_create_gc (GCPtr pGC)
- }
+-struct qxl_point {
++struct compat_qxl_point {
+ int x;
+ int y;
+ };
- static Bool
--qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
-+compat_qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
- {
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-- struct qxl_rom *rom;
-- struct qxl_ram_header *ram_header;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
-+ struct compat_qxl_rom *rom;
-+ struct compat_qxl_ram_header *ram_header;
- VisualPtr visual;
+-struct qxl_pattern {
++struct compat_qxl_pattern {
+ uint64_t pat;
+- struct qxl_point pos;
++ struct compat_qxl_point pos;
+ };
- CHECK_POINT();
+ typedef enum
+@@ -121,19 +121,19 @@ typedef enum
+ QXL_BRUSH_TYPE_NONE,
+ QXL_BRUSH_TYPE_SOLID,
+ QXL_BRUSH_TYPE_PATTERN
+-} qxl_brush_type;
++} compat_qxl_brush_type;
-- qxl->pScrn = pScrn;
-+ compat_qxl->pScrn = pScrn;
-
-- if (!qxl_map_memory(qxl, scrnIndex))
-+ if (!compat_qxl_map_memory(compat_qxl, scrnIndex))
- return FALSE;
+-struct qxl_brush {
++struct compat_qxl_brush {
+ uint32_t type;
+ union {
+ uint32_t color;
+- struct qxl_pattern pattern;
++ struct compat_qxl_pattern pattern;
+ } u;
+ };
-- rom = qxl->rom;
-- ram_header = (void *)((unsigned long)qxl->ram + (unsigned long)qxl->rom->ram_header_offset);
-+ rom = compat_qxl->rom;
-+ ram_header = (void *)((unsigned long)compat_qxl->ram + (unsigned long)compat_qxl->rom->ram_header_offset);
+-struct qxl_mask {
++struct compat_qxl_mask {
+ unsigned char flags;
+- struct qxl_point pos;
++ struct compat_qxl_point pos;
+ uint64_t bitmap;
+ };
-- qxl_save_state(pScrn);
-- qxl_blank_screen(pScreen, SCREEN_SAVER_ON);
-+ compat_qxl_save_state(pScrn);
-+ compat_qxl_blank_screen(pScreen, SCREEN_SAVER_ON);
-
- miClearVisualTypes();
- if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
-@@ -968,14 +968,14 @@ qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
- /* Note we do this before setting pScrn->virtualY to match our current
- mode, so as to allocate a buffer large enough for the largest mode.
- FIXME: add support for resizing the framebuffer on modeset. */
-- qxl->fb = xcalloc(pScrn->virtualY * pScrn->displayWidth, 4);
-- if (!qxl->fb)
-+ compat_qxl->fb = xcalloc(pScrn->virtualY * pScrn->displayWidth, 4);
-+ if (!compat_qxl->fb)
- goto out;
+@@ -145,13 +145,13 @@ typedef enum {
+ QXL_IMAGE_TYPE_LZ_RGB,
+ QXL_IMAGE_TYPE_GLZ_RGB,
+ QXL_IMAGE_TYPE_FROM_CACHE,
+-} qxl_image_type;
++} compat_qxl_image_type;
- pScrn->virtualX = pScrn->currentMode->HDisplay;
- pScrn->virtualY = pScrn->currentMode->VDisplay;
-
-- if (!fbScreenInit(pScreen, qxl->fb,
-+ if (!fbScreenInit(pScreen, compat_qxl->fb,
- pScrn->currentMode->HDisplay,
- pScrn->currentMode->VDisplay,
- pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
-@@ -1001,59 +1001,59 @@ qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
-
- fbPictureInit(pScreen, 0, 0);
+ typedef enum {
+ QXL_IMAGE_CACHE = (1 << 0)
+-} qxl_image_flags;
++} compat_qxl_image_flags;
-- qxl->create_screen_resources = pScreen->CreateScreenResources;
-- pScreen->CreateScreenResources = qxl_create_screen_resources;
-+ compat_qxl->create_screen_resources = pScreen->CreateScreenResources;
-+ pScreen->CreateScreenResources = compat_qxl_create_screen_resources;
+-struct qxl_image_descriptor
++struct compat_qxl_image_descriptor
+ {
+ uint64_t id;
+ uint8_t type;
+@@ -160,7 +160,7 @@ struct qxl_image_descriptor
+ uint32_t height;
+ };
- /* Set up resources */
-- qxl->mem = qxl_mem_create ((void *)((unsigned long)qxl->ram + (unsigned long)rom->pages_offset),
-+ compat_qxl->mem = compat_qxl_mem_create ((void *)((unsigned long)compat_qxl->ram + (unsigned long)rom->pages_offset),
- rom->num_io_pages * getpagesize());
-- qxl->io_pages = (void *)((unsigned long)qxl->ram + (unsigned long)rom->pages_offset);
-- qxl->io_pages_physical = (void *)((unsigned long)qxl->ram_physical + (unsigned long)rom->pages_offset);
--
-- qxl->command_ring = qxl_ring_create (&(ram_header->cmd_ring_hdr),
-- sizeof (struct qxl_command),
-- 32, qxl->io_base + QXL_IO_NOTIFY_CMD);
-- qxl->cursor_ring = qxl_ring_create (&(ram_header->cursor_ring_hdr),
-- sizeof (struct qxl_command),
-- 32, qxl->io_base + QXL_IO_NOTIFY_CURSOR);
-- qxl->release_ring = qxl_ring_create (&(ram_header->release_ring_hdr),
-+ compat_qxl->io_pages = (void *)((unsigned long)compat_qxl->ram + (unsigned long)rom->pages_offset);
-+ compat_qxl->io_pages_physical = (void *)((unsigned long)compat_qxl->ram_physical + (unsigned long)rom->pages_offset);
-+
-+ compat_qxl->command_ring = compat_qxl_ring_create (&(ram_header->cmd_ring_hdr),
-+ sizeof (struct compat_qxl_command),
-+ 32, compat_qxl->io_base + QXL_IO_NOTIFY_CMD);
-+ compat_qxl->cursor_ring = compat_qxl_ring_create (&(ram_header->cursor_ring_hdr),
-+ sizeof (struct compat_qxl_command),
-+ 32, compat_qxl->io_base + QXL_IO_NOTIFY_CURSOR);
-+ compat_qxl->release_ring = compat_qxl_ring_create (&(ram_header->release_ring_hdr),
- sizeof (uint64_t),
- 8, 0);
-
- /* xf86DPMSInit(pScreen, xf86DPMSSet, 0); */
+-struct qxl_data_chunk {
++struct compat_qxl_data_chunk {
+ uint32_t data_size;
+ uint64_t prev_chunk;
+ uint64_t next_chunk;
+@@ -179,90 +179,90 @@ typedef enum
+ QXL_BITMAP_FMT_24BIT,
+ QXL_BITMAP_FMT_32BIT,
+ QXL_BITMAP_FMT_RGBA,
+-} qxl_bitmap_format;
++} compat_qxl_bitmap_format;
- #if 0 /* XV accel */
-- qxlInitVideo(pScreen);
-+ compat_qxlInitVideo(pScreen);
- #endif
+ typedef enum {
+ QXL_BITMAP_PAL_CACHE_ME = (1 << 0),
+ QXL_BITMAP_PAL_FROM_CACHE = (1 << 1),
+ QXL_BITMAP_TOP_DOWN = (1 << 2),
+-} qxl_bitmap_flags;
++} compat_qxl_bitmap_flags;
-- pScreen->SaveScreen = qxl_blank_screen;
-- qxl->close_screen = pScreen->CloseScreen;
-- pScreen->CloseScreen = qxl_close_screen;
-+ pScreen->SaveScreen = compat_qxl_blank_screen;
-+ compat_qxl->close_screen = pScreen->CloseScreen;
-+ pScreen->CloseScreen = compat_qxl_close_screen;
+-struct qxl_bitmap {
++struct compat_qxl_bitmap {
+ uint8_t format;
+ uint8_t flags;
+ uint32_t x; /* actually width */
+ uint32_t y; /* actually height */
+ uint32_t stride; /* in bytes */
+ uint64_t palette; /* Can be NULL */
+- uint64_t data; /* A qxl_data_chunk that actually contains the data */
++ uint64_t data; /* A compat_qxl_data_chunk that actually contains the data */
+ };
-- qxl->create_gc = pScreen->CreateGC;
-- pScreen->CreateGC = qxl_create_gc;
-+ compat_qxl->create_gc = pScreen->CreateGC;
-+ pScreen->CreateGC = compat_qxl_create_gc;
+-struct qxl_image {
+- struct qxl_image_descriptor descriptor;
++struct compat_qxl_image {
++ struct compat_qxl_image_descriptor descriptor;
+ union
+ {
+- struct qxl_bitmap bitmap;
++ struct compat_qxl_bitmap bitmap;
+ } u;
+ };
- #if 0
-- qxl->paint_window_background = pScreen->PaintWindowBackground;
-- qxl->paint_window_border = pScreen->PaintWindowBorder;
-+ compat_qxl->paint_window_background = pScreen->PaintWindowBackground;
-+ compat_qxl->paint_window_border = pScreen->PaintWindowBorder;
- #endif
-- qxl->copy_window = pScreen->CopyWindow;
-+ compat_qxl->copy_window = pScreen->CopyWindow;
- #if 0
-- pScreen->PaintWindowBackground = qxl_paint_window;
-- pScreen->PaintWindowBorder = qxl_paint_window;
-+ pScreen->PaintWindowBackground = compat_qxl_paint_window;
-+ pScreen->PaintWindowBorder = compat_qxl_paint_window;
- #endif
-- pScreen->CopyWindow = qxl_copy_window;
-+ pScreen->CopyWindow = compat_qxl_copy_window;
+-struct qxl_fill {
+- struct qxl_brush brush;
++struct compat_qxl_fill {
++ struct compat_qxl_brush brush;
+ unsigned short rop_descriptor;
+- struct qxl_mask mask;
++ struct compat_qxl_mask mask;
+ };
- miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+-struct qxl_opaque {
++struct compat_qxl_opaque {
+ uint64_t src_bitmap;
+- struct qxl_rect src_area;
+- struct qxl_brush brush;
++ struct compat_qxl_rect src_area;
++ struct compat_qxl_brush brush;
+ unsigned short rop_descriptor;
+ unsigned char scale_mode;
+- struct qxl_mask mask;
++ struct compat_qxl_mask mask;
+ };
- if (!miCreateDefColormap(pScreen))
- goto out;
+-struct qxl_copy {
++struct compat_qxl_copy {
+ uint64_t src_bitmap;
+- struct qxl_rect src_area;
++ struct compat_qxl_rect src_area;
+ unsigned short rop_descriptor;
+ unsigned char scale_mode;
+- struct qxl_mask mask;
++ struct compat_qxl_mask mask;
+ };
-- qxl_cursor_init (pScreen);
-+ compat_qxl_cursor_init (pScreen);
-
- CHECK_POINT();
+-struct qxl_transparent {
++struct compat_qxl_transparent {
+ uint64_t src_bitmap;
+- struct qxl_rect src_area;
++ struct compat_qxl_rect src_area;
+ uint32_t src_color;
+ uint32_t true_color;
+ };
-- qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
-+ compat_qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
+-struct qxl_alpha_blend {
++struct compat_qxl_alpha_blend {
+ unsigned char alpha;
+ uint64_t src_bitmap;
+- struct qxl_rect src_area;
++ struct compat_qxl_rect src_area;
+ };
- CHECK_POINT();
-
-@@ -1064,26 +1064,26 @@ out:
- }
+-struct qxl_copy_bits {
+- struct qxl_point src_pos;
++struct compat_qxl_copy_bits {
++ struct compat_qxl_point src_pos;
+ };
- static Bool
--qxl_enter_vt(int scrnIndex, int flags)
-+compat_qxl_enter_vt(int scrnIndex, int flags)
- {
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+-struct qxl_blend { /* same as copy */
++struct compat_qxl_blend { /* same as copy */
+ uint64_t src_bitmap;
+- struct qxl_rect src_area;
++ struct compat_qxl_rect src_area;
+ unsigned short rop_descriptor;
+ unsigned char scale_mode;
+- struct qxl_mask mask;
++ struct compat_qxl_mask mask;
+ };
-- qxl_save_state(pScrn);
-- qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
-+ compat_qxl_save_state(pScrn);
-+ compat_qxl_switch_mode(scrnIndex, pScrn->currentMode, 0);
+-struct qxl_rop3 {
++struct compat_qxl_rop3 {
+ uint64_t src_bitmap;
+- struct qxl_rect src_area;
+- struct qxl_brush brush;
++ struct compat_qxl_rect src_area;
++ struct compat_qxl_brush brush;
+ unsigned char rop3;
+ unsigned char scale_mode;
+- struct qxl_mask mask;
++ struct compat_qxl_mask mask;
+ };
- return TRUE;
- }
+-struct qxl_line_attr {
++struct compat_qxl_line_attr {
+ unsigned char flags;
+ unsigned char join_style;
+ unsigned char end_style;
+@@ -272,33 +272,33 @@ struct qxl_line_attr {
+ uint64_t style;
+ };
- static void
--qxl_leave_vt(int scrnIndex, int flags)
-+compat_qxl_leave_vt(int scrnIndex, int flags)
- {
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+-struct qxl_stroke {
++struct compat_qxl_stroke {
+ uint64_t path;
+- struct qxl_line_attr attr;
+- struct qxl_brush brush;
++ struct compat_qxl_line_attr attr;
++ struct compat_qxl_brush brush;
+ unsigned short fore_mode;
+ unsigned short back_mode;
+ };
-- qxl_restore_state(pScrn);
-+ compat_qxl_restore_state(pScrn);
- }
+-struct qxl_text {
++struct compat_qxl_text {
+ uint64_t str;
+- struct qxl_rect back_area;
+- struct qxl_brush fore_brush;
+- struct qxl_brush back_brush;
++ struct compat_qxl_rect back_area;
++ struct compat_qxl_brush fore_brush;
++ struct compat_qxl_brush back_brush;
+ unsigned short fore_mode;
+ unsigned short back_mode;
+ };
- static Bool
--qxl_color_setup(ScrnInfoPtr pScrn)
-+compat_qxl_color_setup(ScrnInfoPtr pScrn)
- {
- int scrnIndex = pScrn->scrnIndex;
- Gamma gzeros = { 0.0, 0.0, 0.0 };
-@@ -1113,13 +1113,13 @@ qxl_color_setup(ScrnInfoPtr pScrn)
- }
+-struct qxl_blackness {
+- struct qxl_mask mask;
++struct compat_qxl_blackness {
++ struct compat_qxl_mask mask;
+ };
- static void
--print_modes (qxl_screen_t *qxl, int scrnIndex)
-+print_modes (compat_qxl_screen_t *compat_qxl, int scrnIndex)
- {
- int i;
+-struct qxl_inverse {
+- struct qxl_mask mask;
++struct compat_qxl_inverse {
++ struct compat_qxl_mask mask;
+ };
-- for (i = 0; i < qxl->num_modes; ++i)
-+ for (i = 0; i < compat_qxl->num_modes; ++i)
- {
-- struct qxl_mode *m = qxl->modes + i;
-+ struct compat_qxl_mode *m = compat_qxl->modes + i;
+-struct qxl_whiteness {
+- struct qxl_mask mask;
++struct compat_qxl_whiteness {
++ struct compat_qxl_mask mask;
+ };
- xf86DrvMsg (scrnIndex, X_INFO,
- "%d: %dx%d, %d bits, stride %d, %dmm x %dmm, orientation %d\n",
-@@ -1129,11 +1129,11 @@ print_modes (qxl_screen_t *qxl, int scrnIndex)
- }
+ /* Effects */
+@@ -312,14 +312,14 @@ typedef enum
+ QXL_EFFECT_NOP_ON_DUP,
+ QXL_EFFECT_NOP,
+ QXL_EFFECT_OPAQUE_BRUSH
+-} qxl_effect_type;
++} compat_qxl_effect_type;
- static Bool
--qxl_check_device(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
-+compat_qxl_check_device(ScrnInfoPtr pScrn, compat_qxl_screen_t *compat_qxl)
+ typedef enum
{
- int scrnIndex = pScrn->scrnIndex;
-- struct qxl_rom *rom = qxl->rom;
-- struct qxl_ram_header *ram_header = (void *)((unsigned long)qxl->ram + rom->ram_header_offset);
-+ struct compat_qxl_rom *rom = compat_qxl->rom;
-+ struct compat_qxl_ram_header *ram_header = (void *)((unsigned long)compat_qxl->ram + rom->ram_header_offset);
+ QXL_CLIP_TYPE_NONE,
+ QXL_CLIP_TYPE_RECTS,
+ QXL_CLIP_TYPE_PATH,
+-} qxl_clip_type;
++} compat_qxl_clip_type;
- CHECK_POINT();
-
-@@ -1170,24 +1170,24 @@ qxl_check_device(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
- xf86DrvMsg(scrnIndex, X_INFO, "Correct RAM signature %x\n",
- ram_header->magic);
+ typedef enum {
+ QXL_DRAW_NOP,
+@@ -336,41 +336,41 @@ typedef enum {
+ QXL_DRAW_TEXT,
+ QXL_DRAW_TRANSPARENT,
+ QXL_DRAW_ALPHA_BLEND,
+-} qxl_draw_type;
++} compat_qxl_draw_type;
-- qxl->draw_area_offset = rom->draw_area_offset;
-- qxl->draw_area_size = rom->draw_area_size;
-+ compat_qxl->draw_area_offset = rom->draw_area_offset;
-+ compat_qxl->draw_area_size = rom->draw_area_size;
- pScrn->videoRam = rom->draw_area_size / 1024;
-
- return TRUE;
- }
+-struct qxl_drawable {
+- union qxl_release_info release_info;
++struct compat_qxl_drawable {
++ union compat_qxl_release_info release_info;
+ unsigned char effect;
+ unsigned char type;
+ unsigned short bitmap_offset;
+- struct qxl_rect bitmap_area;
+- struct qxl_rect bbox;
+- struct qxl_clip clip;
++ struct compat_qxl_rect bitmap_area;
++ struct compat_qxl_rect bbox;
++ struct compat_qxl_clip clip;
+ uint32_t mm_time;
+ union {
+- struct qxl_fill fill;
+- struct qxl_opaque opaque;
+- struct qxl_copy copy;
+- struct qxl_transparent transparent;
+- struct qxl_alpha_blend alpha_blend;
+- struct qxl_copy_bits copy_bits;
+- struct qxl_blend blend;
+- struct qxl_rop3 rop3;
+- struct qxl_stroke stroke;
+- struct qxl_text text;
+- struct qxl_blackness blackness;
+- struct qxl_inverse inverse;
+- struct qxl_whiteness whiteness;
++ struct compat_qxl_fill fill;
++ struct compat_qxl_opaque opaque;
++ struct compat_qxl_copy copy;
++ struct compat_qxl_transparent transparent;
++ struct compat_qxl_alpha_blend alpha_blend;
++ struct compat_qxl_copy_bits copy_bits;
++ struct compat_qxl_blend blend;
++ struct compat_qxl_rop3 rop3;
++ struct compat_qxl_stroke stroke;
++ struct compat_qxl_text text;
++ struct compat_qxl_blackness blackness;
++ struct compat_qxl_inverse inverse;
++ struct compat_qxl_whiteness whiteness;
+ } u;
+ };
- static int
--qxl_find_native_mode(ScrnInfoPtr pScrn, DisplayModePtr p)
-+compat_qxl_find_native_mode(ScrnInfoPtr pScrn, DisplayModePtr p)
- {
- int i;
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
+-struct qxl_update_cmd {
+- union qxl_release_info release_info;
+- struct qxl_rect area;
++struct compat_qxl_update_cmd {
++ union compat_qxl_release_info release_info;
++ struct compat_qxl_rect area;
+ uint32_t update_id;
+ };
- CHECK_POINT();
-
-- for (i = 0; i < qxl->num_modes; i++)
-+ for (i = 0; i < compat_qxl->num_modes; i++)
- {
-- struct qxl_mode *m = qxl->modes + i;
-+ struct compat_qxl_mode *m = compat_qxl->modes + i;
+-struct qxl_point16 {
++struct compat_qxl_point16 {
+ int16_t x;
+ int16_t y;
+ };
+@@ -394,7 +394,7 @@ enum {
+ CURSOR_TYPE_COLOR32,
+ };
- if (m->x_res == p->HDisplay &&
- m->y_res == p->VDisplay &&
-@@ -1212,20 +1212,20 @@ qxl_find_native_mode(ScrnInfoPtr pScrn, DisplayModePtr p)
- }
+-struct qxl_cursor_header {
++struct compat_qxl_cursor_header {
+ uint64_t unique;
+ uint16_t type;
+ uint16_t width;
+@@ -403,19 +403,19 @@ struct qxl_cursor_header {
+ uint16_t hot_spot_y;
+ };
- static ModeStatus
--qxl_valid_mode(int scrn, DisplayModePtr p, Bool flag, int pass)
-+compat_qxl_valid_mode(int scrn, DisplayModePtr p, Bool flag, int pass)
+-struct qxl_cursor
++struct compat_qxl_cursor
{
- ScrnInfoPtr pScrn = xf86Screens[scrn];
-- qxl_screen_t *qxl = pScrn->driverPrivate;
-+ compat_qxl_screen_t *compat_qxl = pScrn->driverPrivate;
- int bpp = pScrn->bitsPerPixel;
- int mode_idx;
-
- /* FIXME: I don't think this is necessary now that we report the
- * correct amount of video ram?
- */
-- if (p->HDisplay * p->VDisplay * (bpp/8) > qxl->draw_area_size)
-+ if (p->HDisplay * p->VDisplay * (bpp/8) > compat_qxl->draw_area_size)
- return MODE_MEM;
+- struct qxl_cursor_header header;
++ struct compat_qxl_cursor_header header;
+ uint32_t data_size;
+- struct qxl_data_chunk chunk;
++ struct compat_qxl_data_chunk chunk;
+ };
-- mode_idx = qxl_find_native_mode (pScrn, p);
-+ mode_idx = compat_qxl_find_native_mode (pScrn, p);
- if (mode_idx == -1)
- return MODE_NOMODE;
+-struct qxl_cursor_cmd {
+- union qxl_release_info release_info;
++struct compat_qxl_cursor_cmd {
++ union compat_qxl_release_info release_info;
+ uint8_t type;
+ union {
+ struct {
+- struct qxl_point16 position;
++ struct compat_qxl_point16 position;
+ unsigned char visible;
+ uint64_t shape;
+ } set;
+@@ -423,12 +423,12 @@ struct qxl_cursor_cmd {
+ uint16_t length;
+ uint16_t frequency;
+ } trail;
+- struct qxl_point16 position;
++ struct compat_qxl_point16 position;
+ } u;
+ uint8_t device_data[QXL_CURSOR_DEVICE_DATA_SIZE];
+ };
-@@ -1234,7 +1234,7 @@ qxl_valid_mode(int scrn, DisplayModePtr p, Bool flag, int pass)
- return MODE_OK;
- }
+-struct qxl_rom {
++struct compat_qxl_rom {
+ uint32_t magic;
+ uint32_t id;
+ uint32_t update_id;
+@@ -444,7 +444,7 @@ struct qxl_rom {
+ uint32_t mm_clock;
+ };
--static void qxl_add_mode(ScrnInfoPtr pScrn, int width, int height, int type)
-+static void compat_qxl_add_mode(ScrnInfoPtr pScrn, int width, int height, int type)
- {
- DisplayModePtr mode;
+-struct qxl_ring_header {
++struct compat_qxl_ring_header {
+ uint32_t num_items;
+ uint32_t prod;
+ uint32_t notify_on_prod;
+@@ -454,38 +454,38 @@ struct qxl_ring_header {
-@@ -1263,10 +1263,10 @@ static void qxl_add_mode(ScrnInfoPtr pScrn, int width, int height, int type)
- }
+ #define QXL_LOG_BUF_SIZE 4096
- static Bool
--qxl_pre_init(ScrnInfoPtr pScrn, int flags)
-+compat_qxl_pre_init(ScrnInfoPtr pScrn, int flags)
- {
- int i, scrnIndex = pScrn->scrnIndex;
-- qxl_screen_t *qxl = NULL;
-+ compat_qxl_screen_t *compat_qxl = NULL;
- ClockRangePtr clockRanges = NULL;
- int *linePitches = NULL;
- DisplayModePtr mode;
-@@ -1281,27 +1281,27 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
- }
+-struct qxl_ram_header {
++struct compat_qxl_ram_header {
+ uint32_t magic;
+ uint32_t int_pending;
+ uint32_t int_mask;
+ unsigned char log_buf[QXL_LOG_BUF_SIZE];
+- struct qxl_ring_header cmd_ring_hdr;
+- struct qxl_command cmd_ring[32];
+- struct qxl_ring_header cursor_ring_hdr;
+- struct qxl_command cursor_ring[32];
+- struct qxl_ring_header release_ring_hdr;
++ struct compat_qxl_ring_header cmd_ring_hdr;
++ struct compat_qxl_command cmd_ring[32];
++ struct compat_qxl_ring_header cursor_ring_hdr;
++ struct compat_qxl_command cursor_ring[32];
++ struct compat_qxl_ring_header release_ring_hdr;
+ uint64_t release_ring[8];
+- struct qxl_rect update_area;
++ struct compat_qxl_rect update_area;
+ };
- if (!pScrn->driverPrivate)
-- pScrn->driverPrivate = xnfcalloc(sizeof(qxl_screen_t), 1);
-- qxl = pScrn->driverPrivate;
-+ pScrn->driverPrivate = xnfcalloc(sizeof(compat_qxl_screen_t), 1);
-+ compat_qxl = pScrn->driverPrivate;
-
-- qxl->entity = xf86GetEntityInfo(pScrn->entityList[0]);
-- qxl->pci = xf86GetPciInfoForEntity(qxl->entity->index);
-+ compat_qxl->entity = xf86GetEntityInfo(pScrn->entityList[0]);
-+ compat_qxl->pci = xf86GetPciInfoForEntity(compat_qxl->entity->index);
- #ifndef XSERVER_LIBPCIACCESS
-- qxl->pci_tag = pciTag(qxl->pci->bus, qxl->pci->device, qxl->pci->func);
-+ compat_qxl->pci_tag = pciTag(compat_qxl->pci->bus, compat_qxl->pci->device, compat_qxl->pci->func);
- #endif
+ #pragma pack(pop)
- pScrn->monitor = pScrn->confScreen->monitor;
+-typedef struct _qxl_screen_t qxl_screen_t;
++typedef struct _compat_qxl_screen_t compat_qxl_screen_t;
-- if (!qxl_color_setup(pScrn))
-+ if (!compat_qxl_color_setup(pScrn))
- goto out;
+-struct _qxl_screen_t
++struct _compat_qxl_screen_t
+ {
+ /* These are the names QXL uses */
+ void * ram; /* Video RAM */
+ void * ram_physical;
+ void * vram; /* Command RAM */
+- struct qxl_rom * rom; /* Parameter RAM */
++ struct compat_qxl_rom * rom; /* Parameter RAM */
+
+- struct qxl_ring * command_ring;
+- struct qxl_ring * cursor_ring;
+- struct qxl_ring * release_ring;
++ struct compat_qxl_ring * command_ring;
++ struct compat_qxl_ring * cursor_ring;
++ struct compat_qxl_ring * release_ring;
+
+ int num_modes;
+- struct qxl_mode * modes;
++ struct compat_qxl_mode * modes;
+ int io_base;
+ int draw_area_offset;
+ int draw_area_size;
+@@ -493,7 +493,7 @@ struct _qxl_screen_t
+ void * fb;
+ int bytes_per_pixel;
- /* option parsing and card differentiation */
- xf86CollectOptions(pScrn, NULL);
+- struct qxl_mem * mem; /* Context for qxl_alloc/free */
++ struct compat_qxl_mem * mem; /* Context for compat_qxl_alloc/free */
-- if (!qxl_map_memory(qxl, scrnIndex))
-+ if (!compat_qxl_map_memory(compat_qxl, scrnIndex))
- goto out;
+ EntityInfoPtr entity;
-- if (!qxl_check_device(pScrn, qxl))
-+ if (!compat_qxl_check_device(pScrn, compat_qxl))
- goto out;
+@@ -530,15 +530,15 @@ struct _qxl_screen_t
+ };
- /* ddc stuff here */
-@@ -1328,22 +1328,22 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
- }
+ static inline uint64_t
+-physical_address (qxl_screen_t *qxl, void *virtual)
++physical_address (compat_qxl_screen_t *compat_qxl, void *virtual)
+ {
+- return (uint64_t) ((unsigned long)virtual + (((unsigned long)qxl->ram_physical - (unsigned long)qxl->ram)));
++ return (uint64_t) ((unsigned long)virtual + (((unsigned long)compat_qxl->ram_physical - (unsigned long)compat_qxl->ram)));
+ }
- /* Add any modes not in xorg's default mode list */
-- for (i = 0; i < qxl->num_modes; i++)
-- if (qxl->modes[i].orientation == 0) {
-- qxl_add_mode(pScrn, qxl->modes[i].x_res, qxl->modes[i].y_res,
-+ for (i = 0; i < compat_qxl->num_modes; i++)
-+ if (compat_qxl->modes[i].orientation == 0) {
-+ compat_qxl_add_mode(pScrn, compat_qxl->modes[i].x_res, compat_qxl->modes[i].y_res,
- M_T_DRIVER);
-- if (qxl->modes[i].x_res > max_x)
-- max_x = qxl->modes[i].x_res;
-- if (qxl->modes[i].y_res > max_y)
-- max_y = qxl->modes[i].y_res;
-+ if (compat_qxl->modes[i].x_res > max_x)
-+ max_x = compat_qxl->modes[i].x_res;
-+ if (compat_qxl->modes[i].y_res > max_y)
-+ max_y = compat_qxl->modes[i].y_res;
- }
+ static inline void *
+-virtual_address (qxl_screen_t *qxl, void *physical)
++virtual_address (compat_qxl_screen_t *compat_qxl, void *physical)
+ {
+- return (void *) ((unsigned long)physical + ((unsigned long)qxl->ram - (unsigned long)qxl->ram_physical));
++ return (void *) ((unsigned long)physical + ((unsigned long)compat_qxl->ram - (unsigned long)compat_qxl->ram_physical));
+ }
- if (pScrn->display->virtualX == 0 && pScrn->display->virtualY == 0) {
- /* It is possible for the largest x + largest y size combined leading
- to a virtual size which will not fit into the framebuffer when this
- happens we prefer max width and make height as large as possible */
-- if (max_x * max_y * (pScrn->bitsPerPixel / 8) > qxl->draw_area_size)
-- pScrn->display->virtualY = qxl->draw_area_size /
-+ if (max_x * max_y * (pScrn->bitsPerPixel / 8) > compat_qxl->draw_area_size)
-+ pScrn->display->virtualY = compat_qxl->draw_area_size /
- (max_x * (pScrn->bitsPerPixel / 8));
- else
- pScrn->display->virtualY = max_y;
-@@ -1381,14 +1381,14 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
- goto out;
- }
+ static inline void *
+@@ -553,58 +553,58 @@ pointer_to_u64 (void *p)
+ return (uint64_t)(unsigned long)p;
+ }
-- print_modes (qxl, scrnIndex);
-+ print_modes (compat_qxl, scrnIndex);
+-struct qxl_ring;
++struct compat_qxl_ring;
- /* VGA hardware initialisation */
- if (!vgaHWGetHWRec(pScrn))
- return FALSE;
+ /*
+ * HW cursor
+ */
+-void qxl_cursor_init (ScreenPtr pScreen);
++void compat_qxl_cursor_init (ScreenPtr pScreen);
- /* hate */
-- qxl_unmap_memory(qxl, scrnIndex);
-+ compat_qxl_unmap_memory(compat_qxl, scrnIndex);
- CHECK_POINT();
-
-@@ -1398,19 +1398,19 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
- out:
- if (clockRanges)
- xfree(clockRanges);
-- if (qxl)
-- xfree(qxl);
-+ if (compat_qxl)
-+ xfree(compat_qxl);
- return FALSE;
- }
+ /*
+ * Rings
+ */
+-struct qxl_ring * qxl_ring_create (struct qxl_ring_header *header,
++struct compat_qxl_ring * compat_qxl_ring_create (struct compat_qxl_ring_header *header,
+ int element_size,
+ int n_elements,
+ int prod_notify);
+-void qxl_ring_push (struct qxl_ring *ring,
++void compat_qxl_ring_push (struct compat_qxl_ring *ring,
+ const void *element);
+-Bool qxl_ring_pop (struct qxl_ring *ring,
++Bool compat_qxl_ring_pop (struct compat_qxl_ring *ring,
+ void *element);
+-void qxl_ring_wait_idle (struct qxl_ring *ring);
++void compat_qxl_ring_wait_idle (struct compat_qxl_ring *ring);
- #ifdef XSERVER_LIBPCIACCESS
--enum qxl_class
-+enum compat_qxl_class
- {
- CHIP_QXL_1,
- };
--static const struct pci_id_match qxl_device_match[] = {
-+static const struct pci_id_match compat_qxl_device_match[] = {
- {
- PCI_VENDOR_RED_HAT, PCI_CHIP_QXL_0100, PCI_MATCH_ANY, PCI_MATCH_ANY,
- 0x00030000, 0x00ffffff, CHIP_QXL_1
-@@ -1420,14 +1420,14 @@ static const struct pci_id_match qxl_device_match[] = {
- };
- #endif
--static SymTabRec qxlChips[] =
-+static SymTabRec compat_qxlChips[] =
- {
- { PCI_CHIP_QXL_0100, "QXL 1", },
- { -1, NULL }
- };
+ /*
+ * Images
+ */
+-struct qxl_image *qxl_image_create (qxl_screen_t *qxl,
++struct compat_qxl_image *compat_qxl_image_create (compat_qxl_screen_t *compat_qxl,
+ const uint8_t *data,
+ int x,
+ int y,
+ int width,
+ int height,
+ int stride);
+-void qxl_image_destroy (qxl_screen_t *qxl,
+- struct qxl_image *image);
+-void qxl_drop_image_cache (qxl_screen_t *qxl);
++void compat_qxl_image_destroy (compat_qxl_screen_t *compat_qxl,
++ struct compat_qxl_image *image);
++void compat_qxl_drop_image_cache (compat_qxl_screen_t *compat_qxl);
- #ifndef XSERVER_LIBPCIACCESS
--static PciChipsets qxlPciChips[] =
-+static PciChipsets compat_qxlPciChips[] =
- {
- { PCI_CHIP_QXL_0100, PCI_CHIP_QXL_0100, RES_SHARED_VGA },
- { -1, -1, RES_UNDEFINED }
-@@ -1435,20 +1435,20 @@ static PciChipsets qxlPciChips[] =
- #endif
- static void
--qxl_identify(int flags)
-+compat_qxl_identify(int flags)
- {
-- xf86PrintChipsets("qxl", "Driver for QXL virtual graphics", qxlChips);
-+ xf86PrintChipsets("compat_qxl", "Driver for QXL virtual graphics", compat_qxlChips);
- }
+ /*
+ * Malloc
+ */
+-struct qxl_mem * qxl_mem_create (void *base,
++struct compat_qxl_mem * compat_qxl_mem_create (void *base,
+ unsigned long n_bytes);
+-void qxl_mem_dump_stats (struct qxl_mem *mem,
++void compat_qxl_mem_dump_stats (struct compat_qxl_mem *mem,
+ const char *header);
+-void * qxl_alloc (struct qxl_mem *mem,
++void * compat_qxl_alloc (struct compat_qxl_mem *mem,
+ unsigned long n_bytes);
+-void qxl_free (struct qxl_mem *mem,
++void compat_qxl_free (struct compat_qxl_mem *mem,
+ void *d);
+-void qxl_mem_free_all (struct qxl_mem *mem);
+-void * qxl_allocnf (qxl_screen_t *qxl,
++void compat_qxl_mem_free_all (struct compat_qxl_mem *mem);
++void * compat_qxl_allocnf (compat_qxl_screen_t *compat_qxl,
+ unsigned long size);
--static void
--qxl_init_scrn(ScrnInfoPtr pScrn)
-+void
-+compat_init_scrn(ScrnInfoPtr pScrn)
- {
- pScrn->driverVersion = 0;
-- pScrn->driverName = pScrn->name = "qxl";
-- pScrn->PreInit = qxl_pre_init;
-- pScrn->ScreenInit = qxl_screen_init;
-- pScrn->SwitchMode = qxl_switch_mode;
-- pScrn->ValidMode = qxl_valid_mode;
-- pScrn->EnterVT = qxl_enter_vt;
-- pScrn->LeaveVT = qxl_leave_vt;
-+ pScrn->driverName = pScrn->name = "compat_qxl";
-+ pScrn->PreInit = compat_qxl_pre_init;
-+ pScrn->ScreenInit = compat_qxl_screen_init;
-+ pScrn->SwitchMode = compat_qxl_switch_mode;
-+ pScrn->ValidMode = compat_qxl_valid_mode;
-+ pScrn->EnterVT = compat_qxl_enter_vt;
-+ pScrn->LeaveVT = compat_qxl_leave_vt;
- }
-diff --git a/src/compat/compat-qxl_image.c b/src/compat/compat-qxl_image.c
-index d2ac12d..2307138 100644
---- a/src/compat/compat-qxl_image.c
-+++ b/src/compat/compat-qxl_image.c
-@@ -8,7 +8,7 @@ typedef struct image_info_t image_info_t;
+
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_image.c.compat2 xf86-video-qxl-20130514/src/compat/compat-qxl_image.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_image.c.compat2 2013-07-03 14:19:39.010334593 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_image.c 2013-07-03 14:19:56.103748552 +1000
+@@ -8,7 +8,7 @@ typedef struct image_info_t image_info_t
struct image_info_t
{
@@ -2365,7 +2305,7 @@ index d2ac12d..2307138 100644
int ref_count;
image_info_t *next;
};
-@@ -33,7 +33,7 @@ hash_and_copy (const uint8_t *src, int src_stride,
+@@ -33,7 +33,7 @@ hash_and_copy (const uint8_t *src, int s
if (dest)
memcpy (dest_line, src_line, n_bytes);
@@ -2405,7 +2345,7 @@ index d2ac12d..2307138 100644
info = lookup_image_info (hash, width, height);
if (info)
-@@ -120,11 +120,11 @@ qxl_image_create (qxl_screen_t *qxl, const uint8_t *data,
+@@ -120,11 +120,11 @@ qxl_image_create (qxl_screen_t *qxl, con
for (i = 0; i < height; ++i)
{
@@ -2419,7 +2359,7 @@ index d2ac12d..2307138 100644
dest_line = (uint32_t *)chunk->data + width * i;
-@@ -147,9 +147,9 @@ qxl_image_create (qxl_screen_t *qxl, const uint8_t *data,
+@@ -147,9 +147,9 @@ qxl_image_create (qxl_screen_t *qxl, con
}
else
{
@@ -2432,7 +2372,7 @@ index d2ac12d..2307138 100644
image_info_t *info;
#if 0
-@@ -159,7 +159,7 @@ qxl_image_create (qxl_screen_t *qxl, const uint8_t *data,
+@@ -159,7 +159,7 @@ qxl_image_create (qxl_screen_t *qxl, con
/* Chunk */
/* FIXME: Check integer overflow */
@@ -2441,7 +2381,7 @@ index d2ac12d..2307138 100644
chunk->data_size = height * dest_stride;
chunk->prev_chunk = 0;
-@@ -167,10 +167,10 @@ qxl_image_create (qxl_screen_t *qxl, const uint8_t *data,
+@@ -167,10 +167,10 @@ qxl_image_create (qxl_screen_t *qxl, con
hash_and_copy (data, stride,
chunk->data, dest_stride,
@@ -2454,7 +2394,7 @@ index d2ac12d..2307138 100644
image->descriptor.id = 0;
image->descriptor.type = QXL_IMAGE_TYPE_BITMAP;
-@@ -179,7 +179,7 @@ qxl_image_create (qxl_screen_t *qxl, const uint8_t *data,
+@@ -179,7 +179,7 @@ qxl_image_create (qxl_screen_t *qxl, con
image->descriptor.width = width;
image->descriptor.height = height;
@@ -2463,7 +2403,7 @@ index d2ac12d..2307138 100644
{
image->u.bitmap.format = QXL_BITMAP_FMT_16BIT;
}
-@@ -191,9 +191,9 @@ qxl_image_create (qxl_screen_t *qxl, const uint8_t *data,
+@@ -191,9 +191,9 @@ qxl_image_create (qxl_screen_t *qxl, con
image->u.bitmap.flags = QXL_BITMAP_TOP_DOWN;
image->u.bitmap.x = width;
image->u.bitmap.y = height;
@@ -2475,7 +2415,7 @@ index d2ac12d..2307138 100644
#if 0
ErrorF ("%p has size %d %d\n", image, width, height);
-@@ -218,13 +218,13 @@ qxl_image_create (qxl_screen_t *qxl, const uint8_t *data,
+@@ -218,13 +218,13 @@ qxl_image_create (qxl_screen_t *qxl, con
}
void
@@ -2509,10 +2449,9 @@ index d2ac12d..2307138 100644
{
memset (image_table, 0, HASH_SIZE * sizeof (image_info_t *));
}
-diff --git a/src/compat/compat-qxl_mem.c b/src/compat/compat-qxl_mem.c
-index 2f6fa6a..26e85f9 100644
---- a/src/compat/compat-qxl_mem.c
-+++ b/src/compat/compat-qxl_mem.c
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_mem.c.compat2 xf86-video-qxl-20130514/src/compat/compat-qxl_mem.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_mem.c.compat2 2013-07-03 14:19:39.010334593 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_mem.c 2013-07-03 14:19:56.104748592 +1000
@@ -22,7 +22,7 @@ struct block
} u;
};
@@ -2561,7 +2500,7 @@ index 2f6fa6a..26e85f9 100644
{
struct block *b;
int n_blocks;
-@@ -122,7 +122,7 @@ qxl_mem_dump_stats (struct qxl_mem *mem, const char *header)
+@@ -122,7 +122,7 @@ qxl_mem_dump_stats (struct qxl_mem *mem,
}
void *
@@ -2570,7 +2509,7 @@ index 2f6fa6a..26e85f9 100644
{
struct block *b, *prev;
-@@ -202,7 +202,7 @@ qxl_alloc (struct qxl_mem *mem, unsigned long n_bytes)
+@@ -202,7 +202,7 @@ qxl_alloc (struct qxl_mem *mem, unsigned
/* If we get here, we are out of memory, so print some stats */
#if 0
fprintf (stderr, "Failing to allocate %lu bytes\n", n_bytes);
@@ -2579,7 +2518,7 @@ index 2f6fa6a..26e85f9 100644
#endif
return NULL;
-@@ -213,7 +213,7 @@ qxl_alloc (struct qxl_mem *mem, unsigned long n_bytes)
+@@ -213,7 +213,7 @@ qxl_alloc (struct qxl_mem *mem, unsigned
* last unused block.
*/
static void
@@ -2588,7 +2527,7 @@ index 2f6fa6a..26e85f9 100644
struct block **before, struct block **after)
{
struct block *b;
-@@ -237,7 +237,7 @@ find_neighbours (struct qxl_mem *mem, void *data,
+@@ -237,7 +237,7 @@ find_neighbours (struct qxl_mem *mem, vo
}
void
@@ -2614,10 +2553,9 @@ index 2f6fa6a..26e85f9 100644
+ compat_qxl_mem_dump_stats (mem, "after free");
#endif
}
-diff --git a/src/compat/compat-qxl_ring.c b/src/compat/compat-qxl_ring.c
-index 9a34583..d875357 100644
---- a/src/compat/compat-qxl_ring.c
-+++ b/src/compat/compat-qxl_ring.c
+diff -up xf86-video-qxl-20130514/src/compat/compat-qxl_ring.c.compat2 xf86-video-qxl-20130514/src/compat/compat-qxl_ring.c
+--- xf86-video-qxl-20130514/src/compat/compat-qxl_ring.c.compat2 2013-07-03 14:19:39.010334593 +1000
++++ xf86-video-qxl-20130514/src/compat/compat-qxl_ring.c 2013-07-03 14:19:56.104748592 +1000
@@ -5,11 +5,11 @@
struct ring
@@ -2649,7 +2587,7 @@ index 9a34583..d875357 100644
ring = malloc (sizeof *ring);
if (!ring)
-@@ -38,10 +38,10 @@ qxl_ring_create (struct qxl_ring_header *header,
+@@ -38,10 +38,10 @@ qxl_ring_create (struct qxl_ring_header
}
void
@@ -2684,11 +2622,44 @@ index 9a34583..d875357 100644
{
while (ring->ring->header.cons != ring->ring->header.prod)
{
-diff --git a/src/qxl_driver.c b/src/qxl_driver.c
-index 8183565..fa8b704 100644
---- a/src/qxl_driver.c
-+++ b/src/qxl_driver.c
-@@ -1365,7 +1365,11 @@ qxl_pci_probe (DriverPtr drv, int entity, struct pci_device *dev, intptr_t match
+diff -up xf86-video-qxl-20130514/src/compat/Makefile.am.compat2 xf86-video-qxl-20130514/src/compat/Makefile.am
+--- xf86-video-qxl-20130514/src/compat/Makefile.am.compat2 2013-07-03 14:19:39.010334593 +1000
++++ xf86-video-qxl-20130514/src/compat/Makefile.am 2013-07-03 14:19:56.102748510 +1000
+@@ -24,13 +24,13 @@
+ # -avoid-version prevents gratuitous .0.0.0 version numbers on the end
+ # _ladir passes a dummy rpath to libtool so the thing will actually link
+ # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
+-qxl_drv_la_LTLIBRARIES = qxl_drv.la
+-qxl_drv_la_LDFLAGS = -module -avoid-version
+-qxl_drv_ladir = @moduledir@/drivers
+-AM_CFLAGS = -g
++
++noinst_LTLIBRARIES = compatdriver.la
++compatdriver_la_LDFLAGS = -module -avoid-version
++
+ AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS)
+
+-qxl_drv_la_SOURCES = \
++compatdriver_la_SOURCES = \
+ compat-qxl.h \
+ compat-qxl_driver.c \
+ compat-qxl_image.c \
+diff -up xf86-video-qxl-20130514/src/Makefile.am.compat2 xf86-video-qxl-20130514/src/Makefile.am
+--- xf86-video-qxl-20130514/src/Makefile.am.compat2 2013-07-03 14:19:56.102748510 +1000
++++ xf86-video-qxl-20130514/src/Makefile.am 2013-07-03 14:20:10.365094118 +1000
+@@ -34,7 +34,7 @@ qxl_drv_la_LTLIBRARIES = qxl_drv.la
+ qxl_drv_la_LDFLAGS = -module -avoid-version
+ qxl_drv_ladir = @moduledir@/drivers
+
+-qxl_drv_la_LIBADD = uxa/libuxa.la
++qxl_drv_la_LIBADD = uxa/libuxa.la compat/compatdriver.la
+ if LIBUDEV
+ qxl_drv_la_LIBADD += $(LIBUDEV_LIBS)
+ endif
+diff -up xf86-video-qxl-20130514/src/qxl_driver.c.compat2 xf86-video-qxl-20130514/src/qxl_driver.c
+--- xf86-video-qxl-20130514/src/qxl_driver.c.compat2 2013-05-14 11:13:00.000000000 +1000
++++ xf86-video-qxl-20130514/src/qxl_driver.c 2013-07-03 14:19:56.104748592 +1000
+@@ -1365,7 +1365,11 @@ qxl_pci_probe (DriverPtr drv, int entity
qxl = pScrn->driverPrivate;
qxl->pci = dev;
@@ -2701,6 +2672,3 @@ index 8183565..fa8b704 100644
return TRUE;
}
---
-1.8.2.1
-
diff --git a/xorg-x11-drv-qxl.spec b/xorg-x11-drv-qxl.spec
index 3d5baa9..3f3e89f 100644
--- a/xorg-x11-drv-qxl.spec
+++ b/xorg-x11-drv-qxl.spec
@@ -22,18 +22,19 @@ Name: xorg-x11-drv-qxl
Version: 0.1.1
-Release: 0.11%{?gver}%{?dist}
+Release: 0.12%{?gver}%{?dist}
URL: http://www.x.org
#Source0: http://xorg.freedesktop.org/releases/individual/driver/%{tarball}-%{version}.tar.bz2
Source0: %{tarball}-%{gitdate}.tar.bz2
Patch1: qxl-fix-32-bit.patch
# Support for old revision 1 qxl device (which won't go upstream)
-Patch2: 0002-Add-old-driver-in-as-a-compatibility-layer.patch
-Patch3: 0003-Link-in-the-compat-driver-various-renamings.patch
-Patch4: 0004-compat-bump-to-new-server-API-changes.patch
Patch5: qxl-kms-disable-composite.patch
Patch6: 0001-qxl-fix-issue-with-resizing-dev_image-improperly.patch
+Patch7: 0001-qxl-add-uevent-handler-support.patch
+Patch20: 0002-Add-old-driver-in-as-a-compatibility-layer.patch
+Patch21: 0003-Link-in-the-compat-driver-various-renamings.patch
+Patch22: 0004-compat-bump-to-new-server-API-changes.patch
License: MIT
Group: User Interface/X Hardware Support
@@ -50,6 +51,7 @@ BuildRequires: spice-server-devel >= 0.8.0
%endif
BuildRequires: glib2-devel
BuildRequires: libtool
+BuildRequires: libudev-devel
Requires: Xorg %(xserver-sdk-abi-requires ansic)
Requires: Xorg %(xserver-sdk-abi-requires videodrv)
@@ -73,16 +75,15 @@ XSpice is both an X and a Spice server.
%setup -q -n %{tarball}-%{?gitdate:%{gitdate}}%{!?gitdate:%{version}}
%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
%patch5 -p1
%patch6 -p1
-
-autoreconf -f -i
-
+%patch7 -p1
+%patch20 -p1
+%patch21 -p1
+%patch22 -p1
%build
+autoreconf -f -i
%if %{with_xspice}
%define enable_xspice --enable-xspice
%endif
@@ -127,6 +128,9 @@ rm -f $RPM_BUILD_ROOT%{_sysconfdir}/X11/spiceqxl.xorg.conf
%changelog
+* Wed Jul 03 2013 Dave Airlie <airlied at redhat.com> 0.1.1-0.12
+- add support for udev event catching - for dynamic resize from kernel
+
* Tue Jul 02 2013 Dave Airlie <airlied at redhat.com> 0.1.1-0.11
- helps if you apply the patch (#978612)
More information about the scm-commits
mailing list