apple-gfx.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Data structures and functions shared between variants of the macOS
  3. * ParavirtualizedGraphics.framework based apple-gfx display adapter.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0-or-later
  6. */
  7. #ifndef QEMU_APPLE_GFX_H
  8. #define QEMU_APPLE_GFX_H
  9. #include "qemu/queue.h"
  10. #include "exec/memory.h"
  11. #include "hw/qdev-properties.h"
  12. #include "ui/surface.h"
  13. #define TYPE_APPLE_GFX_MMIO "apple-gfx-mmio"
  14. #define TYPE_APPLE_GFX_PCI "apple-gfx-pci"
  15. @class PGDeviceDescriptor;
  16. @protocol PGDevice;
  17. @protocol PGDisplay;
  18. @protocol MTLDevice;
  19. @protocol MTLTexture;
  20. @protocol MTLCommandQueue;
  21. typedef QTAILQ_HEAD(, PGTask_s) PGTaskList;
  22. typedef struct AppleGFXDisplayMode {
  23. uint16_t width_px;
  24. uint16_t height_px;
  25. uint16_t refresh_rate_hz;
  26. } AppleGFXDisplayMode;
  27. typedef struct AppleGFXState {
  28. /* Initialised on init/realize() */
  29. MemoryRegion iomem_gfx;
  30. id<PGDevice> pgdev;
  31. id<PGDisplay> pgdisp;
  32. QemuConsole *con;
  33. id<MTLDevice> mtl;
  34. id<MTLCommandQueue> mtl_queue;
  35. AppleGFXDisplayMode *display_modes;
  36. uint32_t num_display_modes;
  37. /* List `tasks` is protected by task_mutex */
  38. QemuMutex task_mutex;
  39. PGTaskList tasks;
  40. /* Mutable state (BQL protected) */
  41. QEMUCursor *cursor;
  42. DisplaySurface *surface;
  43. id<MTLTexture> texture;
  44. int8_t pending_frames; /* # guest frames in the rendering pipeline */
  45. bool gfx_update_requested; /* QEMU display system wants a new frame */
  46. bool new_frame_ready; /* Guest has rendered a frame, ready to be used */
  47. bool using_managed_texture_storage;
  48. uint32_t rendering_frame_width;
  49. uint32_t rendering_frame_height;
  50. /* Mutable state (atomic) */
  51. bool cursor_show;
  52. } AppleGFXState;
  53. void apple_gfx_common_init(Object *obj, AppleGFXState *s, const char* obj_name);
  54. bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev,
  55. PGDeviceDescriptor *desc, Error **errp);
  56. void *apple_gfx_host_ptr_for_gpa_range(uint64_t guest_physical,
  57. uint64_t length, bool read_only,
  58. MemoryRegion **mapping_in_region);
  59. extern const PropertyInfo qdev_prop_apple_gfx_display_mode;
  60. #endif