spice-display.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (C) 2010 Red Hat, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 or
  7. * (at your option) version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <spice/ipc_ring.h>
  18. #include <spice/enums.h>
  19. #include <spice/qxl_dev.h>
  20. #include "qemu-thread.h"
  21. #include "console.h"
  22. #include "pflib.h"
  23. #include "sysemu.h"
  24. #define NUM_MEMSLOTS 8
  25. #define MEMSLOT_GENERATION_BITS 8
  26. #define MEMSLOT_SLOT_BITS 8
  27. #define MEMSLOT_GROUP_HOST 0
  28. #define MEMSLOT_GROUP_GUEST 1
  29. #define NUM_MEMSLOTS_GROUPS 2
  30. #define NUM_SURFACES 1024
  31. /*
  32. * Internal enum to differenciate between options for
  33. * io calls that have a sync (old) version and an _async (new)
  34. * version:
  35. * QXL_SYNC: use the old version
  36. * QXL_ASYNC: use the new version and make sure there are no two
  37. * happening at the same time. This is used for guest initiated
  38. * calls
  39. */
  40. typedef enum qxl_async_io {
  41. QXL_SYNC,
  42. QXL_ASYNC,
  43. } qxl_async_io;
  44. enum {
  45. QXL_COOKIE_TYPE_IO,
  46. QXL_COOKIE_TYPE_RENDER_UPDATE_AREA,
  47. QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG,
  48. };
  49. typedef struct QXLCookie {
  50. int type;
  51. uint64_t io;
  52. union {
  53. uint32_t surface_id;
  54. QXLRect area;
  55. struct {
  56. QXLRect area;
  57. int redraw;
  58. } render;
  59. } u;
  60. } QXLCookie;
  61. QXLCookie *qxl_cookie_new(int type, uint64_t io);
  62. typedef struct SimpleSpiceDisplay SimpleSpiceDisplay;
  63. typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
  64. struct SimpleSpiceDisplay {
  65. DisplayState *ds;
  66. void *buf;
  67. int bufsize;
  68. QXLWorker *worker;
  69. QXLInstance qxl;
  70. uint32_t unique;
  71. QemuPfConv *conv;
  72. QXLRect dirty;
  73. int notify;
  74. #if SPICE_SERVER_VERSION < 0x000b02 /* before 0.11.2 */
  75. int running;
  76. #endif
  77. /*
  78. * All struct members below this comment can be accessed from
  79. * both spice server and qemu (iothread) context and any access
  80. * to them must be protected by the lock.
  81. */
  82. QemuMutex lock;
  83. SimpleSpiceUpdate *update;
  84. QEMUCursor *cursor;
  85. int mouse_x, mouse_y;
  86. };
  87. struct SimpleSpiceUpdate {
  88. QXLDrawable drawable;
  89. QXLImage image;
  90. QXLCommandExt ext;
  91. uint8_t *bitmap;
  92. };
  93. int qemu_spice_rect_is_empty(const QXLRect* r);
  94. void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r);
  95. void qemu_spice_destroy_update(SimpleSpiceDisplay *sdpy, SimpleSpiceUpdate *update);
  96. void qemu_spice_create_host_memslot(SimpleSpiceDisplay *ssd);
  97. void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd);
  98. void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd);
  99. void qemu_spice_vm_change_state_handler(void *opaque, int running,
  100. RunState state);
  101. void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds);
  102. void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
  103. int x, int y, int w, int h);
  104. void qemu_spice_display_resize(SimpleSpiceDisplay *ssd);
  105. void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd);
  106. void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd);
  107. void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot,
  108. qxl_async_io async);
  109. void qemu_spice_del_memslot(SimpleSpiceDisplay *ssd, uint32_t gid,
  110. uint32_t sid);
  111. void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
  112. QXLDevSurfaceCreate *surface,
  113. qxl_async_io async);
  114. void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd,
  115. uint32_t id, qxl_async_io async);
  116. void qemu_spice_wakeup(SimpleSpiceDisplay *ssd);
  117. #if SPICE_SERVER_VERSION >= 0x000b02 /* before 0.11.2 */
  118. void qemu_spice_display_start(void);
  119. void qemu_spice_display_stop(void);
  120. #endif
  121. int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd);