1 /* SPDX-License-Identifier: MIT */
3 * fbif.h -- Xen virtual frame buffer device
5 * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
6 * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
9 #ifndef __XEN_PUBLIC_IO_FBIF_H__
10 #define __XEN_PUBLIC_IO_FBIF_H__
12 /* Out events (frontend -> backend) */
15 * Out events may be sent only when requested by backend, and receipt
16 * of an unknown out event is an error.
19 /* Event type 1 currently not used */
21 * Framebuffer update notification event
22 * Capable frontend sets feature-update in xenstore.
23 * Backend requests it by setting request-update in xenstore.
25 #define XENFB_TYPE_UPDATE 2
29 uint8_t type
; /* XENFB_TYPE_UPDATE */
30 int32_t x
; /* source x */
31 int32_t y
; /* source y */
32 int32_t width
; /* rect width */
33 int32_t height
; /* rect height */
37 * Framebuffer resize notification event
38 * Capable backend sets feature-resize in xenstore.
40 #define XENFB_TYPE_RESIZE 3
44 uint8_t type
; /* XENFB_TYPE_RESIZE */
45 int32_t width
; /* width in pixels */
46 int32_t height
; /* height in pixels */
47 int32_t stride
; /* stride in bytes */
48 int32_t depth
; /* depth in bits */
49 int32_t offset
; /* offset of the framebuffer in bytes */
52 #define XENFB_OUT_EVENT_SIZE 40
57 struct xenfb_update update
;
58 struct xenfb_resize resize
;
59 char pad
[XENFB_OUT_EVENT_SIZE
];
62 /* In events (backend -> frontend) */
65 * Frontends should ignore unknown in events.
69 * Framebuffer refresh period advice
70 * Backend sends it to advise the frontend their preferred period of
71 * refresh. Frontends that keep the framebuffer constantly up-to-date
72 * just ignore it. Frontends that use the advice should immediately
73 * refresh the framebuffer (and send an update notification event if
74 * those have been requested), then use the update frequency to guide
75 * their periodical refreshs.
77 #define XENFB_TYPE_REFRESH_PERIOD 1
78 #define XENFB_NO_REFRESH 0
80 struct xenfb_refresh_period
82 uint8_t type
; /* XENFB_TYPE_UPDATE_PERIOD */
83 uint32_t period
; /* period of refresh, in ms,
84 * XENFB_NO_REFRESH if no refresh is needed */
87 #define XENFB_IN_EVENT_SIZE 40
92 struct xenfb_refresh_period refresh_period
;
93 char pad
[XENFB_IN_EVENT_SIZE
];
98 #define XENFB_IN_RING_SIZE 1024
99 #define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
100 #define XENFB_IN_RING_OFFS 1024
101 #define XENFB_IN_RING(page) \
102 ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
103 #define XENFB_IN_RING_REF(page, idx) \
104 (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
106 #define XENFB_OUT_RING_SIZE 2048
107 #define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
108 #define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
109 #define XENFB_OUT_RING(page) \
110 ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
111 #define XENFB_OUT_RING_REF(page, idx) \
112 (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
116 uint32_t in_cons
, in_prod
;
117 uint32_t out_cons
, out_prod
;
119 int32_t width
; /* the width of the framebuffer (in pixels) */
120 int32_t height
; /* the height of the framebuffer (in pixels) */
121 uint32_t line_length
; /* the length of a row of pixels (in bytes) */
122 uint32_t mem_length
; /* the length of the framebuffer (in bytes) */
123 uint8_t depth
; /* the depth of a pixel (in bits) */
126 * Framebuffer page directory
128 * Each directory page holds PAGE_SIZE / sizeof(*pd)
129 * framebuffer pages, and can thus map up to PAGE_SIZE *
130 * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and
131 * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2 Megs
132 * 64 bit. 256 directories give enough room for a 512 Meg
133 * framebuffer with a max resolution of 12,800x10,240. Should
134 * be enough for a while with room leftover for expansion.
136 unsigned long pd
[256];
140 * Wart: xenkbd needs to know default resolution. Put it here until a
141 * better solution is found, but don't leak it to the backend.
144 #define XENFB_WIDTH 800
145 #define XENFB_HEIGHT 600
146 #define XENFB_DEPTH 32
154 * c-file-style: "BSD"
157 * indent-tabs-mode: nil