fbif.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * fbif.h -- Xen virtual frame buffer device
  4. *
  5. * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
  6. * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
  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. {
  24. uint8_t type; /* XENFB_TYPE_UPDATE */
  25. int32_t x; /* source x */
  26. int32_t y; /* source y */
  27. int32_t width; /* rect width */
  28. int32_t height; /* rect height */
  29. };
  30. /*
  31. * Framebuffer resize notification event
  32. * Capable backend sets feature-resize in xenstore.
  33. */
  34. #define XENFB_TYPE_RESIZE 3
  35. struct xenfb_resize
  36. {
  37. uint8_t type; /* XENFB_TYPE_RESIZE */
  38. int32_t width; /* width in pixels */
  39. int32_t height; /* height in pixels */
  40. int32_t stride; /* stride in bytes */
  41. int32_t depth; /* depth in bits */
  42. int32_t offset; /* offset of the framebuffer in bytes */
  43. };
  44. #define XENFB_OUT_EVENT_SIZE 40
  45. union xenfb_out_event
  46. {
  47. uint8_t type;
  48. struct xenfb_update update;
  49. struct xenfb_resize resize;
  50. char pad[XENFB_OUT_EVENT_SIZE];
  51. };
  52. /* In events (backend -> frontend) */
  53. /*
  54. * Frontends should ignore unknown in events.
  55. */
  56. /*
  57. * Framebuffer refresh period advice
  58. * Backend sends it to advise the frontend their preferred period of
  59. * refresh. Frontends that keep the framebuffer constantly up-to-date
  60. * just ignore it. Frontends that use the advice should immediately
  61. * refresh the framebuffer (and send an update notification event if
  62. * those have been requested), then use the update frequency to guide
  63. * their periodical refreshs.
  64. */
  65. #define XENFB_TYPE_REFRESH_PERIOD 1
  66. #define XENFB_NO_REFRESH 0
  67. struct xenfb_refresh_period
  68. {
  69. uint8_t type; /* XENFB_TYPE_UPDATE_PERIOD */
  70. uint32_t period; /* period of refresh, in ms,
  71. * XENFB_NO_REFRESH if no refresh is needed */
  72. };
  73. #define XENFB_IN_EVENT_SIZE 40
  74. union xenfb_in_event
  75. {
  76. uint8_t type;
  77. struct xenfb_refresh_period refresh_period;
  78. char pad[XENFB_IN_EVENT_SIZE];
  79. };
  80. /* shared page */
  81. #define XENFB_IN_RING_SIZE 1024
  82. #define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
  83. #define XENFB_IN_RING_OFFS 1024
  84. #define XENFB_IN_RING(page) \
  85. ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
  86. #define XENFB_IN_RING_REF(page, idx) \
  87. (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
  88. #define XENFB_OUT_RING_SIZE 2048
  89. #define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
  90. #define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
  91. #define XENFB_OUT_RING(page) \
  92. ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
  93. #define XENFB_OUT_RING_REF(page, idx) \
  94. (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
  95. struct xenfb_page
  96. {
  97. uint32_t in_cons, in_prod;
  98. uint32_t out_cons, out_prod;
  99. int32_t width; /* the width of the framebuffer (in pixels) */
  100. int32_t height; /* the height of the framebuffer (in pixels) */
  101. uint32_t line_length; /* the length of a row of pixels (in bytes) */
  102. uint32_t mem_length; /* the length of the framebuffer (in bytes) */
  103. uint8_t depth; /* the depth of a pixel (in bits) */
  104. /*
  105. * Framebuffer page directory
  106. *
  107. * Each directory page holds PAGE_SIZE / sizeof(*pd)
  108. * framebuffer pages, and can thus map up to PAGE_SIZE *
  109. * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and
  110. * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2 Megs
  111. * 64 bit. 256 directories give enough room for a 512 Meg
  112. * framebuffer with a max resolution of 12,800x10,240. Should
  113. * be enough for a while with room leftover for expansion.
  114. */
  115. unsigned long pd[256];
  116. };
  117. /*
  118. * Wart: xenkbd needs to know default resolution. Put it here until a
  119. * better solution is found, but don't leak it to the backend.
  120. */
  121. #ifdef __KERNEL__
  122. #define XENFB_WIDTH 800
  123. #define XENFB_HEIGHT 600
  124. #define XENFB_DEPTH 32
  125. #endif
  126. #endif
  127. /*
  128. * Local variables:
  129. * mode: C
  130. * c-file-style: "BSD"
  131. * c-basic-offset: 4
  132. * tab-width: 4
  133. * indent-tabs-mode: nil
  134. * End:
  135. */