From: Dave Airlie <airlied@xxxxxxxxx> this moves all the lowlevel ioport interaction code to a separate file. Signed-off-by: Dave Airlie <airlied@xxxxxxxxxx> --- src/Makefile.am | 4 +- src/qxl.h | 4 ++ src/qxl_driver.c | 199 ++++------------------------------------------------- src/qxl_io.c | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 225 insertions(+), 187 deletions(-) create mode 100644 src/qxl_io.c diff --git a/src/Makefile.am b/src/Makefile.am index c383514..b8d0d3e 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 @@ -95,5 +96,6 @@ spiceqxl_drv_la_SOURCES = \ dfps.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 09e9486..fb3a473 100644 --- a/src/qxl.h +++ b/src/qxl.h @@ -511,6 +511,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 fdfee89..212de60 100644 --- a/src/qxl_driver.c +++ b/src/qxl_driver.c @@ -134,173 +134,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 @@ -429,6 +262,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; +} + -- 1.8.1.2 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel