1 1.1 cherry /* 2 1.1 cherry * fbif.h -- Xen virtual frame buffer device 3 1.1 cherry * 4 1.1 cherry * Permission is hereby granted, free of charge, to any person obtaining a copy 5 1.1 cherry * of this software and associated documentation files (the "Software"), to 6 1.1 cherry * deal in the Software without restriction, including without limitation the 7 1.1 cherry * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 1.1 cherry * sell copies of the Software, and to permit persons to whom the Software is 9 1.1 cherry * furnished to do so, subject to the following conditions: 10 1.1 cherry * 11 1.1 cherry * The above copyright notice and this permission notice shall be included in 12 1.1 cherry * all copies or substantial portions of the Software. 13 1.1 cherry * 14 1.1 cherry * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 1.1 cherry * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 1.1 cherry * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 1.1 cherry * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 1.1 cherry * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 1.1 cherry * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 1.1 cherry * DEALINGS IN THE SOFTWARE. 21 1.1 cherry * 22 1.1 cherry * Copyright (C) 2005 Anthony Liguori <aliguori (at) us.ibm.com> 23 1.1 cherry * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru (at) redhat.com> 24 1.1 cherry */ 25 1.1 cherry 26 1.1 cherry #ifndef __XEN_PUBLIC_IO_FBIF_H__ 27 1.1 cherry #define __XEN_PUBLIC_IO_FBIF_H__ 28 1.1 cherry 29 1.1 cherry /* Out events (frontend -> backend) */ 30 1.1 cherry 31 1.1 cherry /* 32 1.1 cherry * Out events may be sent only when requested by backend, and receipt 33 1.1 cherry * of an unknown out event is an error. 34 1.1 cherry */ 35 1.1 cherry 36 1.1 cherry /* Event type 1 currently not used */ 37 1.1 cherry /* 38 1.1 cherry * Framebuffer update notification event 39 1.1 cherry * Capable frontend sets feature-update in xenstore. 40 1.1 cherry * Backend requests it by setting request-update in xenstore. 41 1.1 cherry */ 42 1.1 cherry #define XENFB_TYPE_UPDATE 2 43 1.1 cherry 44 1.1 cherry struct xenfb_update 45 1.1 cherry { 46 1.1 cherry uint8_t type; /* XENFB_TYPE_UPDATE */ 47 1.1 cherry int32_t x; /* source x */ 48 1.1 cherry int32_t y; /* source y */ 49 1.1 cherry int32_t width; /* rect width */ 50 1.1 cherry int32_t height; /* rect height */ 51 1.1 cherry }; 52 1.1 cherry 53 1.1 cherry /* 54 1.1 cherry * Framebuffer resize notification event 55 1.1 cherry * Capable backend sets feature-resize in xenstore. 56 1.1 cherry */ 57 1.1 cherry #define XENFB_TYPE_RESIZE 3 58 1.1 cherry 59 1.1 cherry struct xenfb_resize 60 1.1 cherry { 61 1.1 cherry uint8_t type; /* XENFB_TYPE_RESIZE */ 62 1.1 cherry int32_t width; /* width in pixels */ 63 1.1 cherry int32_t height; /* height in pixels */ 64 1.1 cherry int32_t stride; /* stride in bytes */ 65 1.1 cherry int32_t depth; /* depth in bits */ 66 1.1 cherry int32_t offset; /* offset of the framebuffer in bytes */ 67 1.1 cherry }; 68 1.1 cherry 69 1.1 cherry #define XENFB_OUT_EVENT_SIZE 40 70 1.1 cherry 71 1.1 cherry union xenfb_out_event 72 1.1 cherry { 73 1.1 cherry uint8_t type; 74 1.1 cherry struct xenfb_update update; 75 1.1 cherry struct xenfb_resize resize; 76 1.1 cherry char pad[XENFB_OUT_EVENT_SIZE]; 77 1.1 cherry }; 78 1.1 cherry 79 1.1 cherry /* In events (backend -> frontend) */ 80 1.1 cherry 81 1.1 cherry /* 82 1.1 cherry * Frontends should ignore unknown in events. 83 1.1 cherry */ 84 1.1 cherry 85 1.1 cherry /* 86 1.1 cherry * Framebuffer refresh period advice 87 1.1 cherry * Backend sends it to advise the frontend their preferred period of 88 1.1 cherry * refresh. Frontends that keep the framebuffer constantly up-to-date 89 1.1 cherry * just ignore it. Frontends that use the advice should immediately 90 1.1 cherry * refresh the framebuffer (and send an update notification event if 91 1.1 cherry * those have been requested), then use the update frequency to guide 92 1.1 cherry * their periodical refreshs. 93 1.1 cherry */ 94 1.1 cherry #define XENFB_TYPE_REFRESH_PERIOD 1 95 1.1 cherry #define XENFB_NO_REFRESH 0 96 1.1 cherry 97 1.1 cherry struct xenfb_refresh_period 98 1.1 cherry { 99 1.1 cherry uint8_t type; /* XENFB_TYPE_UPDATE_PERIOD */ 100 1.1 cherry uint32_t period; /* period of refresh, in ms, 101 1.1 cherry * XENFB_NO_REFRESH if no refresh is needed */ 102 1.1 cherry }; 103 1.1 cherry 104 1.1 cherry #define XENFB_IN_EVENT_SIZE 40 105 1.1 cherry 106 1.1 cherry union xenfb_in_event 107 1.1 cherry { 108 1.1 cherry uint8_t type; 109 1.1 cherry struct xenfb_refresh_period refresh_period; 110 1.1 cherry char pad[XENFB_IN_EVENT_SIZE]; 111 1.1 cherry }; 112 1.1 cherry 113 1.1 cherry /* shared page */ 114 1.1 cherry 115 1.1 cherry #define XENFB_IN_RING_SIZE 1024 116 1.1 cherry #define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE) 117 1.1 cherry #define XENFB_IN_RING_OFFS 1024 118 1.1 cherry #define XENFB_IN_RING(page) \ 119 1.1 cherry ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS)) 120 1.1 cherry #define XENFB_IN_RING_REF(page, idx) \ 121 1.1 cherry (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN]) 122 1.1 cherry 123 1.1 cherry #define XENFB_OUT_RING_SIZE 2048 124 1.1 cherry #define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE) 125 1.1 cherry #define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE) 126 1.1 cherry #define XENFB_OUT_RING(page) \ 127 1.1 cherry ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS)) 128 1.1 cherry #define XENFB_OUT_RING_REF(page, idx) \ 129 1.1 cherry (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN]) 130 1.1 cherry 131 1.1 cherry struct xenfb_page 132 1.1 cherry { 133 1.1 cherry uint32_t in_cons, in_prod; 134 1.1 cherry uint32_t out_cons, out_prod; 135 1.1 cherry 136 1.1 cherry int32_t width; /* the width of the framebuffer (in pixels) */ 137 1.1 cherry int32_t height; /* the height of the framebuffer (in pixels) */ 138 1.1 cherry uint32_t line_length; /* the length of a row of pixels (in bytes) */ 139 1.1 cherry uint32_t mem_length; /* the length of the framebuffer (in bytes) */ 140 1.1 cherry uint8_t depth; /* the depth of a pixel (in bits) */ 141 1.1 cherry 142 1.1 cherry /* 143 1.1 cherry * Framebuffer page directory 144 1.1 cherry * 145 1.1 cherry * Each directory page holds PAGE_SIZE / sizeof(*pd) 146 1.1 cherry * framebuffer pages, and can thus map up to PAGE_SIZE * 147 1.1 cherry * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and 148 1.1 cherry * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2 Megs 149 1.1 cherry * 64 bit. 256 directories give enough room for a 512 Meg 150 1.1 cherry * framebuffer with a max resolution of 12,800x10,240. Should 151 1.1 cherry * be enough for a while with room leftover for expansion. 152 1.1 cherry */ 153 1.1 cherry unsigned long pd[256]; 154 1.1 cherry }; 155 1.1 cherry 156 1.1 cherry /* 157 1.1 cherry * Wart: xenkbd needs to know default resolution. Put it here until a 158 1.1 cherry * better solution is found, but don't leak it to the backend. 159 1.1 cherry */ 160 1.1 cherry #ifdef __KERNEL__ 161 1.1 cherry #define XENFB_WIDTH 800 162 1.1 cherry #define XENFB_HEIGHT 600 163 1.1 cherry #define XENFB_DEPTH 32 164 1.1 cherry #endif 165 1.1 cherry 166 1.1 cherry #endif 167 1.1 cherry 168 1.1 cherry /* 169 1.1 cherry * Local variables: 170 1.1 cherry * mode: C 171 1.1 cherry * c-file-style: "BSD" 172 1.1 cherry * c-basic-offset: 4 173 1.1 cherry * tab-width: 4 174 1.1 cherry * indent-tabs-mode: nil 175 1.1 cherry * End: 176 1.1 cherry */ 177