1181624Skmacy/* 2181624Skmacy * fbif.h -- Xen virtual frame buffer device 3181624Skmacy * 4181624Skmacy * Permission is hereby granted, free of charge, to any person obtaining a copy 5181624Skmacy * of this software and associated documentation files (the "Software"), to 6181624Skmacy * deal in the Software without restriction, including without limitation the 7181624Skmacy * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8181624Skmacy * sell copies of the Software, and to permit persons to whom the Software is 9181624Skmacy * furnished to do so, subject to the following conditions: 10181624Skmacy * 11181624Skmacy * The above copyright notice and this permission notice shall be included in 12181624Skmacy * all copies or substantial portions of the Software. 13181624Skmacy * 14181624Skmacy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15181624Skmacy * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16181624Skmacy * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17181624Skmacy * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18181624Skmacy * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19181624Skmacy * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20181624Skmacy * DEALINGS IN THE SOFTWARE. 21181624Skmacy * 22181624Skmacy * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com> 23181624Skmacy * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com> 24181624Skmacy */ 25181624Skmacy 26181624Skmacy#ifndef __XEN_PUBLIC_IO_FBIF_H__ 27181624Skmacy#define __XEN_PUBLIC_IO_FBIF_H__ 28181624Skmacy 29181624Skmacy/* Out events (frontend -> backend) */ 30181624Skmacy 31181624Skmacy/* 32181624Skmacy * Out events may be sent only when requested by backend, and receipt 33181624Skmacy * of an unknown out event is an error. 34181624Skmacy */ 35181624Skmacy 36181624Skmacy/* Event type 1 currently not used */ 37181624Skmacy/* 38181624Skmacy * Framebuffer update notification event 39181624Skmacy * Capable frontend sets feature-update in xenstore. 40181624Skmacy * Backend requests it by setting request-update in xenstore. 41181624Skmacy */ 42181624Skmacy#define XENFB_TYPE_UPDATE 2 43181624Skmacy 44181624Skmacystruct xenfb_update 45181624Skmacy{ 46181624Skmacy uint8_t type; /* XENFB_TYPE_UPDATE */ 47181624Skmacy int32_t x; /* source x */ 48181624Skmacy int32_t y; /* source y */ 49181624Skmacy int32_t width; /* rect width */ 50181624Skmacy int32_t height; /* rect height */ 51181624Skmacy}; 52181624Skmacy 53183375Skmacy/* 54183375Skmacy * Framebuffer resize notification event 55183375Skmacy * Capable backend sets feature-resize in xenstore. 56183375Skmacy */ 57183375Skmacy#define XENFB_TYPE_RESIZE 3 58183375Skmacy 59183375Skmacystruct xenfb_resize 60183375Skmacy{ 61183375Skmacy uint8_t type; /* XENFB_TYPE_RESIZE */ 62183375Skmacy int32_t width; /* width in pixels */ 63183375Skmacy int32_t height; /* height in pixels */ 64183375Skmacy int32_t stride; /* stride in bytes */ 65183375Skmacy int32_t depth; /* depth in bits */ 66183375Skmacy int32_t offset; /* offset of the framebuffer in bytes */ 67183375Skmacy}; 68183375Skmacy 69181624Skmacy#define XENFB_OUT_EVENT_SIZE 40 70181624Skmacy 71181624Skmacyunion xenfb_out_event 72181624Skmacy{ 73181624Skmacy uint8_t type; 74181624Skmacy struct xenfb_update update; 75183375Skmacy struct xenfb_resize resize; 76181624Skmacy char pad[XENFB_OUT_EVENT_SIZE]; 77181624Skmacy}; 78181624Skmacy 79181624Skmacy/* In events (backend -> frontend) */ 80181624Skmacy 81181624Skmacy/* 82181624Skmacy * Frontends should ignore unknown in events. 83181624Skmacy */ 84181624Skmacy 85183375Skmacy/* 86183375Skmacy * Framebuffer refresh period advice 87183375Skmacy * Backend sends it to advise the frontend their preferred period of 88183375Skmacy * refresh. Frontends that keep the framebuffer constantly up-to-date 89183375Skmacy * just ignore it. Frontends that use the advice should immediately 90183375Skmacy * refresh the framebuffer (and send an update notification event if 91183375Skmacy * those have been requested), then use the update frequency to guide 92183375Skmacy * their periodical refreshs. 93183375Skmacy */ 94183375Skmacy#define XENFB_TYPE_REFRESH_PERIOD 1 95183375Skmacy#define XENFB_NO_REFRESH 0 96183375Skmacy 97183375Skmacystruct xenfb_refresh_period 98183375Skmacy{ 99183375Skmacy uint8_t type; /* XENFB_TYPE_UPDATE_PERIOD */ 100183375Skmacy uint32_t period; /* period of refresh, in ms, 101183375Skmacy * XENFB_NO_REFRESH if no refresh is needed */ 102183375Skmacy}; 103183375Skmacy 104181624Skmacy#define XENFB_IN_EVENT_SIZE 40 105181624Skmacy 106181624Skmacyunion xenfb_in_event 107181624Skmacy{ 108181624Skmacy uint8_t type; 109183375Skmacy struct xenfb_refresh_period refresh_period; 110181624Skmacy char pad[XENFB_IN_EVENT_SIZE]; 111181624Skmacy}; 112181624Skmacy 113181624Skmacy/* shared page */ 114181624Skmacy 115181624Skmacy#define XENFB_IN_RING_SIZE 1024 116181624Skmacy#define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE) 117181624Skmacy#define XENFB_IN_RING_OFFS 1024 118181624Skmacy#define XENFB_IN_RING(page) \ 119181624Skmacy ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS)) 120181624Skmacy#define XENFB_IN_RING_REF(page, idx) \ 121181624Skmacy (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN]) 122181624Skmacy 123181624Skmacy#define XENFB_OUT_RING_SIZE 2048 124181624Skmacy#define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE) 125181624Skmacy#define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE) 126181624Skmacy#define XENFB_OUT_RING(page) \ 127181624Skmacy ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS)) 128181624Skmacy#define XENFB_OUT_RING_REF(page, idx) \ 129181624Skmacy (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN]) 130181624Skmacy 131181624Skmacystruct xenfb_page 132181624Skmacy{ 133181624Skmacy uint32_t in_cons, in_prod; 134181624Skmacy uint32_t out_cons, out_prod; 135181624Skmacy 136181624Skmacy int32_t width; /* the width of the framebuffer (in pixels) */ 137181624Skmacy int32_t height; /* the height of the framebuffer (in pixels) */ 138181624Skmacy uint32_t line_length; /* the length of a row of pixels (in bytes) */ 139181624Skmacy uint32_t mem_length; /* the length of the framebuffer (in bytes) */ 140181624Skmacy uint8_t depth; /* the depth of a pixel (in bits) */ 141181624Skmacy 142181624Skmacy /* 143181624Skmacy * Framebuffer page directory 144181624Skmacy * 145181624Skmacy * Each directory page holds PAGE_SIZE / sizeof(*pd) 146181624Skmacy * framebuffer pages, and can thus map up to PAGE_SIZE * 147181624Skmacy * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and 148183375Skmacy * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2 Megs 149183375Skmacy * 64 bit. 256 directories give enough room for a 512 Meg 150183375Skmacy * framebuffer with a max resolution of 12,800x10,240. Should 151183375Skmacy * be enough for a while with room leftover for expansion. 152181624Skmacy */ 153183375Skmacy unsigned long pd[256]; 154181624Skmacy}; 155181624Skmacy 156181624Skmacy/* 157183375Skmacy * Wart: xenkbd needs to know default resolution. Put it here until a 158183375Skmacy * better solution is found, but don't leak it to the backend. 159181624Skmacy */ 160181624Skmacy#ifdef __KERNEL__ 161181624Skmacy#define XENFB_WIDTH 800 162181624Skmacy#define XENFB_HEIGHT 600 163181624Skmacy#define XENFB_DEPTH 32 164181624Skmacy#endif 165181624Skmacy 166181624Skmacy#endif 167181624Skmacy 168181624Skmacy/* 169181624Skmacy * Local variables: 170181624Skmacy * mode: C 171181624Skmacy * c-set-style: "BSD" 172181624Skmacy * c-basic-offset: 4 173181624Skmacy * tab-width: 4 174181624Skmacy * indent-tabs-mode: nil 175181624Skmacy * End: 176181624Skmacy */ 177