spice-display.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. typedef struct SimpleSpiceDisplay SimpleSpiceDisplay;
  45. typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
  46. struct SimpleSpiceDisplay {
  47. DisplayState *ds;
  48. void *buf;
  49. int bufsize;
  50. QXLWorker *worker;
  51. QXLInstance qxl;
  52. uint32_t unique;
  53. QemuPfConv *conv;
  54. QXLRect dirty;
  55. int notify;
  56. int running;
  57. /*
  58. * All struct members below this comment can be accessed from
  59. * both spice server and qemu (iothread) context and any access
  60. * to them must be protected by the lock.
  61. */
  62. QemuMutex lock;
  63. SimpleSpiceUpdate *update;
  64. QEMUCursor *cursor;
  65. int mouse_x, mouse_y;
  66. };
  67. struct SimpleSpiceUpdate {
  68. QXLDrawable drawable;
  69. QXLImage image;
  70. QXLCommandExt ext;
  71. uint8_t *bitmap;
  72. };
  73. int qemu_spice_rect_is_empty(const QXLRect* r);
  74. void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r);
  75. void qemu_spice_destroy_update(SimpleSpiceDisplay *sdpy, SimpleSpiceUpdate *update);
  76. void qemu_spice_create_host_memslot(SimpleSpiceDisplay *ssd);
  77. void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd);
  78. void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd);
  79. void qemu_spice_vm_change_state_handler(void *opaque, int running,
  80. RunState state);
  81. void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds);
  82. void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
  83. int x, int y, int w, int h);
  84. void qemu_spice_display_resize(SimpleSpiceDisplay *ssd);
  85. void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd);
  86. void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot,
  87. qxl_async_io async);
  88. void qemu_spice_del_memslot(SimpleSpiceDisplay *ssd, uint32_t gid,
  89. uint32_t sid);
  90. void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
  91. QXLDevSurfaceCreate *surface,
  92. qxl_async_io async);
  93. void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd,
  94. uint32_t id, qxl_async_io async);
  95. void qemu_spice_wakeup(SimpleSpiceDisplay *ssd);
  96. void qemu_spice_start(SimpleSpiceDisplay *ssd);
  97. void qemu_spice_stop(SimpleSpiceDisplay *ssd);