Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * fbif.h -- Xen virtual frame buffer device
0004  *
0005  * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
0006  * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
0007  */
0008 
0009 #ifndef __XEN_PUBLIC_IO_FBIF_H__
0010 #define __XEN_PUBLIC_IO_FBIF_H__
0011 
0012 /* Out events (frontend -> backend) */
0013 
0014 /*
0015  * Out events may be sent only when requested by backend, and receipt
0016  * of an unknown out event is an error.
0017  */
0018 
0019 /* Event type 1 currently not used */
0020 /*
0021  * Framebuffer update notification event
0022  * Capable frontend sets feature-update in xenstore.
0023  * Backend requests it by setting request-update in xenstore.
0024  */
0025 #define XENFB_TYPE_UPDATE 2
0026 
0027 struct xenfb_update {
0028     uint8_t type;       /* XENFB_TYPE_UPDATE */
0029     int32_t x;      /* source x */
0030     int32_t y;      /* source y */
0031     int32_t width;      /* rect width */
0032     int32_t height;     /* rect height */
0033 };
0034 
0035 /*
0036  * Framebuffer resize notification event
0037  * Capable backend sets feature-resize in xenstore.
0038  */
0039 #define XENFB_TYPE_RESIZE 3
0040 
0041 struct xenfb_resize {
0042     uint8_t type;       /* XENFB_TYPE_RESIZE */
0043     int32_t width;      /* width in pixels */
0044     int32_t height;     /* height in pixels */
0045     int32_t stride;     /* stride in bytes */
0046     int32_t depth;      /* depth in bits */
0047     int32_t offset;     /* start offset within framebuffer */
0048 };
0049 
0050 #define XENFB_OUT_EVENT_SIZE 40
0051 
0052 union xenfb_out_event {
0053     uint8_t type;
0054     struct xenfb_update update;
0055     struct xenfb_resize resize;
0056     char pad[XENFB_OUT_EVENT_SIZE];
0057 };
0058 
0059 /* In events (backend -> frontend) */
0060 
0061 /*
0062  * Frontends should ignore unknown in events.
0063  * No in events currently defined.
0064  */
0065 
0066 #define XENFB_IN_EVENT_SIZE 40
0067 
0068 union xenfb_in_event {
0069     uint8_t type;
0070     char pad[XENFB_IN_EVENT_SIZE];
0071 };
0072 
0073 /* shared page */
0074 
0075 #define XENFB_IN_RING_SIZE 1024
0076 #define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
0077 #define XENFB_IN_RING_OFFS 1024
0078 #define XENFB_IN_RING(page) \
0079     ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
0080 #define XENFB_IN_RING_REF(page, idx) \
0081     (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
0082 
0083 #define XENFB_OUT_RING_SIZE 2048
0084 #define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
0085 #define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
0086 #define XENFB_OUT_RING(page) \
0087     ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
0088 #define XENFB_OUT_RING_REF(page, idx) \
0089     (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
0090 
0091 struct xenfb_page {
0092     uint32_t in_cons, in_prod;
0093     uint32_t out_cons, out_prod;
0094 
0095     int32_t width;          /* width of the framebuffer (in pixels) */
0096     int32_t height;         /* height of the framebuffer (in pixels) */
0097     uint32_t line_length;   /* length of a row of pixels (in bytes) */
0098     uint32_t mem_length;    /* length of the framebuffer (in bytes) */
0099     uint8_t depth;          /* depth of a pixel (in bits) */
0100 
0101     /*
0102      * Framebuffer page directory
0103      *
0104      * Each directory page holds PAGE_SIZE / sizeof(*pd)
0105      * framebuffer pages, and can thus map up to PAGE_SIZE *
0106      * PAGE_SIZE / sizeof(*pd) bytes.  With PAGE_SIZE == 4096 and
0107      * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2
0108      * Megs 64 bit.  256 directories give enough room for a 512
0109      * Meg framebuffer with a max resolution of 12,800x10,240.
0110      * Should be enough for a while with room leftover for
0111      * expansion.
0112      */
0113     unsigned long pd[256];
0114 };
0115 
0116 /*
0117  * Wart: xenkbd needs to know default resolution.  Put it here until a
0118  * better solution is found, but don't leak it to the backend.
0119  */
0120 #ifdef __KERNEL__
0121 #define XENFB_WIDTH 800
0122 #define XENFB_HEIGHT 600
0123 #define XENFB_DEPTH 32
0124 #endif
0125 
0126 #endif