summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@gmail.com>2012-11-13 14:33:39 +1000
committerDave Airlie <airlied@gmail.com>2012-11-13 14:33:39 +1000
commit5ac1d837e8e08889dd2d552430f846c603f7c66d (patch)
treefd02255edc8ac6f3dce6528c6705e6878fa71c11
parent238d2579f7196a227e9e51be09e6071b6b380e44 (diff)
qxl: move io functions to a separate file
this moves all the lowlevel ioport interaction code to a separate file. Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--src/Makefile.am4
-rw-r--r--src/qxl.h4
-rw-r--r--src/qxl_driver.c199
-rw-r--r--src/qxl_io.c205
4 files changed, 225 insertions, 187 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index e31b33e..934cb1a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -52,7 +52,8 @@ qxl_drv_la_SOURCES = \
qxl_option_helpers.h \
qxl_edid.c \
qxl_uxa.c \
- qxl_ums_mode.c \
+ qxl_ums_mode.c \
+ qxl_io.c \
compat-api.h
endif
@@ -94,5 +95,6 @@ spiceqxl_drv_la_SOURCES = \
qxl_edid.c \
qxl_uxa.c \
qxl_ums_mode.c \
+ qxl_io.c \
compat-api.h
endif
diff --git a/src/qxl.h b/src/qxl.h
index 271e912..954076a 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -502,6 +502,10 @@ void qxl_io_notify_oom(qxl_screen_t *qxl);
void qxl_io_flush_surfaces(qxl_screen_t *qxl);
void qxl_io_destroy_all_surfaces (qxl_screen_t *qxl);
+#ifdef QXLDRV_RESIZABLE_SURFACE0
+void qxl_io_flush_release (qxl_screen_t *qxl);
+#endif
+
/*
* qxl_edid.c
*/
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 6d57f69..29740fa 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -129,173 +129,6 @@ qxl_available_options (int chipid, int busid)
return DefaultOptions;
}
-#ifndef XSPICE
-static void
-qxl_wait_for_io_command (qxl_screen_t *qxl)
-{
- struct QXLRam *ram_header;
-
- ram_header = (void *)((unsigned long)qxl->ram + qxl->rom->ram_header_offset);
-
- while (!(ram_header->int_pending & QXL_INTERRUPT_IO_CMD))
- usleep (1);
-
- ram_header->int_pending &= ~QXL_INTERRUPT_IO_CMD;
-}
-
-#if 0
-static void
-qxl_wait_for_display_interrupt (qxl_screen_t *qxl)
-{
- struct QXLRam *ram_header;
-
- ram_header = (void *)((unsigned long)qxl->ram + qxl->rom->ram_header_offset);
-
- while (!(ram_header->int_pending & QXL_INTERRUPT_DISPLAY))
- usleep (1);
-
- ram_header->int_pending &= ~QXL_INTERRUPT_DISPLAY;
-}
-
-#endif
-#endif
-
-void
-qxl_update_area (qxl_screen_t *qxl)
-{
-#ifndef XSPICE
- if (qxl->pci->revision >= 3)
- {
- ioport_write (qxl, QXL_IO_UPDATE_AREA_ASYNC, 0);
- qxl_wait_for_io_command (qxl);
- }
- else
- {
- ioport_write (qxl, QXL_IO_UPDATE_AREA, 0);
- }
-#else
- ioport_write (qxl, QXL_IO_UPDATE_AREA, 0);
-#endif
-}
-
-void
-qxl_io_memslot_add (qxl_screen_t *qxl, uint8_t id)
-{
-#ifndef XSPICE
- if (qxl->pci->revision >= 3)
- {
- ioport_write (qxl, QXL_IO_MEMSLOT_ADD_ASYNC, id);
- qxl_wait_for_io_command (qxl);
- }
- else
- {
- ioport_write (qxl, QXL_IO_MEMSLOT_ADD, id);
- }
-#else
- ioport_write (qxl, QXL_IO_MEMSLOT_ADD, id);
-#endif
-}
-
-void
-qxl_io_create_primary (qxl_screen_t *qxl)
-{
-#ifndef XSPICE
- if (qxl->pci->revision >= 3)
- {
- ioport_write (qxl, QXL_IO_CREATE_PRIMARY_ASYNC, 0);
- qxl_wait_for_io_command (qxl);
- }
- else
- {
- ioport_write (qxl, QXL_IO_CREATE_PRIMARY, 0);
- }
-#else
- ioport_write (qxl, QXL_IO_CREATE_PRIMARY, 0);
-#endif
- qxl->device_primary = QXL_DEVICE_PRIMARY_CREATED;
-}
-
-void
-qxl_io_destroy_primary (qxl_screen_t *qxl)
-{
-#ifndef XSPICE
- if (qxl->pci->revision >= 3)
- {
- ioport_write (qxl, QXL_IO_DESTROY_PRIMARY_ASYNC, 0);
- qxl_wait_for_io_command (qxl);
- }
- else
- {
- ioport_write (qxl, QXL_IO_DESTROY_PRIMARY, 0);
- }
-#else
- ioport_write (qxl, QXL_IO_DESTROY_PRIMARY, 0);
-#endif
- qxl->device_primary = QXL_DEVICE_PRIMARY_NONE;
-}
-
-void
-qxl_io_notify_oom (qxl_screen_t *qxl)
-{
- ioport_write (qxl, QXL_IO_NOTIFY_OOM, 0);
-}
-
-void
-qxl_io_flush_surfaces (qxl_screen_t *qxl)
-{
- // FIXME: write individual update_area for revision < V10
-#ifndef XSPICE
- ioport_write (qxl, QXL_IO_FLUSH_SURFACES_ASYNC, 0);
- qxl_wait_for_io_command (qxl);
-#else
- ioport_write (qxl, QXL_IO_FLUSH_SURFACES_ASYNC, 0);
-#endif
-}
-
-static void
-qxl_usleep (int useconds)
-{
- struct timespec t;
-
- t.tv_sec = useconds / 1000000;
- t.tv_nsec = (useconds - (t.tv_sec * 1000000)) * 1000;
-
- errno = 0;
- while (nanosleep (&t, &t) == -1 && errno == EINTR)
- ;
-}
-
-#ifdef QXLDRV_RESIZABLE_SURFACE0
-static void
-qxl_io_flush_release (qxl_screen_t *qxl)
-{
-#ifndef XSPICE
- int sum = 0;
-
- sum += qxl_garbage_collect (qxl);
- ioport_write (qxl, QXL_IO_FLUSH_RELEASE, 0);
- sum += qxl_garbage_collect (qxl);
- ErrorF ("%s: collected %d\n", __func__, sum);
-#else
-#endif
-}
-
-#endif
-
-void
-qxl_io_monitors_config_async (qxl_screen_t *qxl)
-{
-#ifndef XSPICE
- if (qxl->pci->revision < 4)
- return;
-
- ioport_write (qxl, QXL_IO_MONITORS_CONFIG_ASYNC, 0);
- qxl_wait_for_io_command (qxl);
-#else
- fprintf (stderr, "UNIMPLEMENTED!\n");
-#endif
-}
-
/* Having a single monitors config struct allocated on the device avoids any
*
* possible fragmentation. Since X is single threaded there is no danger
@@ -431,6 +264,19 @@ qxl_garbage_collect (qxl_screen_t *qxl)
return i;
}
+static void
+qxl_usleep (int useconds)
+{
+ struct timespec t;
+
+ t.tv_sec = useconds / 1000000;
+ t.tv_nsec = (useconds - (t.tv_sec * 1000000)) * 1000;
+
+ errno = 0;
+ while (nanosleep (&t, &t) == -1 && errno == EINTR)
+ ;
+}
+
int
qxl_handle_oom (qxl_screen_t *qxl)
{
@@ -843,25 +689,6 @@ qxl_mark_mem_unverifiable (qxl_screen_t *qxl)
qxl_mem_unverifiable (qxl->surf_mem);
}
-void
-qxl_io_destroy_all_surfaces (qxl_screen_t *qxl)
-{
-#ifndef XSPICE
- if (qxl->pci->revision >= 3)
- {
- ioport_write (qxl, QXL_IO_DESTROY_ALL_SURFACES_ASYNC, 0);
- qxl_wait_for_io_command (qxl);
- }
- else
- {
- ioport_write (qxl, QXL_IO_DESTROY_ALL_SURFACES, 0);
- }
-#else
- ErrorF ("Xspice: error: UNIMPLEMENTED qxl_io_destroy_all_surfaces\n");
-#endif
- qxl->device_primary = QXL_DEVICE_PRIMARY_NONE;
-}
-
static Bool
qxl_close_screen (CLOSE_SCREEN_ARGS_DECL)
{
diff --git a/src/qxl_io.c b/src/qxl_io.c
new file mode 100644
index 0000000..c592631
--- /dev/null
+++ b/src/qxl_io.c
@@ -0,0 +1,205 @@
+/*
+ * 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.
+ */
+
+/* all the IO routines for QXL userspace code */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <unistd.h>
+#include <errno.h>
+#include <time.h>
+#include "qxl.h"
+#ifndef XSPICE
+static void
+qxl_wait_for_io_command (qxl_screen_t *qxl)
+{
+ struct QXLRam *ram_header;
+
+ ram_header = (void *)((unsigned long)qxl->ram + qxl->rom->ram_header_offset);
+
+ while (!(ram_header->int_pending & QXL_INTERRUPT_IO_CMD))
+ usleep (1);
+
+ ram_header->int_pending &= ~QXL_INTERRUPT_IO_CMD;
+}
+
+#if 0
+static void
+qxl_wait_for_display_interrupt (qxl_screen_t *qxl)
+{
+ struct QXLRam *ram_header;
+
+ ram_header = (void *)((unsigned long)qxl->ram + qxl->rom->ram_header_offset);
+
+ while (!(ram_header->int_pending & QXL_INTERRUPT_DISPLAY))
+ usleep (1);
+
+ ram_header->int_pending &= ~QXL_INTERRUPT_DISPLAY;
+}
+
+#endif
+#endif
+
+void
+qxl_update_area (qxl_screen_t *qxl)
+{
+#ifndef XSPICE
+ if (qxl->pci->revision >= 3)
+ {
+ ioport_write (qxl, QXL_IO_UPDATE_AREA_ASYNC, 0);
+ qxl_wait_for_io_command (qxl);
+ }
+ else
+ {
+ ioport_write (qxl, QXL_IO_UPDATE_AREA, 0);
+ }
+#else
+ ioport_write (qxl, QXL_IO_UPDATE_AREA, 0);
+#endif
+}
+
+void
+qxl_io_memslot_add (qxl_screen_t *qxl, uint8_t id)
+{
+#ifndef XSPICE
+ if (qxl->pci->revision >= 3)
+ {
+ ioport_write (qxl, QXL_IO_MEMSLOT_ADD_ASYNC, id);
+ qxl_wait_for_io_command (qxl);
+ }
+ else
+ {
+ ioport_write (qxl, QXL_IO_MEMSLOT_ADD, id);
+ }
+#else
+ ioport_write (qxl, QXL_IO_MEMSLOT_ADD, id);
+#endif
+}
+
+void
+qxl_io_create_primary (qxl_screen_t *qxl)
+{
+#ifndef XSPICE
+ if (qxl->pci->revision >= 3)
+ {
+ ioport_write (qxl, QXL_IO_CREATE_PRIMARY_ASYNC, 0);
+ qxl_wait_for_io_command (qxl);
+ }
+ else
+ {
+ ioport_write (qxl, QXL_IO_CREATE_PRIMARY, 0);
+ }
+#else
+ ioport_write (qxl, QXL_IO_CREATE_PRIMARY, 0);
+#endif
+ qxl->device_primary = QXL_DEVICE_PRIMARY_CREATED;
+}
+
+void
+qxl_io_destroy_primary (qxl_screen_t *qxl)
+{
+#ifndef XSPICE
+ if (qxl->pci->revision >= 3)
+ {
+ ioport_write (qxl, QXL_IO_DESTROY_PRIMARY_ASYNC, 0);
+ qxl_wait_for_io_command (qxl);
+ }
+ else
+ {
+ ioport_write (qxl, QXL_IO_DESTROY_PRIMARY, 0);
+ }
+#else
+ ioport_write (qxl, QXL_IO_DESTROY_PRIMARY, 0);
+#endif
+ qxl->device_primary = QXL_DEVICE_PRIMARY_NONE;
+}
+
+void
+qxl_io_notify_oom (qxl_screen_t *qxl)
+{
+ ioport_write (qxl, QXL_IO_NOTIFY_OOM, 0);
+}
+
+void
+qxl_io_flush_surfaces (qxl_screen_t *qxl)
+{
+ // FIXME: write individual update_area for revision < V10
+#ifndef XSPICE
+ ioport_write (qxl, QXL_IO_FLUSH_SURFACES_ASYNC, 0);
+ qxl_wait_for_io_command (qxl);
+#else
+ ioport_write (qxl, QXL_IO_FLUSH_SURFACES_ASYNC, 0);
+#endif
+}
+
+#ifdef QXLDRV_RESIZABLE_SURFACE0
+void
+qxl_io_flush_release (qxl_screen_t *qxl)
+{
+#ifndef XSPICE
+ int sum = 0;
+
+ sum += qxl_garbage_collect (qxl);
+ ioport_write (qxl, QXL_IO_FLUSH_RELEASE, 0);
+ sum += qxl_garbage_collect (qxl);
+ ErrorF ("%s: collected %d\n", __func__, sum);
+#else
+#endif
+}
+
+#endif
+
+void
+qxl_io_monitors_config_async (qxl_screen_t *qxl)
+{
+#ifndef XSPICE
+ if (qxl->pci->revision < 4)
+ return;
+
+ ioport_write (qxl, QXL_IO_MONITORS_CONFIG_ASYNC, 0);
+ qxl_wait_for_io_command (qxl);
+#else
+ fprintf (stderr, "UNIMPLEMENTED!\n");
+#endif
+}
+
+
+void
+qxl_io_destroy_all_surfaces (qxl_screen_t *qxl)
+{
+#ifndef XSPICE
+ if (qxl->pci->revision >= 3)
+ {
+ ioport_write (qxl, QXL_IO_DESTROY_ALL_SURFACES_ASYNC, 0);
+ qxl_wait_for_io_command (qxl);
+ }
+ else
+ {
+ ioport_write (qxl, QXL_IO_DESTROY_ALL_SURFACES, 0);
+ }
+#else
+ ErrorF ("Xspice: error: UNIMPLEMENTED qxl_io_destroy_all_surfaces\n");
+#endif
+ qxl->device_primary = QXL_DEVICE_PRIMARY_NONE;
+}
+