18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * fbif.h -- Xen virtual frame buffer device 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 58c2ecf20Sopenharmony_ci * of this software and associated documentation files (the "Software"), to 68c2ecf20Sopenharmony_ci * deal in the Software without restriction, including without limitation the 78c2ecf20Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 88c2ecf20Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is 98c2ecf20Sopenharmony_ci * furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 178c2ecf20Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 188c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 198c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 208c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com> 238c2ecf20Sopenharmony_ci * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com> 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#ifndef __XEN_PUBLIC_IO_FBIF_H__ 278c2ecf20Sopenharmony_ci#define __XEN_PUBLIC_IO_FBIF_H__ 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* Out events (frontend -> backend) */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* 328c2ecf20Sopenharmony_ci * Out events may be sent only when requested by backend, and receipt 338c2ecf20Sopenharmony_ci * of an unknown out event is an error. 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* Event type 1 currently not used */ 378c2ecf20Sopenharmony_ci/* 388c2ecf20Sopenharmony_ci * Framebuffer update notification event 398c2ecf20Sopenharmony_ci * Capable frontend sets feature-update in xenstore. 408c2ecf20Sopenharmony_ci * Backend requests it by setting request-update in xenstore. 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_ci#define XENFB_TYPE_UPDATE 2 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistruct xenfb_update { 458c2ecf20Sopenharmony_ci uint8_t type; /* XENFB_TYPE_UPDATE */ 468c2ecf20Sopenharmony_ci int32_t x; /* source x */ 478c2ecf20Sopenharmony_ci int32_t y; /* source y */ 488c2ecf20Sopenharmony_ci int32_t width; /* rect width */ 498c2ecf20Sopenharmony_ci int32_t height; /* rect height */ 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * Framebuffer resize notification event 548c2ecf20Sopenharmony_ci * Capable backend sets feature-resize in xenstore. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci#define XENFB_TYPE_RESIZE 3 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct xenfb_resize { 598c2ecf20Sopenharmony_ci uint8_t type; /* XENFB_TYPE_RESIZE */ 608c2ecf20Sopenharmony_ci int32_t width; /* width in pixels */ 618c2ecf20Sopenharmony_ci int32_t height; /* height in pixels */ 628c2ecf20Sopenharmony_ci int32_t stride; /* stride in bytes */ 638c2ecf20Sopenharmony_ci int32_t depth; /* depth in bits */ 648c2ecf20Sopenharmony_ci int32_t offset; /* start offset within framebuffer */ 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define XENFB_OUT_EVENT_SIZE 40 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciunion xenfb_out_event { 708c2ecf20Sopenharmony_ci uint8_t type; 718c2ecf20Sopenharmony_ci struct xenfb_update update; 728c2ecf20Sopenharmony_ci struct xenfb_resize resize; 738c2ecf20Sopenharmony_ci char pad[XENFB_OUT_EVENT_SIZE]; 748c2ecf20Sopenharmony_ci}; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* In events (backend -> frontend) */ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* 798c2ecf20Sopenharmony_ci * Frontends should ignore unknown in events. 808c2ecf20Sopenharmony_ci * No in events currently defined. 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define XENFB_IN_EVENT_SIZE 40 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciunion xenfb_in_event { 868c2ecf20Sopenharmony_ci uint8_t type; 878c2ecf20Sopenharmony_ci char pad[XENFB_IN_EVENT_SIZE]; 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* shared page */ 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define XENFB_IN_RING_SIZE 1024 938c2ecf20Sopenharmony_ci#define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE) 948c2ecf20Sopenharmony_ci#define XENFB_IN_RING_OFFS 1024 958c2ecf20Sopenharmony_ci#define XENFB_IN_RING(page) \ 968c2ecf20Sopenharmony_ci ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS)) 978c2ecf20Sopenharmony_ci#define XENFB_IN_RING_REF(page, idx) \ 988c2ecf20Sopenharmony_ci (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN]) 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define XENFB_OUT_RING_SIZE 2048 1018c2ecf20Sopenharmony_ci#define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE) 1028c2ecf20Sopenharmony_ci#define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE) 1038c2ecf20Sopenharmony_ci#define XENFB_OUT_RING(page) \ 1048c2ecf20Sopenharmony_ci ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS)) 1058c2ecf20Sopenharmony_ci#define XENFB_OUT_RING_REF(page, idx) \ 1068c2ecf20Sopenharmony_ci (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN]) 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cistruct xenfb_page { 1098c2ecf20Sopenharmony_ci uint32_t in_cons, in_prod; 1108c2ecf20Sopenharmony_ci uint32_t out_cons, out_prod; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci int32_t width; /* width of the framebuffer (in pixels) */ 1138c2ecf20Sopenharmony_ci int32_t height; /* height of the framebuffer (in pixels) */ 1148c2ecf20Sopenharmony_ci uint32_t line_length; /* length of a row of pixels (in bytes) */ 1158c2ecf20Sopenharmony_ci uint32_t mem_length; /* length of the framebuffer (in bytes) */ 1168c2ecf20Sopenharmony_ci uint8_t depth; /* depth of a pixel (in bits) */ 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci /* 1198c2ecf20Sopenharmony_ci * Framebuffer page directory 1208c2ecf20Sopenharmony_ci * 1218c2ecf20Sopenharmony_ci * Each directory page holds PAGE_SIZE / sizeof(*pd) 1228c2ecf20Sopenharmony_ci * framebuffer pages, and can thus map up to PAGE_SIZE * 1238c2ecf20Sopenharmony_ci * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and 1248c2ecf20Sopenharmony_ci * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2 1258c2ecf20Sopenharmony_ci * Megs 64 bit. 256 directories give enough room for a 512 1268c2ecf20Sopenharmony_ci * Meg framebuffer with a max resolution of 12,800x10,240. 1278c2ecf20Sopenharmony_ci * Should be enough for a while with room leftover for 1288c2ecf20Sopenharmony_ci * expansion. 1298c2ecf20Sopenharmony_ci */ 1308c2ecf20Sopenharmony_ci unsigned long pd[256]; 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci/* 1348c2ecf20Sopenharmony_ci * Wart: xenkbd needs to know default resolution. Put it here until a 1358c2ecf20Sopenharmony_ci * better solution is found, but don't leak it to the backend. 1368c2ecf20Sopenharmony_ci */ 1378c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 1388c2ecf20Sopenharmony_ci#define XENFB_WIDTH 800 1398c2ecf20Sopenharmony_ci#define XENFB_HEIGHT 600 1408c2ecf20Sopenharmony_ci#define XENFB_DEPTH 32 1418c2ecf20Sopenharmony_ci#endif 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#endif 144