fbif.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * fbif.h -- Xen virtual frame buffer device
  4. *
  5. * Copyright (C) 2005 Anthony Liguori <[email protected]>
  6. * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <[email protected]>
  7. */
  8. #ifndef __XEN_PUBLIC_IO_FBIF_H__
  9. #define __XEN_PUBLIC_IO_FBIF_H__
  10. /* Out events (frontend -> backend) */
  11. /*
  12. * Out events may be sent only when requested by backend, and receipt
  13. * of an unknown out event is an error.
  14. */
  15. /* Event type 1 currently not used */
  16. /*
  17. * Framebuffer update notification event
  18. * Capable frontend sets feature-update in xenstore.
  19. * Backend requests it by setting request-update in xenstore.
  20. */
  21. #define XENFB_TYPE_UPDATE 2
  22. struct xenfb_update {
  23. uint8_t type; /* XENFB_TYPE_UPDATE */
  24. int32_t x; /* source x */
  25. int32_t y; /* source y */
  26. int32_t width; /* rect width */
  27. int32_t height; /* rect height */
  28. };
  29. /*
  30. * Framebuffer resize notification event
  31. * Capable backend sets feature-resize in xenstore.
  32. */
  33. #define XENFB_TYPE_RESIZE 3
  34. struct xenfb_resize {
  35. uint8_t type; /* XENFB_TYPE_RESIZE */
  36. int32_t width; /* width in pixels */
  37. int32_t height; /* height in pixels */
  38. int32_t stride; /* stride in bytes */
  39. int32_t depth; /* depth in bits */
  40. int32_t offset; /* start offset within framebuffer */
  41. };
  42. #define XENFB_OUT_EVENT_SIZE 40
  43. union xenfb_out_event {
  44. uint8_t type;
  45. struct xenfb_update update;
  46. struct xenfb_resize resize;
  47. char pad[XENFB_OUT_EVENT_SIZE];
  48. };
  49. /* In events (backend -> frontend) */
  50. /*
  51. * Frontends should ignore unknown in events.
  52. * No in events currently defined.
  53. */
  54. #define XENFB_IN_EVENT_SIZE 40
  55. union xenfb_in_event {
  56. uint8_t type;
  57. char pad[XENFB_IN_EVENT_SIZE];
  58. };
  59. /* shared page */
  60. #define XENFB_IN_RING_SIZE 1024
  61. #define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
  62. #define XENFB_IN_RING_OFFS 1024
  63. #define XENFB_IN_RING(page) \
  64. ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
  65. #define XENFB_IN_RING_REF(page, idx) \
  66. (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
  67. #define XENFB_OUT_RING_SIZE 2048
  68. #define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
  69. #define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
  70. #define XENFB_OUT_RING(page) \
  71. ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
  72. #define XENFB_OUT_RING_REF(page, idx) \
  73. (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
  74. struct xenfb_page {
  75. uint32_t in_cons, in_prod;
  76. uint32_t out_cons, out_prod;
  77. int32_t width; /* width of the framebuffer (in pixels) */
  78. int32_t height; /* height of the framebuffer (in pixels) */
  79. uint32_t line_length; /* length of a row of pixels (in bytes) */
  80. uint32_t mem_length; /* length of the framebuffer (in bytes) */
  81. uint8_t depth; /* depth of a pixel (in bits) */
  82. /*
  83. * Framebuffer page directory
  84. *
  85. * Each directory page holds PAGE_SIZE / sizeof(*pd)
  86. * framebuffer pages, and can thus map up to PAGE_SIZE *
  87. * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and
  88. * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2
  89. * Megs 64 bit. 256 directories give enough room for a 512
  90. * Meg framebuffer with a max resolution of 12,800x10,240.
  91. * Should be enough for a while with room leftover for
  92. * expansion.
  93. */
  94. unsigned long pd[256];
  95. };
  96. /*
  97. * Wart: xenkbd needs to know default resolution. Put it here until a
  98. * better solution is found, but don't leak it to the backend.
  99. */
  100. #ifdef __KERNEL__
  101. #define XENFB_WIDTH 800
  102. #define XENFB_HEIGHT 600
  103. #define XENFB_DEPTH 32
  104. #endif
  105. #endif