2010-08-25 15:32:06 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 or
|
|
|
|
* (at your option) version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-04 20:16:18 +02:00
|
|
|
#ifndef UI_SPICE_DISPLAY_H
|
|
|
|
#define UI_SPICE_DISPLAY_H
|
|
|
|
|
2019-08-12 07:23:31 +02:00
|
|
|
#include <spice.h>
|
2010-08-25 15:32:06 +02:00
|
|
|
#include <spice/ipc_ring.h>
|
|
|
|
#include <spice/enums.h>
|
|
|
|
#include <spice/qxl_dev.h>
|
|
|
|
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/thread.h"
|
2012-11-28 12:06:30 +01:00
|
|
|
#include "ui/qemu-pixman.h"
|
2013-01-21 13:03:47 +01:00
|
|
|
#include "ui/console.h"
|
2010-08-25 15:32:06 +02:00
|
|
|
|
2021-02-23 07:03:07 +01:00
|
|
|
#if defined(CONFIG_OPENGL) && defined(CONFIG_GBM)
|
2015-10-13 15:39:34 +02:00
|
|
|
# define HAVE_SPICE_GL 1
|
|
|
|
# include "ui/egl-helpers.h"
|
|
|
|
# include "ui/egl-context.h"
|
|
|
|
#endif
|
|
|
|
|
2010-08-25 15:32:06 +02:00
|
|
|
#define NUM_MEMSLOTS 8
|
|
|
|
#define MEMSLOT_GENERATION_BITS 8
|
|
|
|
#define MEMSLOT_SLOT_BITS 8
|
|
|
|
|
|
|
|
#define MEMSLOT_GROUP_HOST 0
|
|
|
|
#define MEMSLOT_GROUP_GUEST 1
|
|
|
|
#define NUM_MEMSLOTS_GROUPS 2
|
|
|
|
|
2011-07-20 11:20:58 +02:00
|
|
|
/*
|
|
|
|
* Internal enum to differenciate between options for
|
|
|
|
* io calls that have a sync (old) version and an _async (new)
|
|
|
|
* version:
|
|
|
|
* QXL_SYNC: use the old version
|
|
|
|
* QXL_ASYNC: use the new version and make sure there are no two
|
|
|
|
* happening at the same time. This is used for guest initiated
|
|
|
|
* calls
|
|
|
|
*/
|
|
|
|
typedef enum qxl_async_io {
|
|
|
|
QXL_SYNC,
|
|
|
|
QXL_ASYNC,
|
|
|
|
} qxl_async_io;
|
|
|
|
|
2012-02-24 22:19:30 +01:00
|
|
|
enum {
|
|
|
|
QXL_COOKIE_TYPE_IO,
|
2012-02-24 22:19:31 +01:00
|
|
|
QXL_COOKIE_TYPE_RENDER_UPDATE_AREA,
|
2012-08-22 10:16:25 +02:00
|
|
|
QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG,
|
2015-10-13 15:39:34 +02:00
|
|
|
QXL_COOKIE_TYPE_GL_DRAW_DONE,
|
2012-02-24 22:19:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct QXLCookie {
|
|
|
|
int type;
|
|
|
|
uint64_t io;
|
|
|
|
union {
|
|
|
|
uint32_t surface_id;
|
2012-02-24 22:19:31 +01:00
|
|
|
QXLRect area;
|
|
|
|
struct {
|
|
|
|
QXLRect area;
|
|
|
|
int redraw;
|
|
|
|
} render;
|
2016-02-03 13:55:00 +01:00
|
|
|
void *data;
|
2012-02-24 22:19:30 +01:00
|
|
|
} u;
|
|
|
|
} QXLCookie;
|
|
|
|
|
|
|
|
QXLCookie *qxl_cookie_new(int type, uint64_t io);
|
|
|
|
|
2011-04-27 15:21:51 +02:00
|
|
|
typedef struct SimpleSpiceDisplay SimpleSpiceDisplay;
|
|
|
|
typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
|
2014-06-07 13:03:10 +02:00
|
|
|
typedef struct SimpleSpiceCursor SimpleSpiceCursor;
|
2011-04-27 15:21:51 +02:00
|
|
|
|
|
|
|
struct SimpleSpiceDisplay {
|
2013-02-28 16:42:28 +01:00
|
|
|
DisplaySurface *ds;
|
2021-10-09 21:48:46 +02:00
|
|
|
DisplayGLCtx dgc;
|
2012-11-13 14:51:41 +01:00
|
|
|
DisplayChangeListener dcl;
|
2010-08-25 15:32:06 +02:00
|
|
|
void *buf;
|
|
|
|
int bufsize;
|
|
|
|
QXLInstance qxl;
|
|
|
|
uint32_t unique;
|
2012-11-02 09:12:49 +01:00
|
|
|
pixman_image_t *surface;
|
|
|
|
pixman_image_t *mirror;
|
2012-09-04 11:39:41 +02:00
|
|
|
int32_t num_surfaces;
|
2010-08-25 15:32:06 +02:00
|
|
|
|
|
|
|
QXLRect dirty;
|
|
|
|
int notify;
|
|
|
|
|
2011-04-27 15:21:51 +02:00
|
|
|
/*
|
|
|
|
* All struct members below this comment can be accessed from
|
|
|
|
* both spice server and qemu (iothread) context and any access
|
|
|
|
* to them must be protected by the lock.
|
|
|
|
*/
|
|
|
|
QemuMutex lock;
|
2012-09-05 08:25:08 +02:00
|
|
|
QTAILQ_HEAD(, SimpleSpiceUpdate) updates;
|
2014-06-07 13:03:10 +02:00
|
|
|
|
|
|
|
/* cursor (without qxl): displaychangelistener -> spice server */
|
|
|
|
SimpleSpiceCursor *ptr_define;
|
|
|
|
SimpleSpiceCursor *ptr_move;
|
2015-03-24 17:50:12 +01:00
|
|
|
int16_t ptr_x, ptr_y;
|
|
|
|
int16_t hot_x, hot_y;
|
2014-06-07 13:03:10 +02:00
|
|
|
|
|
|
|
/* cursor (with qxl): qxl local renderer -> displaychangelistener */
|
2011-04-27 15:50:32 +02:00
|
|
|
QEMUCursor *cursor;
|
|
|
|
int mouse_x, mouse_y;
|
2014-11-04 13:59:59 +01:00
|
|
|
QEMUBH *cursor_bh;
|
2015-10-13 15:39:34 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_SPICE_GL
|
|
|
|
/* opengl rendering */
|
|
|
|
QEMUBH *gl_unblock_bh;
|
2016-02-19 07:46:47 +01:00
|
|
|
QEMUTimer *gl_unblock_timer;
|
2017-10-10 15:54:49 +02:00
|
|
|
QemuGLShader *gls;
|
2016-09-23 09:50:28 +02:00
|
|
|
int gl_updates;
|
|
|
|
bool have_scanout;
|
|
|
|
bool have_surface;
|
2018-03-08 10:06:17 +01:00
|
|
|
|
|
|
|
QemuDmaBuf *guest_dmabuf;
|
|
|
|
bool guest_dmabuf_refresh;
|
|
|
|
bool render_cursor;
|
|
|
|
|
|
|
|
egl_fb guest_fb;
|
|
|
|
egl_fb blit_fb;
|
|
|
|
egl_fb cursor_fb;
|
|
|
|
bool have_hot;
|
2015-10-13 15:39:34 +02:00
|
|
|
#endif
|
2011-04-27 15:21:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SimpleSpiceUpdate {
|
2010-08-25 15:32:06 +02:00
|
|
|
QXLDrawable drawable;
|
|
|
|
QXLImage image;
|
|
|
|
QXLCommandExt ext;
|
|
|
|
uint8_t *bitmap;
|
2012-09-05 08:25:08 +02:00
|
|
|
QTAILQ_ENTRY(SimpleSpiceUpdate) next;
|
2011-04-27 15:21:51 +02:00
|
|
|
};
|
2010-08-25 15:32:06 +02:00
|
|
|
|
2014-06-07 13:03:10 +02:00
|
|
|
struct SimpleSpiceCursor {
|
|
|
|
QXLCursorCmd cmd;
|
|
|
|
QXLCommandExt ext;
|
|
|
|
QXLCursor cursor;
|
|
|
|
};
|
|
|
|
|
2017-06-06 13:06:18 +02:00
|
|
|
extern bool spice_opengl;
|
|
|
|
|
2010-08-25 15:32:06 +02:00
|
|
|
int qemu_spice_rect_is_empty(const QXLRect* r);
|
|
|
|
void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r);
|
|
|
|
|
|
|
|
void qemu_spice_destroy_update(SimpleSpiceDisplay *sdpy, SimpleSpiceUpdate *update);
|
|
|
|
void qemu_spice_create_host_memslot(SimpleSpiceDisplay *ssd);
|
|
|
|
void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd);
|
|
|
|
void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd);
|
2013-03-05 15:24:14 +01:00
|
|
|
void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd);
|
2010-08-25 15:32:06 +02:00
|
|
|
|
|
|
|
void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
|
|
|
|
int x, int y, int w, int h);
|
2013-02-28 15:03:04 +01:00
|
|
|
void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
|
|
|
|
DisplaySurface *surface);
|
2010-08-25 15:32:06 +02:00
|
|
|
void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd);
|
2014-11-04 13:59:59 +01:00
|
|
|
void qemu_spice_cursor_refresh_bh(void *opaque);
|
2011-07-20 11:20:50 +02:00
|
|
|
|
2011-07-20 11:20:58 +02:00
|
|
|
void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot,
|
|
|
|
qxl_async_io async);
|
2011-07-20 11:20:50 +02:00
|
|
|
void qemu_spice_del_memslot(SimpleSpiceDisplay *ssd, uint32_t gid,
|
|
|
|
uint32_t sid);
|
|
|
|
void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
|
2011-07-20 11:20:58 +02:00
|
|
|
QXLDevSurfaceCreate *surface,
|
|
|
|
qxl_async_io async);
|
|
|
|
void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd,
|
|
|
|
uint32_t id, qxl_async_io async);
|
2011-07-20 11:20:50 +02:00
|
|
|
void qemu_spice_wakeup(SimpleSpiceDisplay *ssd);
|
2012-08-21 10:51:56 +02:00
|
|
|
void qemu_spice_display_start(void);
|
|
|
|
void qemu_spice_display_stop(void);
|
|
|
|
int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd);
|
2019-02-15 16:09:19 +01:00
|
|
|
|
2019-06-04 20:16:18 +02:00
|
|
|
#endif
|